• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

HowTo: Advice Bean deployed on JBoss

 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following worked for me. Comments and corrections are welcome.
I assume that you have previously deployed the Advice application using the Reference Implementation (RI) of J2EE, and you have obtained a jar file AdviceAppClient.jar for the client application's use. Why? Because we are going to cheat a little to get hold of the ejb-jar.xml file which is the AdviceBean's deployment descriptor. I also assume that you have installed JBoss. I'm using 3.2.3 on Windows XP. I'm also assuming you have an environment variable JBOSS_HOME correctly set up.

Let's take a look at the directory structure:

Add a lib directory to this to get:

Into the lib directory copy jboss-j2ee.jar and jbossall-client.jar. These two jars are to be found in %JBOSS_HOME%\client. jboss-j2ee.jar is JBoss's version of j2ee.jar and jbossall-client.jar contains classes required by the client.

Copy the previously generated (by the RI deploytool) AdviceAppClient.jar file into HFEJBCODE\advice\classes and extract the file ejb-jar-ic.jar which contains the Advice bean:

Now extract the Advice Bean's ejb-jar.xml deployment description from ejb-jar-ic.jar:

Delete the two jars to destroy all evidence of cheating:

You should now have the following:

We must now compile all the classes. First the Advice bean's classes:

And the client:

The directory structure should now have the following contents:

We have to show JBoss how to set up JNDI for this bean. To do this create a file called
jboss.xml with the following contents:

Copy this file to the META-INF directory to get:

We are now ready to make a jar file and copy it to the jboss deployment directory:

Provided you have started it with:

you should now see JBoss automatically deploy the Advice bean.
To run the client we need one more file named jndi.properties containing:

Copy this file into the advice directory:

Finally we can run the client:

[ December 14, 2003: Message edited by: Barry Gaunt ]
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Barry,
This is good and nice tutorial for simple session bean but as for Entity bean,also have to include standardjbosscmp-jdbc.xml and also the driver jar file in order to access the database.
I'm using currently jboss 3.2.1 and jnet.jar is in my classpath but if i set only jboss-j2ee.jar,my client won't interact with the bean on the server.Hence I set couple of more jar file in my classpath. and now it's working fine.
There is one more thing regarding Jboss, right now I deployed my entity bean class and it is working fine with the database but that entity bean is CMP and it's not abstract class.So that is the violation of the EJB spec but it is working fine.
I also wrote abstract class for entity bean and I'm deploying it but it's throwing exception and warning during deployment such as


-3.2.1_tomcat-4.1.24/server/default/deploy/customer.jar
22:04:29,897 WARN [verifier] EJB spec violation:
Bean : CustomerBeanCMP
Section: 9.2.2
Warning: The entity bean class must not be defined as abstract.
22:04:29,907 WARN [verifier] EJB spec violation:
Bean : CustomerBeanCMP
Section: 9.4.7.1
Warning: The primkey-field element must name a public field in the bean implemen
tation class.
22:04:29,907 ERROR [MainDeployer] could not create deployment: file:/C:/jboss-3.
2.1_tomcat-4.1.24/server/default/deploy/customer.jar
org.jboss.deployment.DeploymentException: Verification of Enterprise Beans faile
d, see above for error messages.
at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:487)
..........so on


please put some shed on it if you know.
Regards,
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nauman, the point of the exercise is to get the first simple stateless session AdviceBean deployed on JBoss. As you said entity beans have to be deployed differently.
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Okay, I have tried this one out, however, I have found several errors:
1) In jboss.xml, under <enterprise-beans>, there is <entity>, however, it should be <session>
2) When you run the client: instead of using jboss-all.jar, use jbossall-client.jar
Overall, this is a great tutorial!!! I like it a lot. Thanks for concurring my request!!!
Thanks again,
John
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In case it helps. Here is the ejb-jar.xml that I needed to use to deploy successfully to jboss. Its in the book, but don't always have a 600 page book handy when hacking. :-)

<?xml version="1.0" ?>
<!DOCTYPE ejb-jar PUBLIC
'-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN'
'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
<ejb-jar>
<display-name>Ejb1</display-name>
<enterprise-beans>
<session>
<display-name>AdviceBean</display-name>
<ejb-name>AdviceBean</ejb-name>
<home>headfirst.AdviceHome</home>
<remote>headfirst.Advice</remote>
<ejb-class>headfirst.AdviceBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
<security-identity>
<description></description>
<use-caller-identity></use-caller-identity>
</security-identity>
</session>
</enterprise-beans>
</ejb-jar>
 
What I don't understand is how they changed the earth's orbit to fit the metric calendar. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic