aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Need help to run chapter2-Manning Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Need help to run chapter2-Manning" Watch "Need help to run chapter2-Manning" New topic
Author

Need help to run chapter2-Manning

M Mirra
Greenhorn

Joined: Mar 29, 2011
Posts: 2
Hi,

I have difficulty running chapter 2 ( Manning 'EJB3 in action' ) in glassfish(glassfish-installer-v2-b58g).I am new to EJB
I did the following steps
1)Created 2 separate projects - 1)EJBProject 2)ClientProject in Eclipse
2)Ant script executes fine but hangs at deploy step(Guess not a problem since the jars are created)
3)Logged in to Glassfish admin console and deployed the chapter2.ear(which is created inside 'build' folder')
4)Created jms/QueueConnectionFactory and Destination-jms/OrderBillingQueue using the admin console
5)Also changed the datasource to 'jdbc/__default' in persistence.xml file.
6)When i try to run PlaceBidClient.java as JavaApploication(in Eclipse) it throws NullPointerexception in the line
System.out.println("Bid Successful, BidId Received is:" +placeBid.addBid(bid).getBidId());
(I found that the client should be run in ACC-Application client container) but not sure how to proceed
Please guide me in running the PlaceBidClient.java to view the output


Note: I also tried to deploy chapter2.ear under enterprise application in JBOSS(jboss-5.1.0.GA) console but deployment itself fails there

M Mirra
Greenhorn

Joined: Mar 29, 2011
Posts: 2
Hi,

I found that EJB client can be run in 2 ways
1)If it has to use DI,then it has to run inside ACC(aplication client container)
2)If it has to run as standalone java app,then DI cannot be used,and we have to go for JNDI lookup

So,i tried to follow 2nd approach and added the following lines in the main() method of PlaceBidClient
Properties props = new Properties();
props.load(new FileInputStream("jndi.properties"));
InitialContext ctx = new InitialContext(props);
PlaceBid placeBid = (PlaceBid) ctx.lookup("PlaceBidBean");

jndi.properties file

#Set required appropriate for your environment
java.naming.factory.initial = com.sun.enterprise.naming.SerialInitContextFactory
java.naming.factory.url.pkgs = com.sun.enterprise.naming
java.naming.factory.state = com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl
#optional. Defaults to localhost. Only needed if web server is running
#on a different host than the appserver
org.omg.CORBA.ORBInitialHost = localhost
#optional. Defaults to 3700. Only needed if target orb port is not 3700.
org.omg.CORBA.ORBInitialPort = 3700

I do not know how to configure jndi under Custom Resources in the glassfish admin console
What values must be supplied for 1)Resource Type and 2)Factory class
i have used JNDI Name - PlaceBidBean
Also,Do we need to change any config files

I get the below exception when i use 1)Resource Type - Stateless , 2)Factory Class - javax.naming.spi.ObjectFactory and run the standalone java program
java.lang.InstantiationException: javax.naming.spi.ObjectFactory
at java.lang.Class.newInstance0(Class.java:335)
at java.lang.Class.newInstance(Class.java:303)
at javax.naming.spi.NamingManager.getObjectFactoryFromReference(NamingManager.java:146)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:302)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:344)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at ejb.client.ejb3inaction.example.PlaceBidClient.main(PlaceBidClient.java:26)
javax.naming.CommunicationException: serial context communication ex [Root exception is java.lang.InstantiationException: javax.naming.spi.ObjectFactory]
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:368)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at ejb.client.ejb3inaction.example.PlaceBidClient.main(PlaceBidClient.java:26)
Caused by: java.lang.InstantiationException: javax.naming.spi.ObjectFactory
at java.lang.Class.newInstance0(Class.java:335)
at java.lang.Class.newInstance(Class.java:303)
at javax.naming.spi.NamingManager.getObjectFactoryFromReference(NamingManager.java:146)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:302)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:344)
... 2 more

Please help....

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help to run chapter2-Manning
 
Similar Threads
Why is eclipse deploying me ejb with my web project?
Cannot conect to mySql DB after changing DB from HSQL to mySql in JBOSS 5
Axis2 (1.5) - Use App Server's Admin console to deploy EAR, WAR, JAR|| Message service in Axis2
EJB3 deployment issue
How to replace Derby with MySQL Ant properties & CLASSPATH reference