• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to package ejbs

 
rastin purr
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I am new to Ejbs and need some help.
Is it possible to package ejbs just as we could package normal java classes? If so, how do we get the ejbs from the ear file?
For example, I have a stateless session bean called ejbbean.mybean.MySesBean. The session bean name is MySesBean located directory mybean which is located in directory ejbbean. I have a web component as well. Jar up the bean to BeanEjb.jar (got the xml file done as well) and jar up the web component (made up of jsps and servlets which is in web-inf/classes, got the xml file in web-inf as well). Then jar these two up into an ear file. I am not sure how to access the ejb from say for example the jsp.
Say for example, how am i going to import the ConHome (Home interface) and Con (remote interface)? Is it <%@ page import="Con" %> and <%@ page import="ConHome" %> or is it <%@ page import="ejbbean.mybean.Con" %> and <%@ page import="ejbbean.mybean.ConHome" %>? Do I need to change other things like classpath etc?
I have another question about InitialContext. Why do we need to add properties into InitialContext for example when using WebLogic but not when using J2sdkee1.3.1 RI? Please help me as I am confuse. Is it because web logic have thier own implementation of the context factory and uri? Is it not a standard defined by Sun? Will it work in Web logic if we omit the properties in initialContext?
Sorry for this long description. Thanks in advance for helping. Thanks a lot. Thanks Java Ranch Rangers as well for having such a woderfull site. Cheers!
Ras
 
Dave Landers
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am not sure how to access the ejb from say for example the jsp.
Say for example, how am i going to import the ConHome (Home interface) and Con (remote interface)? Is it <%@ page import="Con" %> and <%@ page import="ConHome" %> or is it <%@ page import="ejbbean.mybean.Con" %> and <%@ page import="ejbbean.mybean.ConHome" %>?

If the class is ejbbean.mybean.Con(Home), then that is what you should import. These <@page import'"xxx"%> things in jsp translate into regular java import statements.
Do I need to change other things like classpath etc?
Not if everything is packaged in the ear as you described.
I have another question about InitialContext. Why do we need to add properties into InitialContext for example when using WebLogic but not when using J2sdkee1.3.1 RI?
In WebLogic you used to need the properties (version 5.1 and before, I think) but you don't need them any more since WebLogic 6.0 - just do as the J2EE spec says: new InitialContext(). This assumes you are running code in the server (i.e. JSP and EJB).
If you are connecting to the server remotely (say from another java program) then you do need the initial context factory and provider url and maybe username/password so your java program knows how to talk to the WLS server.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!