1 / 83

JBoss Technology - Installation on AFS and Deployment of a Simple EJB

JBoss Technology - Installation on AFS and Deployment of a Simple EJB. Himanshu Shah Jasmeet S. Sangari Ajay Bajaj Urszula Gutmanski. JBoss. JBoss is an application server written in Java that can host business components developed in Java. Open source-developed application server.

creighton
Download Presentation

JBoss Technology - Installation on AFS and Deployment of a Simple EJB

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JBoss Technology - Installation on AFS and Deployment of a Simple EJB Himanshu Shah Jasmeet S. Sangari Ajay Bajaj Urszula Gutmanski

  2. JBoss • JBoss is an application server written in Java that can host business components developed in Java. • Open source-developed application server. • Started in 1999 and distributed under an LGPL license • JBoss provides EJB container. • JBoss is supplied with “Hypersonic” database

  3. With or without Tomcat? • This tutorial was written by persons from two different teams, with comments from several other teams. Both tutorials were based on examples from the JBoss site. • 1) To use JBoss as both a Web Server and EJB container, continue with the next slide. • 2) To install the JBoss EJB container with the Tomcat Web Server start here. • In 2003 and 2004, about 12 teams successfully used JBoss. Most had to make extensive use of materials found on Web sites other than the JBoss site to succeed.

  4. Download JBoss • Download latest version of Jboss from http://jboss.org/index.html • Unpack the zip file: • JBoss is distributed as a ZIP archive • Unzip the archive using UNIX unzip command unzip jboss-3.2.0.zip

  5. Directory structure of Jboss • bin directory contains scripts to run or shutdown server • client directory: where you have to store your client program • docs directory contains XML DTD’s used in jboss for reference. • lib directory contains necessary files to start the server • server directory: where you have deploy your server application particular in deploy sub-directory

  6. Server Directory • ALL, DEFAULT,MINIMAL is configuration directory which is supplied with the jboss package. • By default when you start the server it will use the configuration from the default directory, which contain almost all the service to get started • If you want to run server with minimum service, copy jboss-service.xml file to minimal/config directory, server will start with minimum services. • If you want to run server with all available service copy jboss-service.xml file to all/config directory, server will start with all available services. • You may customize your own configuration . Make new directory in server directory and copy files which is necessary files needed to run server.

  7. Server Configurations • JBoss comes with three server configurations: • minimal - This configuration includes only logging, the JNDI service, and the URL deployment scanner. You would want to use this configuration for starting services that don't require J2EE or as the base for a custom configuration. • default - This configuration is the default. It includes all of the J2EE services except RMI/IIOP and clustering. • all - This configuration includes all JBoss services.

  8. Continued • Below is the absolute minimum jboss-service.xmlconfig file. • <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE server> <server> </server>

  9. Installing JBoss • Run the Server by going into the bin directory of the installation and executing java -jar run.jar • In a proper installation, the server should start without any error messages or exceptions being thrown. It will produce about three pages of output on startup.

  10. Installing JBoss (continued) • Go to your Home directory on AFS and edit the .login file as follows setenv CLASSPATH ${CLASSPATH}:${HOME}/jboss-3.2.0/server/all/lib/jboss-j2ee.jar:${HOME}/jboss-3.2.0/client/log4j.jar:${HOME}/jboss-3.2.0/client/jboss-client.jar:${HOME}/jboss-3.2.0/client/jboss-common-client.jar:${HOME}/jboss-3.2.0/client/jnp-client.jar:${HOME}/jboss-3.2.0/client/jboss-jaas.jar:${HOME}/jboss-3.2.0/client/jbosssx-client.jar • Note that jboss3.2.0 is the installation directory and this information WILL change!

  11. Run JBoss • Go to JBOSS_HOME/lib directory and run “run.sh” script if you are running from UNIX system • If you want to run from Window based system run “run.bat” script which located in same directory as “run.sh” • Type • run.sh & Note: JBOSS_HOME is absolute path to the directory where you have installed jboss

  12. Test JBoss server • Go to following URL To test the server is runing • For e.g. If you are running server on afs4 write • http://afs4.njit.edu:8080/jmx-console/ • If you are running on local host for e.g. on home computer write • http://localhost:8080/jmx-console/

  13. If you see following screen, it means your server is successfully running

  14. About screen • This is the JBoss Management Console which provides a raw view of the JMX MBeans which make up the server. • You can modify configuration using this console.

  15. Problem • If you type http://afs4.njit.edu:8080 • You might get error “Page not found” because jboss never gives access to its root directory, unless you are in NJIT domain.

  16. Shutdown • Remember always run server in background using &. So you will get command prompt back on successful completion of process where you can type “shutdown.sh” or “shutdown.dat” to shutdown server depending on type of server you are running. • Ctrl+c to shutdown the server is not a good way to shutdown. You might get errors because ctrl+c just cancels the process. If you have an application which needs to connect to the database and you use ctrl+c to shutdown the sever during an open connection to database, it keep that connection open. • If you forget to run server in background using &, just log in to the same server and type “shutdown.sh” or “shutdown.bat” which will shutdown sever remotely. • Alternatively you can shutdown the server using CONSOLE management, look for “type=Server” under the “jboss.system” section and invoke the “shutdown” operation).

  17. Shutdown(continued) • If you started JBoss in the foreground from an MS-DOS Prompt window, Command Prompt window, or Unix shell, simply press Ctrl-C in the window where JBoss is running. • To shutdown JBoss in the window or shell where it is running, press Ctrl-C. • To shutdown JBoss from another window or shell: • ·Windows: • Open an MS-DOS Prompt or Command Prompt window. • cd %JBOSS_HOME%\bin • shutdown -S or shutdown --server=url • ·Unix: • Open a shell. • cd $JBOSS_HOME/bin • ./shutdown -S or ./shutdown --server=url

  18. Two Library Directories • jboss/lib and jboss/server/default/lib are different • jboss/lib contains files which are needed to start server • jboss/server/default/lib contains files which are needed to initialize a service.

  19. To Change Default Port Note: This file is not the same as one located in JBOSS_HOME/server/default/config • By default Jboss uses port 8080 to run services • You can change the default port which is specified in jboss-service.xml located at JBOSS_HOME\server\all\deploy\jbossweb.sar\META-INF • <Call name="addListener"> <Arg> <New class="org.mortbay.http.SocketListener"> <Set name="Port"><SystemProperty name="jetty.port" default="8080"/></Set> <Set name="MinThreads">10</Set> <Set name="MaxThreads">100</Set> <Set name="MaxIdleTimeMs">30000</Set> <Set name="LowResourcePersistTimeMs">5000</Set> </New> </Arg> </Call>

  20. Content: jboss-service.xml File • This file is located in JBOSS_HOME/server/default/config directory. In this xml file you define what you want to run when you start the server • JBoss reads jboss-service.xml file and initializes components as they defined in file • The first line of jboss-service.xml <classpath codebase="lib" archives="*"/> • Add the directory which JBoss uses to run

  21. Logging Service • Jboss uses the file specified in log4j.xml to keep the log of server • <mbean code="org.jboss.logging.Log4jService" name="jboss.system:type=Log4jService,service=Logging"> <!-- <attribute name="ConfigurationURL">resource:log4j.xml</attribute> --> </mbean>

  22. Naming Service • starts the jnp JNDI server • mbean code="org.jboss.naming.NamingService" name="jboss:service=Naming"> <attribute name="Port">1099</attribute> </mbean> <mbean code="org.jboss.naming.JNDIView" name="jboss:service=JNDIView"/>

  23. Security Service • JDK 1.4 has integrated security service which means this service may not be necessary • <mbean code="org.jboss.security.plugins.SecurityConfig" name="jboss.security:name=SecurityConfig"> <attribute name="LoginConfig">jboss.security:service=XMLLoginConfig</attribute> </mbean> <mbean code="org.jboss.security.auth.login.XMLLoginConfig" name="jboss.security:service=XMLLoginConfig"> <attribute name="ConfigResource">login-config.xml</attribute> </mbean>

  24. JASS service • This service is not necessary since JDK 1.4 has integrated JASS. • <mbean code="org.jboss.security.plugins.JaasSecurityManagerService" name="jboss.security:service=JaasSecurityManager"> <attribute name="SecurityManagerClassName"> org.jboss.security.plugins.JaasSecurityManager </attribute> </mbean>

  25. Transaction service • mbean code="org.jboss.tm.XidFactory" name="jboss:service=XidFactory"> </mbean> <mbean code="org.jboss.tm.TransactionManagerService" name="jboss:service=TransactionManager"> <attribute name="TransactionTimeout">300</attribute> <depends optional-attribute-name="XidFactory">jboss:service=XidFactory</depends> </mbean> <mbean code="org.jboss.tm.usertx.server.ClientUserTransactionService" name="jboss:service=ClientUserTransaction"> </mbean>

  26. Connection manager • Connection manager is loaded via the jca-service.xml file in the deployment directory. The jca-service.xml contains configuration for the RARDeployer and the three Connection Manager Factories supplied with jboss. • Cache Connection Manager requires that jca-service.xml is installed, which comes with Jboss package • <mbean code="org.jboss.resource.connectionmanager.CachedConnectionManager" name="jboss.jca:service=CachedConnectionManager"> </mbean>

  27. EJB deployment • Use to control Enterprise java beans • <mbean code="org.jboss.ejb.EJBDeployer" name="jboss.ejb:service=EJBDeployer"> <attribute name="VerifyDeployments">true</attribute> <attribute name="ValidateDTDs">false</attribute> <attribute name="MetricsEnabled">false</attribute> <attribute name="VerifierVerbose">true</attribute> <!-- Add a dependency on the JMS provider(jms-service.xml) for MDBs. If you are not using MDBs and JMS remove these. <depends>jboss.mq:service=JMSProviderLoader,name=JBossMQProvider</depends> <depends>jboss.mq:service=ServerSessionPoolMBean,name=StdJMSPool</depends> --> </mbean>

  28. EAR deployment • EAR (Enterprise Archive) wraps up WARs and EJB-JARs. This is necessary service. • <mbean code="org.jboss.deployment.EARDeployer" name="jboss.j2ee:service=EARDeployer"> </mbean>

  29. JMPR • JMPR (Java Remote Method Protocol) is the RMI Server for JBoss • mbean code="org.jboss.invocation.jrmp.server.JRMPInvoker" name="jboss:service=invoker,type=jrmp"> <attribute name="RMIObjectPort">4444</attribute> </mbean> <mbean code="org.jboss.invocation.local.LocalInvoker" name="jboss:service=invoker,type=local"> </mbean>

  30. Deployment Scanner • This service searches for changes in application and re-deploys it if any changes are encountered in application. • mbean code="org.jboss.deployment.scanner.URLDeploymentScanner" name="jboss.deployment:type=DeploymentScanner,flavor=URL"> <depends optional-attribute-name="Deployer">jboss.system:service=MainDeployer</depends> <attribute name="URLComparator">org.jboss.deployment.DeploymentSorter</attribute> <attribute name="Filter">org.jboss.deployment.scanner.DeploymentFilter</attribute> <attribute name="ScanPeriod">5000</attribute> <attribute name="URLs"> ./deploy </attribute> • </mbean>

  31. Server Management • This service makes JBoss JSR-77 compliant. For more info on JSR-77 visit http://www.jcp.org/en/jsr/detail?id=77 • <mbean code="org.jboss.management.j2ee.SingleJBossServerManagement" name="jboss.management.single:j2eeType=J2EEDomain,name=Manager" > </mbean>

  32. Webservice • The web service which allows clients to download classes and other resources • <mbean code="org.jboss.web.WebService" name="jboss:service=Webserver"> <attribute name="Port">8083</attribute> <!-- Should resources and non-EJB classes be downloadable --> <attribute name="DownloadServerClasses">true</attribute> </mbean>

  33. References • http://jboss.org/index.html • www.sun.com • http://www.west28.com • http://www.monkeymachine.ltd.uk/

  34. Using JBoss with Tomcat Web Server for EJB Deployment

  35. Steps Required • Download and install JBoss_Tomcat (latest version). • Develop an EJB • Use JBoss, an open source EJB server to deploy the EJB.

  36. Installing and Running JBOSS • First step towards running an application in EJB is Installing the EJB Server • There are many Servers available to download, like WebLogic, WebSphere and JBoss. • But JBoss, like OpenEJB, is a free open source server available, most others are expensive.

  37. Continued • Go to the JBoss site at http://www.jboss.org/downloads.jsp and download the latest version of JBoss with Tomcat. • JBoss with Tomcat version allows us to run the Tomcat JSP/Servlets pages. • Once you have downloaded the zip file unzip it in the H:\Proj\Jboss folder using the jar xvf jboss_tomcat.zip command . • This requires around 35-40 MB of space.

  38. Continued • Once you have downloaded it and unzipped it in the h:\proj\jboss folder. • Now you are ready to run it on AFS. • To run it on AFS 1. Connect to afs3.njit.edu 2. go to h:\proj\jboss\bin

  39. Continued 3. Type run.sh at the command prompt If you have run.jar then type java –jar run.jar 4. Now if everything is installed perfectly Once “run” was typed a lot of logging information was displayed until the last line of logging output stopped displaying: 23:01:20,309 INFO [Server] JBoss (MX MicroKernel) [3.0.0 Date:200205311035] Started in 0m:43s:973ms

  40. Writing the EJB program • Before Starting the Program, make sure you have a minimum of jdk_1.4 • Set the class path for jdk_1.4\bin • For those who are running it on AFS, there is no need to do this, because JDK_1.4 is already defined in the class path.

  41. Continued • You can also download the jakarta Ant tool which helps in setting the classpath. If you are running EJB using Ant, please refer to the tutorial lecture on Ant. • It is strongly recommended that you use Ant. • One reason to use Ant is that (2004) version of JBoss with Tomcat comes with Tomcat 4 and 5, but defaults to Tomcat 4. Ant makes it easy to reconfigure to Tomcat 5 (recommended).

  42. Comment from Spring 2004 • JBOSS came integrated with Tomcat 4 and Oracle 8i. We had problems integrating JBOSS with Tomcat 5 and Oracle 9i. • Tomcat 5 was hidden as an example in the jboss-3.2.3 package. It was integrated after using ant -buildfile build-tc5-config.xml • Oracle 9i was eventually integrated after making specific changes to the jboss-service.xml and including the oracle-ds.xml in the deploy directory of the JBOSS installation.

  43. More from previous slide • Trying to use Ant to build our project was a major problem. • AFS had Ant Version 1.5 installed, probably the most buggy version of ANT, We installed Ant 1.6.1 , but then our PATH variable had to be changed so that we could use it. • (Instructor’s note) I have since requested 1.6.1 to be installed on AFS.

  44. Server side EJB • First we will write the two interface programs. • Writing the Remote Interface(HelloWorld.java) public interface HelloWorld extends javax.ejb.EJBObject{ public String hello() throws java.rmi.RemoteException; }

  45. public interfaceHelloWorldHome extends javax.ejb.EJBHome { HelloWorld create() throws java.rmi.RemoteException, javax.ejb.CreateException; } Home Interface • Writing the Home Interface (HelloWorldHome.java)

  46. HelloWorldBean.java import javax.ejb.SessionContext; /* This class is the actual implementation of the business logic. This is the EJB for simplicity's sake. */ public class HelloWorldBean implements javax.ejb.SessionBean { private SessionContext ctx; Bean Implementation • Writing the Actual Bean Implementation

  47. public void setSessionContext(SessionContext ctx) { this.ctx = ctx; } public void ejbRemove() { System.out.println( "ejbRemove()" );}public void ejbActivate() { System.out.println( "ejbActivate()" ); } public void ejbPassivate() { System.out.println( "ejbPassivate()" ) }

  48. /* The method called to display the string "Hello World!" on the client. */ public String hello() { System.out.println( "hello()" ); return "Hello World!"; } public void ejbCreate() { System.out.println( "ejbCreate()" ); } }

  49. Compiling the Server Side EJB • If you notice all the three files extends javax.ejb.*; • This is where I was stuck initially when I was trying to compile the program. Now you can download the javax.ejb package from http://java.sun.com/products/ejb/docs10.html • Include it in your class path setenv CLASSPATH /afs/cad/u/a/r/arb5/proj/javax/ejb/:$CLASSPATH Please note that arb5 is my user id, hence yours will be different.

  50. Tips • Once you have downloaded the javax.ejb package and set the appropriate class path • Compile the three java programs. • It is very important where you save these three java files. You must know the directory structure. • Place all the files in the appropriate directories.

More Related