Hi,

I understand there is an example on setting up BMP in Tomcat with OpenEJB,
is there an example on CMP? I am using mySQL as the database. I am not sure
how to do it; such as what to write in the Tomcat configuration files (or
if it is necessary?)

Trying out on my own, I setup the database and received the following
exception when i run a servlet that invokes a Container Mananged Bean.

java.rmi.RemoteException: The bean encountered a non-application
exception.; nested exception is:
      java.rmi.RemoteException: Attempt to create an entity bean
(DeploymentID="EmployeeBean") that can not be persisted.; nested exception
is:
      org.exolab.castor.jdo.ClassNotPersistenceCapableException: The class
org.acme.employee.EmployeeBean is not persistence capable: no mapping was
defined for the class
java.rmi.RemoteException: Attempt to create an entity bean (DeploymentID
="EmployeeBean") that can not be persisted.; nested exception is:
      org.exolab.castor.jdo.ClassNotPersistenceCapableException: The class
org.acme.employee.EmployeeBean is not persistence capable: no mapping was
defined for the class
org.exolab.castor.jdo.ClassNotPersistenceCapableException: The class
org.acme.employee.EmployeeBean is not persistence capable: no mapping was
defined for the class
      at
org.exolab.castor.jdo.engine.DatabaseImpl.create(DatabaseImpl.java:343)
      at
org.openejb.alt.containers.castor_cmp11.CastorCMP11_EntityContainer.createEJBObject(CastorCMP11_EntityContainer.java:821)
      at
org.openejb.alt.containers.castor_cmp11.CastorCMP11_EntityContainer.invoke(CastorCMP11_EntityContainer.java:521)
      at
org.openejb.core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:244)
      at org.openejb.core.ivm.EjbHomeProxyHandler.
_invoke(EjbHomeProxyHandler.java:160)
      at
org.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:308)
      at
org.openejb.util.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:89)
      at $Proxy16.create(Unknown Source)
      at EmployeeClientServlet.doGet(EmployeeClientServlet.java:60)


This is the servlet that i run :

import org.acme.employee.*;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.util.Properties;

import javax.servlet.http.*;
import javax.naming.*;
import java.io.PrintWriter;
import java.io.IOException;
import javax.servlet.ServletException;
public class EmployeeClientServlet extends HttpServlet
{

    String factory = "org.openejb.client.LocalInitialContextFactory";

    public void doGet(HttpServletRequest request, HttpServletResponse
response)
        throws IOException, ServletException
    {

         PrintWriter out = response.getWriter();
        response.setContentType("text/html");

      try{

      Properties env = new Properties();

      String jndiProvider
= "org.openejb.client.LocalInitialContextFactory";
      env.put( "java.naming.factory.initial", jndiProvider );
      env.put( "java.naming.provider.url", "localhost:8080" );
      env.put( "java.naming.security.principal", "root" );
      env.put( "java.naming.security.credentials", "admin" );
      Context ctx = new InitialContext( env );

      Object obj = ctx.lookup( "EmployeeBean" );
      obj = PortableRemoteObject.narrow( obj, EmployeeHome.class );
      EmployeeHome home = ( EmployeeHome ) obj;

      Employee empl_create = home.create( "David", "Owen",
            "OpenEJB-" + System.currentTimeMillis() + "@SF.net" );

      Integer primaryKey = ( Integer ) empl_create.getPrimaryKey();
      Employee empl_find = home.findByPrimaryKey( primaryKey );

        response.setContentType("text/html");

       //The part we've all been wainting for...
        out.println("<html>");
        out.println("<body>");
        out.println("<head>");
        out.println("<title>Hello World!</title>");
        out.println("</head>");
      out.println("<h1>"+ "Are the \"create\" and \"find\" users identical
? "+
            empl_create.isIdentical( empl_find ) +"</h1>");
        out.println("</body>");
        out.println("</html>");
    }
catch (Exception e){
      response.setContentType("text/plain");
      e.printStackTrace(out);
}

}
}

What could be the possible errors? Is there any configuration file(s) that
i have neglected to write? Could someone please help?

Thank you.

regards,
Sean


[This e-mail is confidential and may also be privileged. If you are not the
intended recipient, please delete it and notify us immediately; you should
not copy or use it for any purpose, nor disclose its contents to any other
person. Thank you.]




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
http://OpenEJB.sf.net
OpenEJB-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/openejb-user

Reply via email to