• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP lookup of EJB fails  RSS feed

 
andy sb
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have a JSP which uses ctx.lookup("java:comp/env") to lookup an EJB which deploys without error but the lookup fails.
My question is, does the JSP have to be packaged in a WAR file INSIDE an EAR file for this to work? it is currently not packaged at all.
I am using Weblogic 6.1.
Thanks.
 
Rick Hightower
Author
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

My question is, does the JSP have to be packaged in a WAR file INSIDE an EAR file for this to work? it is currently not packaged at all.

No it does not have to be in an EAR file.
If you are using "java:comp" (the ENC for the web components), you also need a jndi link in you deployment descriptor. You could opt to skip java:comp and hit the jndi link directly.
 
andy sb
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Do you you have an example of this?
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will also need to package up the EJB stubs with your web app though, regardless of whether you use a WAR/EAR/etc, or atleast have them available through the classloading mechanism of your container.
Simon
 
John Carnell
Author
Ranch Foreman
Posts: 93
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andy,
I saw your post. You might want to consider wrappering your call to the EJB inside of business delegate pattern. If you ever want to change how the business service is being invoked (like moving from a EJB to a Web-Service) you are going to have to go through every piece of code that gets that EJB and change it.
Putting the EJB call inside of a business delegate will give you the flexibility to change how the service is invoked without exposing the applications consuming the service to the implementation details.
Thanks,
John
 
andy sb
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, that's a good idea to de-couple it.
Re: my problem, does anybody have an actual example I can look at?
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the actual exception that you are getting - NamingException, ClassNotFoundException, etc?
Simon
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this thread in the BEA/WebLogic forum for a link on how to define EJB references in your web.xml file.
Cheers
Simon
 
andy sb
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for that. Do you know of any conversion tools that map the Sun J2EE reference implementation deployment descriptors to BEA Weblogic, or from BEA to IBM Websphere?
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not off-hand, but have you seen what tools like XDoclet can do for you? Fantastic.
Simon
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!