JBOSS7 Configuring EJB Client Error: No EJB receiver available for handling resolution

Source: Internet
Author: User
Tags documentation jboss jboss server


When I first started using JBoss server, I always get an error when writing an EJB client to invoke a stateless session bean on a remote JBoss server in MyEclipse:





Exception in thread ' main ' java.lang.IllegalStateException:No EJB receiver available for handling [appname:,modulename:h Elloworld,distinctname:] Combination for invocation context org.jboss.ejb.client.ejbclientinvocationcontext@ 35ab28fe
At Org.jboss.ejb.client.EJBClientContext.requireEJBReceiver (ejbclientcontext.java:584)
At Org.jboss.ejb.client.ReceiverInterceptor.handleInvocation (receiverinterceptor.java:119)
At Org.jboss.ejb.client.EJBClientInvocationContext.sendRequest (ejbclientinvocationcontext.java:181)
At Org.jboss.ejb.client.EJBInvocationHandler.doInvoke (ejbinvocationhandler.java:136)
At Org.jboss.ejb.client.EJBInvocationHandler.doInvoke (ejbinvocationhandler.java:121)
At Org.jboss.ejb.client.EJBInvocationHandler.invoke (ejbinvocationhandler.java:104)
At $Proxy 0.sayHello (Unknown Source)
At Cn.mym.test.EJBClient.main (ejbclient.java:34)





Focus on no EJB receiver available for handling





This is because there is no link to remote JBoss (note: The remote referred to here is that the stateless session Bean is packaged and published on the JBoss server, and the server is turned on, then this client connects to JBoss through Jndi and then gets the published stateless session Bean. Finally, the corresponding object is instantiated through the EJB proxy, and then the method in the stateless session Bean published on JBoss can be used.

Paste the client code (which will cause an error before it is modified):






public class Ejbclient {

	/**
	 *<p>title:main</p>
	 * @author Ming ke
	 * @param args
	 * @throws Namingexception 
	 */public
	
	static void Main (string[] args) {
		
	Properties Props=new properties ();
        Props.setproperty (context.url_pkg_prefixes, "org.jboss.ejb.client.naming");
        Try
        {
            Context context=new initialcontext (props);
            HelloWorld hello= (HelloWorld) context.lookup ("ejb:/helloworld//helloworldbean!" +helloworld.class.getname ());
            System.out.println (Hello.sayhello ("Dara"));
        }
        catch (namingexception e)
        {
            e.printstacktrace ();}}

}





Note: The parameter value in lookup, that is, Jndi is not the same as JBOSS6 and the following version, specific reference: http://blog.csdn.net/maoyuanming0806/article/details/71122697



or refer to JBoss's official documentation, official documents I have uploaded, download address: http://download.csdn.net/detail/maoyuanming0806/9831962






Solve:



A JBoss configuration file needs to be added under the Classpath path, and this profile format can be found in the official documentation



Here I put under SRC:



FileName: jboss-ejb-client.properties (file name fixed notation






Endpoint.name=client-endpoint
Remote.connectionprovider.create.options.org.xnio.options.ssl_enabled=false
Remote.connections=default
remote.connection.default.host=127.0.0.1
Remote.connection.default.port = 4447
Remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY _noanonymous=false
remote.connection.default.username=appuser
remote.connection.default.password= Apppassword





Explanation: Altogether eight lines
1. Represents the name used to create the endpoint client
2. By setting the Org.xnio.Options.SSL_ An enabled value of false allows the link provider to use remote.connection.default.connect.options as a prefix when creating a connection          (usually not changed)
3. Indicates the number of links set to the remote server. The default indicates that a single remote link is set. You can set multiple: Remote.connections=one, two
  set up more than one representation set up two EJB receivers, you need to add EJB client
4.5.6 is host (can be localhost), The default remote port (unless modified, the default is 4447), this client link (fixed); Multiple connections The three steps will be set more than once
7.8 is the administrator user name and password, respectively. Official documents are said to have to be set up, for security reasons: Official documents: The user and password must be set because the Security-realm are enabled for the subsystem Remoti Ng (see Standalone*.xml or Domain.xml) by Defaul


After you join this document, the result of compiling the run client is as follows:






Interpretation is based on the official documentation of their own understanding, if there is a wrong translation, please point out, in this thank,  more detailed instructions see the official documentation of the local Jndi section of the remote EJB description



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.