Use eclipse to develop J2EE applications and use eclipse to develop ejbs

Source: Internet
Author: User
Tags jboss jboss server

In part 2 "using eclipse to develop Web Applications", we have added an EJB module named myejb In the J2EE project testj2ee. Next we will add a session bean to the myejb module through lomboz EJB creation wizard.

Click file-> New-> lomboz EJB creation wizard, or right-click the myejb module and choose new-> lomboz EJB creation wizard. The following dialog box is displayed:

 

 

 

 

 

Create a stateless Session Bean named myejb under the com. Dino. testj2ee. myejb package. After that, a file named myejbbean is displayed under the SRC folder of the testj2ee project. java file, right-click this file, and choose new-> lomboz EJB method wizard. You can add various methods to this EJB. I added a helloworld method to return a string type. As shown in:

 

 

 

 

 

Then, add the Session Bean myejb to the module myejb: Right-click myejb. Java and select lomboz J2EE... -> Add EJB to module and select myejb and OK.

Right-click the myejb module and select lombozj2ee... -> Generate EJB classes. In this way, the following files are automatically generated under the ejbsrc directory:

Myejbhome. Java
Myejbrome. Java
Myejblocalhome. Java
Myejblocal. Java
Myejbsession. Java (myejbsession extends myejbbean)
Myejbutil. Java

After the project is built, the module is automatically packaged. Then you can deploy the EJB module according to the steps for deploying the web module.

Finally, we create an application to test EJB.

Open a dialog box through file-> New-> lomboz EJB test client wizard, and press Enter:

 

 

 

After that, testmyejb. Java is generated under the src directory and the test code is added to the testbean method:

 System.out.println(myBean.helloWorld()); 

If the JBoss server has been started and the myejb module has been deployed, execute testmyejb and the following will be displayed in the console window:

 hehe, I can deploy EJB by Eclipse! 

Iv. Summary

Through the above introduction, we know that lomboz makes it very easy for eclipse to develop J2EE applications, and eclipse, lomboz, and JBoss tools are both free and open source projects, therefore, such combinations are more attractive to Java developers.

For developing complex J2EE applications, the above introduction may not be comprehensive enough. I hope you will understand it during the project process and share your experience on developerworks.

Appendix: jboss320.server

 <serverDefinition name="JBOSS 3.2"      ejbModules="true" webModules="true" earModules="true">  <property id="serverRootDirectory" label="Application Server Directory:"      type="directory" default="D:/jboss-3.2.0" />  <property id="serverAddress" label="Address:"      type="string" default="127.0.0.1" />  <property id="serverPort" label="Port:"      type="string" default="8080" />  <property id="classPathVariableName" label="Classpath Variable Name:"      type="string" default="JBOSS32" />  <property id="classPath" label="Classpath Variable:"      type="directory" default="D:/jboss-3.2.0" />      <serverHome>${serverRootDirectory}</serverHome>  <webModulesDeployDirectory>${serverRootDirectory}/server/all/deploy </webModulesDeployDirectory>  <ejbModulesDeployDirectory>${serverRootDirectory}/server/all/deploy </ejbModulesDeployDirectory>  <earModulesDeployDirectory>${serverRootDirectory}/server/all/deploy </earModulesDeployDirectory>  <jndiInitialContextFactory>org.jnp.interfaces.NamingContextFactory </jndiInitialContextFactory>  <jndiProviderUrl>jnp://${serverAddress}:1099</jndiProviderUrl>  <startClass>org.jboss.Main</startClass>  <startWorkingDirectory>${serverRootDirectory}/bin </startWorkingDirectory> <startVmParameters></startVmParameters>  <startProgramArguments>-c all</startProgramArguments>  <stopClass>org.jboss.Shutdown</stopClass>  <stopWorkingDirectory>${serverRootDirectory}/bin </stopWorkingDirectory>  <stopVmParameters></stopVmParameters>  <stopProgramArguments>${serverAddress} ${serverPort} </stopProgramArguments>  <serverClassPath>  <jar type="variable">JDK_TOOLS</jar>  <jar type="variable">${classPathVariableName}/bin/run.jar </jar>  <jar type="variable">${classPathVariableName}/bin/shutdown.jar </jar>  <jar type="variable">${classPathVariableName}/client/jboss-j2ee.jar </jar>  <jar type="variable">${classPathVariableName}/server/all/lib/javax.servlet.jar </jar> <jar type="variable">${classPathVariableName}/lib/commons-httpclient.jar </jar>  <jar type="variable">${classPathVariableName}/lib/concurrent.jar </jar>  <jar type="variable">${classPathVariableName}/lib/getopt.jar </jar>  <jar type="variable">${classPathVariableName}/lib/jboss-boot.jar </jar>  <jar type="variable">${classPathVariableName}/lib/jboss-common.jar </jar>  <jar type="variable">${classPathVariableName}/lib/jboss-jmx.jar </jar>  <jar type="variable">${classPathVariableName}/lib/jboss-system.jar </jar>  <jar type="variable">${classPathVariableName}/lib/jdom.jar </jar>  <jar type="variable">${classPathVariableName}/lib/log4j-boot.jar </jar>  <jar type="variable">${classPathVariableName}/lib/webdavlib.jar </jar>  <jar type="variable">${classPathVariableName}/lib/xercesImpl.jar </jar>  <jar type="variable">${classPathVariableName}/lib/xml-apis.jar </jar>  <jar type="variable">${classPathVariableName}/server/all/lib/jnet.jar </jar> <jar type="variable">${classPathVariableName}/lib/gnu-regexp.jar </jar>  <jar type="variable">${classPathVariableName}/server/all/lib/jboss.jar </jar> <jar type="variable">${classPathVariableName}/server/all/lib/jnpserver.jar </jar>  <jar type="variable">${classPathVariableName}/server/all/lib/jpl-util.jar </jar>  <jar type="variable">${classPathVariableName}/server/all/lib/jpl-pattern.jar </jar>  <jar type="variable">${classPathVariableName}/server/all/lib/jsse.jar </jar>  <jar type="variable">${classPathVariableName}/server/all/lib/jbossha.jar </jar>  <jar type="variable">${classPathVariableName}/server/all/lib/jboss-jaas.jar </jar>  <jar type="variable">${classPathVariableName}/server/all/lib/jts.jar </jar>  <jar type="variable"> ${classPathVariableName}/server/all/lib/jboss-transaction.jar </jar>  <jar type="variable">${classPathVariableName}/server/all/lib/javagroups-2.0.jar </jar>  <jar type="variable">${classPathVariableName}/server/all/lib/jmxri.jar </jar>  <jar type="variable">${classPathVariableName}/server/all/lib/jmxtools.jar </jar>  <jar type="variable">${classPathVariableName}/server/all/lib/jbossmx.jar </jar>  </serverClassPath>  <clientClassPath>  <jar type="variable">${classPathVariableName}/client/jboss-j2ee.jar </jar>  <jar type="variable">${classPathVariableName}/client/jnp-client.jar </jar>  <jar type="variable">${classPathVariableName}/client/jboss-client.jar </jar>  <jar type="variable">${classPathVariableName}/client/jboss-common-client.jar </jar>  <jar type="variable">${classPathVariableName}/client/jbosssx-client.jar </jar>  <jar type="variable">${classPathVariableName}/client/log4j.jar </jar>  <jar type="variable">${classPathVariableName}/client/jnet.jar </jar>  <jar type="variable">${classPathVariableName}/client/jaas.jar </jar>  </clientClassPath>  </serverDefinition> 

References

  • Official website of www.eclipse.org eclipse;
  • Official website of www.jboss.org JBoss;
  • The website www.objectlearn.com lomboz contains the lomboz tutorial.
  • Eclipse in Action: A Guide for Web developers, by David Gallardo, Ed Burnette and Robert McGovern, Manning publications. A good book about eclipse development.
  • JBoss 3.0: Quick Start Guide, by JBoss group. A good book on getting started with JBoss.
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.