8 Replies Latest reply on Feb 7, 2003 5:33 PM by rcotton

    problem with setEntityContext in BMP EJB

      I have a simple bean managed entity bean. It has a single ejbFindByPrimaryKey method which takes a String as the pk.

      Anyway, I put a println statement in the setEntityContext method to see what was being passed in there, and it turns out that the parameter to that method is always 'null'

      In what cases will the EntityContext object passed into that method be null?

      I have another bean that does not exhibit this behavior. The only difference I can think of is that one of them gets called from within another EJB, while one gets called from within a JSP. (The one in the JSP is the one that passes null)

      Thanks for any heads up as to what is really going on.

      --Mark

        • 1. Re: problem with setEntityContext in BMP EJB
          rcotton

          I also have a null EntityContext but the bean is Container managed and is called from a session bean.

          My enviroment is: W2K, JBoss-3.0.4_Tomcat-4.1.12, XDoclet 1.2, Ant 1.5.

          I am getting WARNings in out.txt re jars ignored because they could not be opened, and improper ebj naming.

          I would appreciate any clues or direction offered!

          Thanks,
          Rick

          • 2. Re: problem with setEntityContext in BMP EJB
            jwin1

            Similar problems here.

            I think something is very wrong about JBoss's current state-of-affairs with BMP-EJB's (JBoss 3.0.4)

            The exact same BMP-EJB's (with the exact same DD's) worked as expected with J2EE SDK 1.3.1 and 14. beta !

            Would someone of the JBoss-Team please clarify this very important issue....?

            Regards,
            Joerg

            • 3. Re: problem with setEntityContext in BMP EJB

              Can you post the stack trace or a simple example.

              I don't see how you can get null for setEntityContext?

              Regards,
              Adrian

              • 4. Re: problem with setEntityContext in BMP EJB
                rcotton

                Thanks for your interest...

                Hope this helps...

                2nd attempt to reply...

                /**
                * Store the data within the provided data object into this bean.
                *
                * @param pPooler The Value Object containing the Pooler values
                *
                * @ejb:interface-method view-type="both"
                **/
                public void setValueObject( PoolerData pPooler )
                throws
                InvalidValueException
                {
                System.out.println("set valObj 1");
                // Check for Data Integrity in the Value Object
                if( pPooler == null ) {
                throw new InvalidValueException( "object.undefined", "Pooler" );
                }
                System.out.println("set valObj 2");
                if( pPooler.getId() <= 0 ) {
                throw new InvalidValueException( "pId.invalid", new String[] { "Pooler", "pId" } );
                }
                System.out.println("set valObj 3 " + mContext);
                // Check if the Pooler is not already saved
                try {
                LocalPoolerHome lHome = (LocalPoolerHome) mContext.getEJBLocalHome();
                System.out.println("set valObj 4");
                LocalPooler lEntity = lHome.findAnotherByName( pPooler.getId(), pPooler.getFirstName(), pPooler.getAccountName() );


                17:52:56,942 INFO [STDOUT] set valObj 3 null
                17:52:56,942 ERROR [LogInterceptor] TransactionRolledbackLocalException, causedBy:
                java.lang.NullPointerException
                at peopool.entity.PoolerBean.setValueObject(PoolerBean.java:296)
                at peopool.entity.PoolerBean.ejbCreate(PoolerBean.java:769)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:221)
                at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:270)
                at org.jboss.ejb.EntityContainer.createLocalHome(EntityContainer.java:580)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1119)
                at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:73)
                at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:206)
                at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:215)
                at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:73)
                at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:90)
                at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:79)
                at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:44)
                at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:111)
                at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
                at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:52)
                at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:105)
                at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:129)
                at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
                at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invokeHome(BaseLocalContainerInvoker.java:230)
                at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110)
                at $Proxy26.create(Unknown Source)
                at peopool.session.PeopoolSessionBean.getPoolers(PeopoolSessionBean.java:132)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at org.jboss.ejb.StatefulSessionContainer$ContainerInterceptor.invoke(StatefulSessionContainer.java:817)
                at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
                at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
                at org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invoke(StatefulSessionInstanceInterceptor.java:268)
                at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
                at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
                at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
                at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
                at org.jboss.ejb.StatefulSessionContainer.invoke(StatefulSessionContainer.java:380)
                at org.jboss.ejb.Container.invoke(Container.java:712)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
                at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:382)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
                at sun.rmi.transport.Transport$1.run(Transport.java:148)
                at java.security.AccessController.doPrivileged(Native Method)
                at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
                at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
                at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
                at java.lang.Thread.run(Thread.java:536)

                • 5. Re: problem with setEntityContext in BMP EJB
                  rcotton

                  3rd attempt at replying - trying this simple text as a test

                  • 6. Re: problem with setEntityContext in BMP EJB
                    rcotton

                    4th attempt to reply to warjort...

                    hope this helps...

                    /**
                    * Store the data within the provided data object into this bean.
                    *
                    * @param pPooler The Value Object containing the Pooler values
                    *
                    * @ejb:interface-method view-type="both"
                    **/
                    public void setValueObject( PoolerData pPooler )
                    throws
                    InvalidValueException
                    {
                    System.out.println("set valObj 1");
                    // Check for Data Integrity in the Value Object
                    if( pPooler == null ) {
                    throw new InvalidValueException( "object.undefined", "Pooler" );
                    }
                    System.out.println("set valObj 2");
                    if( pPooler.getId() <= 0 ) {
                    throw new InvalidValueException( "pId.invalid", new String[] { "Pooler", "pId" } );
                    }
                    System.out.println("set valObj 3 " + mContext);
                    // Check if the Pooler is not already saved
                    try {
                    LocalPoolerHome lHome = (LocalPoolerHome) mContext.getEJBLocalHome();
                    System.out.println("set valObj 4");
                    LocalPooler lEntity = lHome.findAnotherByName( pPooler.getId(), pPooler.getFirstName(), pPooler.getAccountName() );



                    17:52:56,942 INFO [STDOUT] set valObj 3 null
                    17:52:56,942 ERROR [LogInterceptor] TransactionRolledbackLocalException, causedBy:
                    java.lang.NullPointerException
                    at peopool.entity.PoolerBean.setValueObject(PoolerBean.java:296)
                    at peopool.entity.PoolerBean.ejbCreate(PoolerBean.java:769)
                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    at java.lang.reflect.Method.invoke(Method.java:324)
                    at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:221)
                    at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:270)
                    at org.jboss.ejb.EntityContainer.createLocalHome(EntityContainer.java:580)
                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    at java.lang.reflect.Method.invoke(Method.java:324)
                    at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1119)
                    at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:73)
                    at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:206)
                    at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:215)
                    at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:73)
                    at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:90)
                    at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:79)
                    at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:44)
                    at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:111)
                    at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
                    at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:52)
                    at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:105)
                    at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:129)
                    at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
                    at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invokeHome(BaseLocalContainerInvoker.java:230)
                    at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110)
                    at $Proxy26.create(Unknown Source)
                    at peopool.session.PeopoolSessionBean.getPoolers(PeopoolSessionBean.java:132)
                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    at java.lang.reflect.Method.invoke(Method.java:324)
                    at org.jboss.ejb.StatefulSessionContainer$ContainerInterceptor.invoke(StatefulSessionContainer.java:817)
                    at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
                    at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
                    at org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invoke(StatefulSessionInstanceInterceptor.java:268)
                    at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
                    at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
                    at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
                    at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
                    at org.jboss.ejb.StatefulSessionContainer.invoke(StatefulSessionContainer.java:380)
                    at org.jboss.ejb.Container.invoke(Container.java:712)
                    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
                    at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:382)
                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    at java.lang.reflect.Method.invoke(Method.java:324)
                    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
                    at sun.rmi.transport.Transport$1.run(Transport.java:148)
                    at java.security.AccessController.doPrivileged(Native Method)
                    at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
                    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
                    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
                    at java.lang.Thread.run(Thread.java:536)

                    • 7. Re: problem with setEntityContext in BMP EJB

                      Hi,

                      I meant can you post the stacktrace when
                      setEntityContext is invoked with null

                      public void setEntityContext(EntityContext ctx)
                      {
                      if (ctx == null)
                      throw new NullPointerException("null context");
                      this.ctx = ctx;
                      }

                      Regards,
                      Adrian

                      • 8. Re: problem with setEntityContext in BMP EJB
                        rcotton

                        Adrian,

                        Thank-you very much!

                        Your instructions pointed out that I had somehow managed to rename my "setEntityContext" method to "setContext". Once renamed correctly it worked fine.

                        Thanks again,
                        Rick