Yesterday Daoteng a day and finally configured the JBoss as 7 domain, and today Daoteng a full day to deploy an EJB on it, and then try a remote invocation using JNDI. Here's a look at the messy questions in the process:
The first is the Jboss-client.properties file, and the meaning of each attribute value can be explained from the official JBoss documentation https://docs.jboss.org/author/display/AS71/EJB+ Invocations+from+a+remote+client+using+jndi
1endpoint.name=client-Endpoint2Remote.connectionprovider.create.options.org.xnio.options.ssl_enabled=false3remote.connections=default4Remote.connection.default. host=192.168.1.335Remote.connection.default. port=44476Remote.connection.default. connect.options.org.xnio.options.sasl_policy_noanonymous=false7Remote.connection.default. username=Mosmith8Remote.connection.default. password=mtizndu2
Endpoint.name is an optional parameter for the name used by the EJB receiver to create the connection, and if not set the default value will be used: Config-based-ejb-client-endpoint
Remote.connectionprovider.create.options.org.xnio.options.ssl_enabled=false is officially used to deal with the creation of connection provider. remote://the parameters of the protocol, but specifically what does not say, according to this name seems to be related to security (purely speculation)
Remote.connections=default, which is specifying the connection configuration name, we can create multiple configurations, see official documentation for details
It is important to note that:
Username is a user in application user in JBoss
Password This property is encoded with the base64 of the user's password.
Here is the remote calling code of my program, which is basically the same as the official one:
1 Packagecom.bes.training.ejb.EJBRemoteInvocation;2 3 Importcom.bes.training.ejb.helloworld.*;4 5 Importjavax.naming.*;6 ImportJava.util.*;7 8 Public classRemoteinvocationdemo {9 Public Static voidMain (string[] args) {Ten OneHashtable<string,string> jndiproperties=NewHashtable<string,string>(); AJndiproperties.put (context.url_pkg_prefixes, "org.jboss.ejb.client.naming"); - //jndiproperties.put (context.initial_context_factory, "org.jboss.naming.remote.client.InitialContextFactory") ; -Jndiproperties.put ("Jboss.naming.client.ejb.context", "true"); the - Try{ -Context context=NewInitialContext (jndiproperties); -Object obj=context.lookup ("Ejb:/temp//sayhelloimpl!com.bes.training.ejb.helloworld.sayhelloimplremote" ); + -Sayhelloimplremote intf=(sayhelloimplremote) obj; +String Result=intf.sayhello ("Mosmith"); A System.out.println (result); at -}Catch(namingexception e) { - System.out.println (E.getmessage ()); - e.printstacktrace (); - } - } in}
However, when running in Eclipse, there is an exception for the No EJB receiver available for handling: Daoteng has been a long time, so I suspect-djboss.ejb.client.properties.file.path= Jndi.properties parameter does not work, so the command line run a bit, normal! Back to eclipse, check carefully and find that the parameter is set incorrectly:
Should be set in VM arguments instead of program arguments. Beginners must pay attention to the difference here ah.
Remote Invoke EJB deployed on JBoss as 7 appears no EJB receiver available for handling exception