geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aaron Mulder" <ammul...@alumni.princeton.edu>
Subject Re: Web App calling standalone EJB
Date Tue, 14 Mar 2006 14:01:59 GMT
Try adding this to your geronimo-web.xml (above the ejb-ref):

<import>RemoteOperationEJB</import>

That should add the EJB clases to the classpath of the web app.  (In
JBoss, it tends to put all apps on the same class loader, but Geronimo
doesn't work that way.)

Also, a couple of less important notes:

1) You may want to remove the parentId from your openejb-jar.xml --
it's not necessary to list the default one like you have, and it ties
you to Geronimo 1.0 since you have the "1.0" version string in there.

2) You don't actually need PortableRemoteObject.narrow unless you're
calling the remote EJB via CORBA, which you are not.  A simple cast
will work.  You won't be able to run this application under JDK 1.5
with Geronimo 1.0 if you continue to use PRO.narrow

Thanks,
    Aaron

On 3/14/06, Bruno Custodio - Datacomp DSCB <BCustodio@datacomp.pt> wrote:
>
> Hi there,
>
> I've recently installed Geronimo v1.0. I am still adapting, as i was using
> JBOSS previously.
>
> In JBOSS i had a Web application (.war) and a separate EJB named
> RemoteOperationEJB.jar. From the web application i was doing the lookup of
> the EJB with no problems, creating the object and calling its methods.
>
> Now in Geronimo i'm having problems to replicate the same scenario. I was
> able to deploy the EJB and the WAR files separately but when i try to run
> the web application and call the EJB i'm having a "NoClassDefFound"
> exception in the narrow!
>
> First of all, is this possible to do in Geronimo, having a web app calling a
> EJB that are NOT part of a EAR?
>
> If so, then i mostly sure have an error in the XML descriptors. Below i put
> each of them:
>
> EJB-JAR.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise
> JavaBeans 2.0//EN"
> "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
> <ejb-jar>
>    <enterprise-beans>
>       <session>
>          <ejb-name>RemoteOperationEJB</ejb-name>
>
> <home>com.datacomp.am.ejb.RemoteOperationHome</home>
>
>
> <remote>com.datacomp.am.ejb.RemoteOperation</remote>
>
> <local-home>com.datacomp.am.ejb.RemoteOperationLocalHome</local-home>
>
> <local>com.datacomp.am.ejb.RemoteOperationLocal</local>
>
> <ejb-class>com.datacomp.am.ejb.RemoteOperationBean</ejb-class>
>          <session-type>Stateless</session-type>
>          <transaction-type>Container</transaction-type>
>
>       </session>
>    </enterprise-beans>
> </ejb-jar>
>
> openejb-jar.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <openejb-jar
>     xmlns="http://www.openejb.org/xml/ns/openejb-jar"
>     configId="RemoteOperationEJB"
>     parentId="geronimo/j2ee-server/1.0/car">
>     <enterprise-beans>
>         <session>
>             <ejb-name>RemoteOperationEJB</ejb-name>
>             <jndi-name>ejb/RemoteOperationEJB</jndi-name>
>         </session>
>     </enterprise-beans>
> </openejb-jar>
>
> web.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
>   version="2.4">
>
>     <servlet>
>         <servlet-name>LoginServlet</servlet-name>
>         <servlet-class>com.datacomp.tp.LoginServlet</servlet-class>
>     </servlet>
>     <servlet-mapping>
>         <servlet-name>LoginServlet</servlet-name>
>         <url-pattern>/LoginServlet</url-pattern>
>     </servlet-mapping>
>     <session-config>
>         <session-timeout>30</session-timeout>
>     </session-config>
>
>     <ejb-ref>
>         <description>EJB Reference to the bean deployed to
> OpenEJB</description>
>        <ejb-ref-name>ejb/RemoteOperationEJB</ejb-ref-name>
>         <ejb-ref-type>Session</ejb-ref-type>
>
> <home>com.datacomp.am.ejb.RemoteOperationHome</home>
>
> <remote>com.datacomp.am.ejb.RemoteOperation</remote>
>     </ejb-ref>
> </web-app>
>
> geronimo-web.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app
>  xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.0"
> xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.0"
>  configId="TestPunch">
>  <naming:ejb-ref>
>   <naming:ref-name>ejb/RemoteOperationEJB</naming:ref-name>
>
> <naming:target-name>geronimo.server:J2EEModule=RemoteOperationEJB.jar,J2EEServer=geronimo,j2eeType=StatelessSessionBean,name=RemoteOperationEJB</naming:target-name>
>  </naming:ejb-ref>
> </web-app>
>
> In my JAVA code i'm doing the following:
>
>       //reference to the remote object
>       Object objref = null;
>       try {
>          //get initial context and lookup EJB
>          objref =
> ictx.lookup("java:comp/env/ejb/RemoteOperationEJB");
>       } catch (NamingException e) {
>          //some problem looking up the remote object
>          e.printStackTrace();
>          return null;
>       }
>       RemoteOperationHome home = (RemoteOperationHome)
> PortableRemoteObject.narrow(objref, RemoteOperationHome.class);
>       try  {
>          return home.create();
>       } catch (javax.ejb.CreateException ec)  {
>          ec.printStackTrace();
>       } catch (RemoteException re) {
>          re.printStackTrace();
>       }
>       return null;
>    }
>
> And it gives that exception in the narrow command!
>
>
> any possible help is welcome!
>
> thanks in advance,
>
> best regards,
> Bruno Custódio
>
>

Mime
View raw message