Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Deploy EJB on J2EE

 
Christine Li
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 977
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm also new to EJB.I think,try to use PortableRemoteObject.narrow().Thanks for
telling my error.
------------------
 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic