4 Replies Latest reply on Jul 16, 2003 7:07 PM by garmany

    InstantiationException during first access

    garmany

      I am using JBoss 3.2.1 on Windows NT.

      I recently attempted to rewrite one of my BMP beans as CMP2.0. I followed the examples and made the Bean class abstract. To keep things simple at first, I eliminated all finders (except findByPrimaryKey of course). My CMP entity bean is still jar'd with all my BMP beans.

      All appeared to go well during deployment, the schema was created (or confirmed to be created), I was able to get the localHome interface, but when I attempt to call findByPrimaryKey, I get an InstantiationException as shown below. Any idea what I am doing wrong?

      13:20:39,485 ERROR [LogInterceptor] TransactionRolledbackLocalException, causedBy:
      java.lang.InstantiationException
      at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:30)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
      at java.lang.Class.newInstance0(Class.java:306)
      at java.lang.Class.newInstance(Class.java:259)
      at org.jboss.ejb.plugins.jaws.JAWSPersistenceManager.createBeanClassInstance(JAWSPersistenceManager.java:165)
      at org.jboss.ejb.plugins.CMPPersistenceManager.createBeanClassInstance(CMPPersistenceManager.java:137)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createBeanClassInstance(CachedConnectionInterceptor.java:251)
      at org.jboss.ejb.EntityContainer.createBeanClassInstance(EntityContainer.java:226)
      at org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.java:146)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:79)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:61)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:28)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:88)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:74)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:92)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:120)
      at org.jboss.ejb.plugins.CleanShutdownInterceptor.invokeHome(CleanShutdownInterceptor.java:198)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
      at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:477)
      at org.jboss.ejb.Container.invoke(Container.java:694)
      at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.java:272)
      at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110)
      at $Proxy321.findByPrimaryKey(Unknown Source)
      at etc, etc

        • 1. Re: InstantiationException during first access
          raja05

          Do you hvae a Primary key class? If so, do you have an constructor with no args?

          • 2. Re: InstantiationException during first access
            garmany

            primary key class is java.lang.Long which does not have a no-args constructor. (But the code examples use java.lang.Integer which also doesn't have a no-args constructor)

            My complete ejb_jar.xml entry is:


            no description
            <display-name>Customer Entity Bean</display-name>
            <ejb-name>Customer</ejb-name>
            <local-home>com.colabranet.partnerflow.customer.CustomerHome</local-home>
            com.colabranet.partnerflow.customer.Customer
            <ejb-class>com.colabranet.partnerflow.customer.CustomerBean</ejb-class>
            <prim-key-class>java.lang.Long</prim-key-class>
            <persistence-type>Container</persistence-type>
            False
            <cmp-version>2.x</cmp-version>
            <abstract-schema-name>customerbeantable</abstract-schema-name>

            <cmp-field><field-name>customerIDPK</field-name></cmp-field>
            <!-- a bunch more cmp-fields go here containing app-specific stuff -->

            <primkey-field>customerIDPK</primkey-field>

            • 3. Re: InstantiationException during first access
              raja05

              Do u have a constructor for ur CMP Class? Post the code for that.

              • 4. Re: InstantiationException during first access
                garmany

                No, there is no constructor for the bean class. Do I need one?

                BTW I tried extending my abstract bean class and making it concrete (implemented the abstract setters and getters). It got past the InstantiationException but threw a FinderException because it couldn't locate the primary key.