aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Deploy EJB on J2EE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Deploy EJB on J2EE" Watch "Deploy EJB on J2EE" New topic
Author

Deploy EJB on J2EE

Christine Li
Greenhorn

Joined: Sep 25, 2001
Posts: 9
Pls help. I just started to use J2EE(1.2.1). I deployed 2 EJB beans on J2EE. I could run my test code (simple Java class) from command window. However, when I tried to test my servlet code which is deployed on J2EE as a Web application, I am getting error.
java.lang.ClassCastException: _EJBhome_stub
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
Could you pls post the fragment of code where you do the lookup and recover the jndi name and also where you recover the remote reference problably there�s something wrong there, and so it�s gonna be easy to help you.
regards.
Christine Li
Greenhorn

Joined: Sep 25, 2001
Posts: 9
Thank you very much for reply. Sure, I have a Java class which does the naming look up for every EJB. the looking up code is:
environment = new Hashtable(2);
environment.put(javax.naming.Context.PROVIDER_URL, providerURL);
environment.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
initialContextFactory);
ctx = new javax.naming.InitialContext(environment)
AgentHome AGENT = (AgentHome) ctx.lookup("milos/enactment/Agent");
The error is just in the lookup code. By the way, I use the "milos/enactment/Agent" as the coded name when I deployed the servlet file. In my simple Java class, it does the same lookup and it works fine.
Originally posted by Marcos Maia:
Could you pls post the fragment of code where you do the lookup and recover the jndi name and also where you recover the remote reference problably there�s something wrong there, and so it�s gonna be easy to help you.
regards.

Sam Wang
Ranch Hand

Joined: Jul 17, 2001
Posts: 95
I'm also new to EJB.I think,try to use PortableRemoteObject.narrow().Thanks for
telling my error.
------------------

SCJP(2001)
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
make sure you�ve deployed the ejb with the jndi name as:
milos/enactment/Agent
also as you�ve deployed the jsp as a war file you have to package the remote and home interfaces of the ejb with it, about the lookup a java casting should work(at least in WebLogic) as you know that you�re recovering a java type, and so you don�t need to use
<code>PortableRemoteObject.narrow();</code>

Christine Li
Greenhorn

Joined: Sep 25, 2001
Posts: 9
Hi, thanks a lot for all.
Finally, I made my deployed servlet work after i recompiled and deployed everything. it works now! However, I have another quetion. I hope someone can help. When I deployed servlet, do i have to creat an Alias name for it? if not, i can't find my servlet class. My question is how do i deploy more than one servlet classes for my Web application? Do i have to give each servlet class an alias name?
Regards

Originally posted by Marcos Maia:
make sure you�ve deployed the ejb with the jndi name as:
milos/enactment/Agent
also as you�ve deployed the jsp as a war file you have to package the remote and home interfaces of the ejb with it, about the lookup a java casting should work(at least in WebLogic) as you know that you�re recovering a java type, and so you don�t need to use
<code>PortableRemoteObject.narrow();</code>

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Deploy EJB on J2EE