Hi, been really snagged by this one, persists with latest SNAPSHOT build
apache-tomee-1.1.0-20120731.041118-79-plus.zip. I have it narrowed down to a
pretty small test case.



It appears the constructor to by @Stateless bean is called twice, once
successfully, the second time by LocalProxyBean. When called the second time
by LocalProxyBean, the Java reference "this" is null. A NullPointerException
occurs on "this" in the constructor. It is causing pretty bad
initializations failures. Here is the code sample:





@Stateless(name="mikeZZZ")
public class MikeFooBean
{

        public MikeFooBean()
        {
                super();
                
                System.err.println("!!!!! MikeFoo constr");
                
                try
                {
                        System.err.println("!!!!! MikeFoo constr this: " + 
this);
                        System.err.println("!!!!! MikeFoo constr: " + 
this.hashCode());
                }
                catch (Exception e)
                {
                        System.err.println("!!!!! MikeFoo constr E!! " + e);
                        e.printStackTrace();
                }
                
        }
        
}






The constructor is called once successfully, then again, and "this" is null.
See output excerpt below. 
The concat of + this causes the compiler to attempt to call .toString()
which calls throws a NullPointerException. Note that there is a complete set
of println statements output properly which include output from the bean
"this". Then, a duplicate set of println statements begins. The first one
outputs (which has no "this" reference). Then the second one throws a
NullPointerException when simply simply trying to concat "this" to a string
(hence, .toString() called).



This doesn't seem like it should be happening. All other references to
'this' in the class in any other method seem to work fine as far as my
research could determine. Thanks for any help. 






INFO: Auto-deploying ejb mikeZZZ: EjbDeployment(deployment-id=mikeZZZ)
INFO: Jndi(name=mikeZZZLocalBean) --> Ejb(deployment-id=mikeZZZ)
INFO:
Jndi(name=global/localhost/scs/mikeZZZ!com.scholastic.scs.ws.mikefoo.MikeFooBean)
--> Ejb(deployment-id=mikeZZZ)
INFO: Jndi(name=global/localhost/scs/mikeZZZ) --> Ejb(deployment-id=mikeZZZ)
INFO: Created Ejb(deployment-id=mikeZZZ, ejb-name=mikeZZZ,
container=scsStatlessContainer)

!!!!! MikeFoo constr
!!!!! MikeFoo constr this:
com.scholastic.scs.ws.mikefoo.MikeFooBean@4c2cffbe
!!!!! MikeFoo constr: 1278017470

INFO: Started Ejb(deployment-id=mikeZZZ, ejb-name=mikeZZZ,
container=scsStatlessContainer)
!!!!! MikeTest service const 2
!!!!! MikeFoo constr
!!!!! MikeFoo constr E!! java.lang.NullPointerException
java.lang.NullPointerException
        at
com.scholastic.scs.ws.mikefoo.MikeFooBean$LocalBeanProxy.toString(com/scholastic/scs/ws/mikefoo/MikeFooBean.java)
        at java.lang.String.valueOf(String.java:2902)
        at java.lang.StringBuilder.append(StringBuilder.java:128)
        at com.scholastic.scs.ws.mikefoo.MikeFooBean.(MikeFooBean.java:18)
        at
com.scholastic.scs.ws.mikefoo.MikeFooBean$LocalBeanProxy.(com/scholastic/scs/ws/mikefoo/MikeFooBean.java)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
        at
org.apache.openejb.util.proxy.LocalBeanProxyFactory.newProxyInstance(LocalBeanProxyFactory.java:36)
        at
org.apache.openejb.core.ivm.EjbHomeProxyHandler.createProxy(EjbHomeProxyHandler.java:138)
        at
org.apache.openejb.core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:289)
        at
org.apache.openejb.core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:174)
        at
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:284)
        at $Proxy64.create(Unknown Source)
        at
org.apache.openejb.core.ivm.naming.BusinessLocalBeanReference.getObject(BusinessLocalBeanReference.java:33)
        at
org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:174)

{...ETC}











--
View this message in context: 
http://openejb.979440.n4.nabble.com/this-is-null-in-constructor-of-Stateless-bean-when-called-second-time-by-LocalBeanProxy-tp4656606.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to