ejb looses information between find and load
tigger908 Apr 22, 2003 1:52 PMHi
Im currently writting a multi bean program, and have recenly moved development to JBoss from the Jdeveloper internal server due to a bug with returning collections of objects.
I have successfully deploied to jboss using the help avalible from oracle, however I have run into problems while running a test client.
The test client searches for a bean by primary key and finds it, however although this bean appears to be correctly found (the correct Id is reported back by debug statments) when the container attepts to load the bean an error occurs, debug statments once again reveal that the variable within the bean which has previouly been reported as correct is now null.
Between these two happenings is a call to the set enttiy contex method, Im wondering if this is the problem and if so how to solve it. While working on this I attempted to hard code the ejb load, this removed the original error but what appears to be an internal error remains.
Jboss version - 3.2.)RC4
OS - Linux (Red Hat 8.0)
// ejb load code
public void ejbLoad()
{
System.out.println("doing ejb load");
System.out.println("this bean is " + this.toString());
try
{
String findStatement=
"select LAST_NAME, INITIALS from DOCTOR where DOCTOR_ID=?";
PreparedStatement prep = con.prepareStatement(findStatement);
System.out.println("You are loading . . " + this.doctorId);
prep.setInt(1,(this.doctorId).intValue());
//prep.setInt(1,1);
ResultSet results = prep.executeQuery();
if(results.next()==true)
{
this.initials=results.getString(2);
this.lastName=results.getString(1);
results.close();
prep.close();
}
else
{
System.out.println("falied to load an ejb!");
results.close();
prep.close();
}
}
catch(Exception e)
{
//prep.close();
//results.close();
System.err.println("Failure of ejb Load");
e.printStackTrace();
}
}
// ejb find by primary key code
public DoctorPK ejbFindByPrimaryKey(DoctorPK primaryKey) throws FinderException
{
System.out.println("doing ejb find by primary key");
try
{
String findStatement=
"select INITIALS, LAST_NAME from DOCTOR where DOCTOR_ID=?";
PreparedStatement prep = con.prepareStatement(findStatement);
prep.setInt(1,(primaryKey.doctorId).intValue());
ResultSet results = prep.executeQuery();
if(results.next())
{
//got results
prep.close();
results.close();
System.out.println("Got some Results");
System.out.println("id is - " + primaryKey.doctorId);
this.doctorId= new Integer((primaryKey.doctorId).intValue());
System.out.println("doctor id set to " + this.doctorId);
return primaryKey;
}
else
{
//not got results
prep.close();
results.close();
System.out.println("Not got some Results");
return null;
//Error condition _ SQL should throw an error
//if the retults are not found.
}
}
catch(Exception e)
{
e.printStackTrace();
return null;
}
}
//test client code
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "localhost");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" );
Context ctx = new InitialContext(env);
DoctorHome doctorHome = (DoctorHome)ctx.lookup("Doctor");
Doctor doctor;
// Use one of the create() methods below to create a new instance
// doctor = doctorHome.create( int pid, java.lang.String initials, java.lang.String lastName );
doctor = doctorHome.findByPrimaryKey(new DoctorPK(new Integer(1)));
System.out.println(doctor.getLastName());
//Error as reported by jbuilder when the client is run
/usr/java/jdk1.3.1/bin/java -client -classpath /home/Tigger/jdevhome/mywork/Workspace2/Pod1/classes:/home/Tigger/javaLibs/mysql-connector-java-2.0.14-bin.jar:/home/Tigger/Applications/jdev/jdev/lib/jdev-rt.jar:/home/Tigger/Applications/jdev/jdk/jre/lib/ext/activation.jar:/home/Tigger/Applications/jdev/jdk/jre/lib/ext/jcert.jar:/home/Tigger/Applications/jdev/jdk/jre/lib/ext/jndi.jar:/home/Tigger/Applications/jdev/jdk/jre/lib/ext/jnet.jar:/home/Tigger/Applications/jdev/jdk/jre/lib/ext/jta.jar:/home/Tigger/Applications/jdev/jdk/jre/lib/ext/mail.jar:/home/Tigger/Applications/jdev/j2ee/home/ejb.jar:/home/Tigger/Applications/jdev/j2ee/home/jaxp.jar:/home/Tigger/Applications/jdev/j2ee/home/jdbc.jar:/home/Tigger/Applications/jdev/j2ee/home/jaas.jar:/home/Tigger/Applications/jdev/j2ee/home/jsse.jar:/home/Tigger/Applications/jdev/j2ee/home/oc4j.jar:/home/Tigger/Applications/jdev/lib/xmlparserv2.jar:/home/Tigger/Applications/jdev/lib/xmlcomp.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/concurrent.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/getopt.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/gnu-regexp.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jacorb.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jboss-client.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jboss-common-client.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jboss-iiop-client.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jboss-j2ee.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jboss-jaas.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jboss-jsr77-client.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jboss-net-client.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jboss-system-client.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jboss-transaction-client.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jbossall-client.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jbossha-client.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jbossjmx-ant.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jbossmq-client.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jbossmqha.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jbosssx-client.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jcert.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jmx-connector-client-factory.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jmx-ejb-connector-client.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jmx-invoker-adaptor-client.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jmx-rmi-connector-client.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jnet.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jnp-client.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/jsse.jar:/home/Tigger/Applications/jboss-3.2.0RC4/client/log4j.jar SamplepodPackage.DoctorClient1
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.ServerException: RuntimeException; nested exception is:
java.lang.IllegalStateException: removing bean lock and it has tx set!
java.rmi.ServerException: RuntimeException; nested exception is:
java.lang.IllegalStateException: removing bean lock and it has tx set!
java.lang.IllegalStateException: removing bean lock and it has tx set!
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:139)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:92)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:77)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:80)
at org.jboss.proxy.ejb.EntityInterceptor.invoke(EntityInterceptor.java:112)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:82)
at $Proxy1.getLastName(Unknown Source)
at SamplepodPackage.DoctorClient1.main(DoctorClient1.java:29)
Process exited with exit code 0.
//error from server - starting from deployment
18:45:39,595 INFO [MainDeployer] Starting deployment of package: file:/home/Tigger/Applications/jboss-3.2.0RC4/server/default/deploy/ejb1.jar
18:45:39,616 INFO [EJBDeployer] looking for nested deployments in : file:/home/Tigger/Applications/jboss-3.2.0RC4/server/default/deploy/ejb1.jar
18:45:39,830 INFO [EjbModule] Creating
18:45:39,836 INFO [EjbModule] Deploying Patient
18:45:39,846 INFO [EjbModule] Deploying Doctor
18:45:39,855 INFO [EjbModule] Deploying Practice
18:45:39,865 INFO [EjbModule] Deploying Assessment
18:45:39,874 INFO [EjbModule] Deploying Treatment
18:45:39,883 INFO [EjbModule] Deploying Problem
18:45:39,894 INFO [EjbModule] Deploying DiaryEntry
18:45:39,904 INFO [EjbModule] Deploying Condition
18:45:39,913 INFO [EjbModule] Deploying Medication
18:45:39,929 INFO [EjbModule] Deploying Account
18:45:39,942 INFO [EntityContainer] Creating
18:45:39,945 INFO [EntityInstancePool] Creating
18:45:39,945 INFO [EntityInstancePool] Created
18:45:39,950 INFO [EntityContainer] Created
18:45:39,953 INFO [EntityContainer] Creating
18:45:39,956 INFO [EntityInstancePool] Creating
18:45:39,957 INFO [EntityInstancePool] Created
18:45:39,959 INFO [EntityContainer] Created
18:45:39,961 INFO [EntityContainer] Creating
18:45:39,965 INFO [EntityInstancePool] Creating
18:45:39,965 INFO [EntityInstancePool] Created
18:45:39,968 INFO [EntityContainer] Created
18:45:39,970 INFO [EntityContainer] Creating
18:45:39,973 INFO [EntityInstancePool] Creating
18:45:39,973 INFO [EntityInstancePool] Created
18:45:39,976 INFO [EntityContainer] Created
18:45:39,979 INFO [EntityContainer] Creating
18:45:39,982 INFO [EntityInstancePool] Creating
18:45:39,982 INFO [EntityInstancePool] Created
18:45:39,985 INFO [EntityContainer] Created
18:45:39,987 INFO [EntityContainer] Creating
18:45:39,991 INFO [EntityInstancePool] Creating
18:45:39,991 INFO [EntityInstancePool] Created
18:45:39,994 INFO [EntityContainer] Created
18:45:39,996 INFO [EntityContainer] Creating
18:45:40,007 INFO [EntityInstancePool] Creating
18:45:40,008 INFO [EntityInstancePool] Created
18:45:40,011 INFO [EntityContainer] Created
18:45:40,013 INFO [EntityContainer] Creating
18:45:40,016 INFO [EntityInstancePool] Creating
18:45:40,017 INFO [EntityInstancePool] Created
18:45:40,019 INFO [EntityContainer] Created
18:45:40,022 INFO [EntityContainer] Creating
18:45:40,025 INFO [EntityInstancePool] Creating
18:45:40,025 INFO [EntityInstancePool] Created
18:45:40,028 INFO [EntityContainer] Created
18:45:40,030 INFO [EntityContainer] Creating
18:45:40,035 INFO [EntityInstancePool] Creating
18:45:40,035 INFO [EntityInstancePool] Created
18:45:40,038 INFO [EntityContainer] Created
18:45:40,039 INFO [EjbModule] Created
18:45:40,041 INFO [EjbModule] Starting
18:45:40,042 INFO [EntityContainer] Starting
18:45:40,098 INFO [EntityInstancePool] Starting
18:45:40,099 INFO [EntityInstancePool] Started
18:45:40,099 INFO [EntityContainer] Started
18:45:40,100 INFO [EntityContainer] Starting
18:45:40,111 INFO [EntityInstancePool] Starting
18:45:40,112 INFO [EntityInstancePool] Started
18:45:40,112 INFO [EntityContainer] Started
18:45:40,113 INFO [EntityContainer] Starting
18:45:40,124 INFO [EntityInstancePool] Starting
18:45:40,125 INFO [EntityInstancePool] Started
18:45:40,125 INFO [EntityContainer] Started
18:45:40,126 INFO [EntityContainer] Starting
18:45:40,137 INFO [EntityInstancePool] Starting
18:45:40,137 INFO [EntityInstancePool] Started
18:45:40,138 INFO [EntityContainer] Started
18:45:40,139 INFO [EntityContainer] Starting
18:45:40,150 INFO [EntityInstancePool] Starting
18:45:40,150 INFO [EntityInstancePool] Started
18:45:40,151 INFO [EntityContainer] Started
18:45:40,151 INFO [EntityContainer] Starting
18:45:40,165 INFO [EntityInstancePool] Starting
18:45:40,165 INFO [EntityInstancePool] Started
18:45:40,166 INFO [EntityContainer] Started
18:45:40,166 INFO [EntityContainer] Starting
18:45:40,178 INFO [EntityInstancePool] Starting
18:45:40,179 INFO [EntityInstancePool] Started
18:45:40,179 INFO [EntityContainer] Started
18:45:40,180 INFO [EntityContainer] Starting
18:45:40,191 INFO [EntityInstancePool] Starting
18:45:40,191 INFO [EntityInstancePool] Started
18:45:40,192 INFO [EntityContainer] Started
18:45:40,192 INFO [EntityContainer] Starting
18:45:40,208 INFO [EntityInstancePool] Starting
18:45:40,209 INFO [EntityInstancePool] Started
18:45:40,209 INFO [EntityContainer] Started
18:45:40,210 INFO [EntityContainer] Starting
18:45:40,222 INFO [EntityInstancePool] Starting
18:45:40,222 INFO [EntityInstancePool] Started
18:45:40,223 INFO [EntityContainer] Started
18:45:40,223 INFO [EjbModule] Started
18:45:40,245 INFO [MainDeployer] Deployed package: file:/home/Tigger/Applications/jboss-3.2.0RC4/server/default/deploy/ejb1.jar
18:47:23,348 INFO [STDOUT] doing set entity context
18:47:23,362 INFO [STDOUT] doing make connection
18:47:23,382 INFO [STDOUT] doing ejb find by primary key
18:47:23,396 INFO [STDOUT] Got some Results
18:47:23,396 INFO [STDOUT] id from input is 1
18:47:23,396 INFO [STDOUT] doctor id in bean set to 1
18:47:23,428 INFO [STDOUT] doing set entity context
18:47:23,446 INFO [STDOUT] doing make connection
18:47:23,463 INFO [STDOUT] doing ejb load
18:47:23,475 INFO [STDOUT] this bean is podPackage.impl.DoctorBean@1125a40
18:47:23,488 INFO [STDOUT] You are loading . . null
18:47:23,501 ERROR [STDERR] Failure of ejb Load
18:47:23,501 ERROR [STDERR] java.lang.NullPointerException
18:47:23,502 ERROR [STDERR] at podPackage.impl.DoctorBean.ejbLoad(DoctorBean.java:106)
18:47:23,502 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
18:47:23,502 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
18:47:23,502 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
18:47:23,502 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
18:47:23,502 ERROR [STDERR] at org.jboss.ejb.plugins.BMPPersistenceManager.loadEntity(BMPPersistenceManager.java:405)
18:47:23,502 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.loadEntity(CachedConnectionInterceptor.java:353)
18:47:23,503 ERROR [STDERR] at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:244)
18:47:23,503 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
18:47:23,503 ERROR [STDERR] at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:82)
18:47:23,503 ERROR [STDERR] at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:174)
18:47:23,503 ERROR [STDERR] at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
18:47:23,503 ERROR [STDERR] at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:53)
18:47:23,503 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
18:47:23,503 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
18:47:23,503 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
18:47:23,503 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:117)
18:47:23,504 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:198)
18:47:23,504 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
18:47:23,504 ERROR [STDERR] at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:483)
18:47:23,504 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:678)
18:47:23,504 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
18:47:23,504 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
18:47:23,504 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
18:47:23,504 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
18:47:23,504 ERROR [STDERR] at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
18:47:23,504 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
18:47:23,504 ERROR [STDERR] at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:358)
18:47:23,505 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor68.invoke(Unknown Source)
18:47:23,505 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
18:47:23,505 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
18:47:23,505 ERROR [STDERR] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
18:47:23,505 ERROR [STDERR] at sun.rmi.transport.Transport$1.run(Transport.java:148)
18:47:23,505 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
18:47:23,505 ERROR [STDERR] at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
18:47:23,505 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
18:47:23,505 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
18:47:23,529 ERROR [STDERR] at java.lang.Thread.run(Thread.java:536)
18:47:23,530 ERROR [BeanLock] removing bean lock and it has tx set! QPL bean=Doctor id=podPackage.DoctorPK@1 tx=TransactionImpl:XidImpl [FormatId=257, GlobalId=pigwidgeon//61, BranchQual=] synched=null timeout=5000 queue=[]
18:47:23,530 ERROR [LogInterceptor] RuntimeException:
java.lang.IllegalStateException: removing bean lock and it has tx set!
at org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock.removeRef(QueuedPessimisticEJBLock.java:430)
at org.jboss.ejb.BeanLockManager.removeLockRef(BeanLockManager.java:107) at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:106)
at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:53)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:117)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:198)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:483)
at org.jboss.ejb.Container.invoke(Container.java:678)
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.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:358)
at sun.reflect.GeneratedMethodAccessor68.invoke(Unknown Source)
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)
Hope this is enough informaiton,
Thanks for your time,
Glenn Jenkins
University of Glamorgan