1 / 11

Tech-Day

Tech-Day. starring: JBoss & EJBs special guest: Tomcat & Servlets. JBoss. Download JBoss from http://www.jboss.org get version 2.4.4 (you don’t need src) Uncompress it to /usr/local/jboss You will need to set the environment variable JAVA_HOME to point to your java directory.

gavivi
Download Presentation

Tech-Day

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. Tech-Day starring: JBoss & EJBs special guest: Tomcat & Servlets

  2. JBoss • Download JBoss from • http://www.jboss.org • get version 2.4.4 (you don’t need src) • Uncompress it to /usr/local/jboss • You will need to set the environment variable JAVA_HOME to point to your java directory. • Do this in /etc/profile

  3. JBoss cont. • You should now be able to • cd /usr/local/jboss/bin • run.sh • Hopefully everything will come up • Now download my examples from the lecture page.

  4. Building Hello World EJB • Place all java files in a directory ~/HelloBean • Place build.xml in the same directory • Place all other xml files in ~/HelloBean/META-INF • Compile and build the bean

  5. Compiling the bean • Go get ant and install it • http://jakarta.apache.org • Compile all source files together ant compile • javac –d . *.java –classpath … • You will need a few jars in your classpath • JBoss connection jars • /usr/local/jboss/client/*.jar • list each individually • look in build.xml for an example

  6. Building & deploying the bean • Create the bean jar file ant ejb-jar • jar cvf HelloBean.jar * • Deploy the bean ant deploy • cp HelloBean.jar /usr/local/jboss/deploy • At this point, you should see some messages go by from JBoss • [INFO,J2eeDeployer] J2EE application: file:/usr/local/jboss/deploy/HelloBean.jar is deployed.

  7. Running the java client • Compile the java client ant compile • same as compiling the bean • you still need the client jars in your classpath • Run the client ant client • you still need the client jars in your classpath • You should see: client: [java] ClassPath is: C:\JBoss\client\jboss- j2ee.jar;C:\JBoss\client\jaas.jar;C:\JBoss\client\jbosssx- client.jar;C:\JBoss\client\jboss-client.jar;C:\JBoss\client\jnp- client.jar;C:\snell\public_html\TestApps\HelloBean [java] <font color="RED">Hello There From the Bean</font>

  8. Working with servlets • Tomcat needs to see the jboss client jars • place them in /var/tomcat4/lib • Build the servlet ant servlet • you will need to modify some of the paths • Restart tomcat • Go to the servlet url

  9. JBoss and PostgreSQL • You need to tell JBoss about PostgreSQL • edit /usr/local/jboss/conf/default/jboss.jcml <!-- ==================================================================== --> <!-- JDBC --> <!-- ==================================================================== --> … stuff … <mbean code="org.jboss.jdbc.JdbcProvider" name="DefaultDomain:service=JdbcProvider2"> <attribute name="Drivers">org.postgresql.Driver</attribute> </mbean> <mbean code="org.jboss.jdbc.XADataSourceLoader" name="DefaultDomain:service=XADataSource,name=PostgresDB"> <attribute name="DataSourceClass">org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl</attribute> <attribute name="PoolName">PostgresDS</attribute> <attribute name="URL">jdbc:postgresql://localhost:5432/yourdb</attribute> <attribute name="JDBCUser">postgres</attribute> <attribute name="Password">postgres</attribute> </mbean>

  10. JBoss & PostgreSQL • JBoss also needs to see your JDBC driver • place it in /usr/local/jboss/lib/ext

  11. JBoss and mysql <mbean code="org.jboss.jdbc.JdbcProvider" name="DefaultDomain:service=JdbcProvider2"> <attribute name="Drivers">org.gjt.mm.mysql.Driver</attribute> </mbean> <mbean code="org.jboss.jdbc.XADataSourceLoader" name="DefaultDomain:service=XADataSource,name=mySQLDB"> <attribute name="DataSourceClass">org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl</attribute> <attribute name="PoolName">mySQLDS</attribute> <attribute name="URL">jdbc:mysql://localhost/test</attribute> </mbean>

More Related