On Mar 19, 2009, at 9:03 AM, Jean-Louis MONTEIRO wrote:
giovacar wrote:
when i try to call it on tomcat using openejb.war
(i copy my bean.jar on lib directory on
apache-tomcat-6.0.18\webapps\openejb\lib)
Sorry but I did not fully read your post.
When you use OpenEJB embedded in Tomcat, it seems to me a little
strange to
deploy your ejb jar in the OpenEJB distribution.
I would be better to package your ejb jar with its dependencies in a
war
file and to deploy the target war in the webapp directory ?
I agree with this suggestion. The EJBs deployed in webapps are usable
remotely with no extra configuration required. There is no difference
in deploying the ejbs in a plain ejb jar vs in an ear vs in a
collapsed ear (i.e. a webapp). All will be accessible by remote
clients if they have remote interfaces. Putting the ejbs in a war
file with all dependencies is the easiest way to go, no servlets
required to get the benefit of the simpler packaging model.
Here's how the client would look when accessing EJBs deployed in any
form in Tomcat:
Properties p = new Properties();
p.put("java.naming.factory.initial",
"org.apache.openejb.client.RemoteInitialContextFactory");
p.put("java.naming.provider.url", "http://127.0.0.1:8080/openejb/
ejb");
// user and pass optional
p.put("java.naming.security.principal", "myuser");
p.put("java.naming.security.credentials", "mypass");
InitialContext ctx = new InitialContext(p);
MyBean myBean = (MyBean) ctx.lookup("MyBeanRemote");
- - - -
In regards to how you have things setup now. Looking at the log file
it seems like you are attempting to put jars with persistence units
(persistence.xml files) in the openejb/lib directory and then use them
from outside those jars.
We don't support independently deploying persistence units for
consumption by other applications. We do support the standard Java EE
requirement that the persistence units must be defined in the
application that intends to use them: in an ear for all modules in the
ear; in the ejb jar for a standalone ejb application; in the war for a
standalone web application.
Hope this helps!
-David