The software versions used in this series of tutorials are as follows:
eclipse:3.4.2, Eclipse IDE for Java EE developers
jboss:5.0.1,http://www.jboss.org/jbossas/downloads/
jdk:1.6.0.14,http://java.sun.com/javase/downloads/index.jsp
A simple stateless Sessionbean is written in this article. When you publish an EJB, you typically need to publish the EJB program as a jar file. These jar files will be placed in the <jboss installation directory >\server\default\deploy directory. If you are developing an EJB program in Eclipse, you need to make some configuration. The preferred option is to set the JBoss installation directory (such as D:\JBOSS5) in the Preferences (Preferences) dialog box. Then add the run items for JBoss in the Run Configuration dialog box. In jboss4.2 and later versions, JBoss receives only requests from localhost or 127.0.0.1 by default, that is, only local access is received. In order for JBoss to receive requests from other addresses, the-B command-line argument needs to be set when the JBoss is started. As shown in the following startup command:
Run.bat-b 200.200.200.123
Run.bat-b 0.0.0.0
The first line above indicates that JBoss can receive requests from 200.200.200.123. The second command indicates that JBoss can receive requests from any address. If you do not set the-B parameter to access the EJB in a non-native way, JBoss throws the following exception:
Exception in thread ' main ' javax.naming.CommunicationException:Could not obtain connection to any of these
urls:192. 168.17.105:1099 and Discovery failed with error:
javax.naming.CommunicationException:Receive timed out [Root Exception is
java.net.SocketTimeoutException:Receive timed out] [Root exception
is javax.naming.CommunicationException:Failed to connect to server/192.168.17.105:1099 [Root
exception is javax.naming.ServiceUnavailableException:Failed to connect to server
/192.168.17.105:1099 [Root exception is Java.net.ConnectException:Connection refused:
Connect]]
At Org.jnp.interfaces.NamingContext.checkRef (namingcontext.java:1725)
At Org.jnp.interfaces.NamingContext.lookup (namingcontext.java:689)
At Org.jnp.interfaces.NamingContext.lookup (namingcontext.java:682)
At Javax.naming.InitialContext.lookup (initialcontext.java:392)
At Test. Client.main (client.java:29)
... ...