Eclipse+jboss 5+EJB3 Development Guide (1): Write the first stateless Sessionbean

Source: Internet
Author: User
Tags versions jboss

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)
... ...

Related Article

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.