8 Replies Latest reply on Mar 30, 2002 1:56 PM by Dennis Muhlestein

    CMP 2.0 in JBoss 3.0

    Joe Rank Newbie

      I'm trying to deploy an entity bean with CMP 2.0 in JBoss 3.0.0alpha (which I downloaded this week). The following warnings show up when I deploy:

      [10:54:34,563,ContainerFactory]
      Bean : OrderEJB
      Section: 9.2.2
      Warning: The entity bean class must not be defined as abstract.

      [10:54:34,565,ContainerFactory]
      Bean : OrderEJB
      Section: 9.2.2
      Warning: The entity bean class must define a public constructor that takes no arguments.

      [10:54:34,568,ContainerFactory]
      Bean : OrderEJB
      Section: 9.4.7.1
      Warning: The primkey-field element must name a public field in the bean implementation class.

      (I saw the other post on this, but I am using JBoss 3.0.) The bean deploys, but when I try to access it with a session bean, I get an InstantiationException:

      [11:05:31,866,LogInterceptor] TransactionRolledbackException, causedBy:
      java.rmi.ServerException: Could not instantiate bean; nested exception is:
      java.lang.InstantiationException: net.trapdoor.webom.order.OrderBean
      java.lang.InstantiationException: net.trapdoor.webom.order.OrderBean
      at java.lang.Class.newInstance0(Native Method)
      at java.lang.Class.newInstance(Class.java:237)
      at org.jboss.ejb.plugins.CMPPersistenceManager.createBeanClassInstance(CMPPersistenceManager.java:155)
      at org.jboss.ejb.EntityContainer.createBeanClassInstance(EntityContainer.java:276)
      at org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.java:153)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:142)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:104)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:100)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:156)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:56)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:106)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:109)
      at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:441)
      at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invokeHome(BaseLocalContainerInvoker.java:255)
      at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker$HomeProxy.invoke(BaseLocalContainerInvoker.java:406)
      at $Proxy27.create(Unknown Source)
      at net.trapdoor.webom.WorkflowManagerBean.createOrder(Unknown Source)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:569)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:67)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:98)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:156)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:65)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:131)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166)
      at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:280)
      at org.jboss.ejb.Container.invoke(Container.java:528)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1555)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:411)
      at java.lang.reflect.Method.invoke(Native Method)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
      at sun.rmi.transport.Transport$1.run(Transport.java:152)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:148)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:465)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:706)
      at java.lang.Thread.run(Thread.java:484)

      The classes couldn't be much simpler:

      <CODE>
      ------------- Home ------------------
      package mypkg.order;

      import javax.ejb.*;

      public interface LocalOrderHome extends EJBLocalHome {
      public LocalOrder create(Integer oid) throws CreateException;
      public LocalOrder findByPrimaryKey(Integer key) throws FinderException;
      }

      ------------- Local ----------------package mypkg.order;

      import javax.ejb.*;

      public interface LocalOrder extends EJBLocalObject {
      public Integer getOrderId();
      }

      -------------- Bean ----------------
      package mypkg.order;
      import javax.ejb.*;

      public abstract class OrderBean implements EntityBean {
      private EntityContext context;

      public abstract Integer getOrderId();
      public abstract void setOrderId(Integer oid);

      public Integer ejbCreate(Integer oid) throws CreateException {
      setOrderId(oid);
      return null;
      }

      publid void ejbPostCreate(Integer oid) throws CreateException { }

      public void setEntityContext(EntityContext ec) {
      context = ec;
      }
      public void unsetEntityContext() {
      context = null;
      }

      public void ejbActivate() { }
      public void ejbPassivate() { }
      public void ejbLoad() { }
      public void ejbRemove() { }
      public void ejbStore() { }
      }
      </CODE>

      The deployment descriptor is as EJB 2.0 as I know how to make it:

      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise Java Beans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>

      <ejb-jar>
      <display-name>OrderJAR</display-name>
      <enterprise-beans>
      <entity>
      <display-name>OrderEJB</display-name>
      <ejb-name>OrderEJB</ejb-name>
      <local-home>mypkg.order.LocalOrderHome</local-home>
      <local>mypkg.order.LocalOrder</local>
      <ejb-class>mypkg.order.OrderBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      <reentrant>True</reentrant>
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>orderSchema</abstract-schema-name>
      <cmp-field>
      <field-name>orderId</field-name>
      </cmp-field>
      <primkey-field>orderId</primkey-field>
      <security-identity>
      <description></description>
      <use-caller-identity></use-caller-identity>
      </security-identity>
      </entity>
      </enterprise-beans>
      <assembly-descriptor>
      <method-permission>
      <unchecked />
      <method>
      <ejb-name>OrderEJB</ejb-name>
      <method-name>*</method-name>
      </method>
      </method-permission>
      <container-transaction>
      <method>
      <ejb-name>OrderEJB</ejb-name>
      <method-name>*</method-name>
      </method>
      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>


      Any help will score you some major karma, to be sure.

      -Joe