users@glassfish.java.net

Exception [EclipseLink-6004] on Jersey layer (glassfish 3.0.1 b18) ejb 3.1

From: <glassfish_at_javadesktop.org>
Date: Sat, 15 May 2010 02:32:36 PDT

Hi,

I have some strange problem in war (ejb 3.1) application.
1. Environment:
Windows 7 64bit, jvm 1.6.0_20 Java HotSpot(TM) 64-Bit Server VM, Postgresql 8.4 (postgresql-8.4-701.jdbc4.jar), glassfish 3.0.1 b18 (but same situation on b12).

2. My application:
War ([ejb, jpa, web, weld]), stateless session beans (no interface view) are exported by jersey. I have also some system timers on servlets (where some filesystem operations are needed), and those
servlets are connecting to the database also (only read operations on User.class entity).

3. The problem scenario.

Client invokes for the fist time after deploy (or start of the server) rest method which invokes dependent bean (dao) which invokes entityManager.getReference(User.class, 1);
Dao returns entity (i have logs before dao.read(1) and after dao.read(1) so assume there is no exception during em.getReference(...), no exceptions during dao method. So the fragment of code is:
----------------------------------------------------------------
@GET
@Path("{itemid}")
@Override
public User read(@javax.ws.rs.PathParam("itemid") Long id) {
        logger.debug("before userDao.read(id)");
        User retval = dao.read(id);
        logger.debug("after userDao.read(id)");
    return retval;
}
----------------------------------------------------------------
then after return method and before client get results exception is thrown from the Jersey Servlet:
-----------------------------------------------------------------------------
[#|2010-05-15T10:50:43.584+0200|WARNING|glassfish3.0.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=27;_ThreadName=http-thread-pool-8080-(2);|StandardWrapperValve[Jersey Web Application]: PWC1406: Servlet.service() for servlet Jersey Web Application threw exception
Local Exception Stack:
Exception [EclipseLink-6004] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.QueryException
Exception Description: The object [user: 1], of class [class pl.freshbrain.domain.platform.User], with identity hashcode (System.identityHashCode()) [1 526 232 266],
is not from this UnitOfWork object space, but the parent session's. The object was never registered in this UnitOfWork,
but read from the parent session and related to an object registered in the UnitOfWork. Ensure that you are correctly
registering your objects. If you are still having problems, you can use the UnitOfWork.validateObjectSpace() method to
help debug where the error occurred. For more information, see the manual or FAQ.
Query: ReadObjectQuery(referenceClass=User sql="SELECT ID_USER, USERNAME, EMAIL, CREATESTAMP, PASSWORD, VERSION, UPDATESTAMP, CREATED_BY_USER_ID, organization_fk, UPDATED_BY_USER_ID FROM PLATFORM_USER WHERE (ID_USER = ?)")
        at org.eclipse.persistence.exceptions.QueryException.backupCloneIsOriginalFromParent(QueryException.java:253)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.getBackupClone(UnitOfWorkImpl.java:1948)
        at org.eclipse.persistence.descriptors.FetchGroupManager.writePartialIntoClones(FetchGroupManager.java:173)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerExistingObject(UnitOfWorkImpl.java:3899)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerExistingObject(UnitOfWorkImpl.java:3843)
        at org.eclipse.persistence.queries.ObjectBuildingQuery.registerIndividualResult(ObjectBuildingQuery.java:362)
        at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java:590)
        at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:551)
        at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:491)
        at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:443)
        at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:635)
        at org.eclipse.persistence.queries.ReadObjectQuery.registerResultInUnitOfWork(ReadObjectQuery.java:724)
        at org.eclipse.persistence.queries.ReadObjectQuery.executeObjectLevelReadQuery(ReadObjectQuery.java:438)
        at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:997)
        at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:675)
        at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:958)
        at org.eclipse.persistence.queries.ReadObjectQuery.execute(ReadObjectQuery.java:399)
        at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1021)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2857)
        at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1225)
        at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1207)
        at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1167)
        at org.eclipse.persistence.jpa.JpaHelper.loadUnfetchedObject(JpaHelper.java:191)
        at pl.freshbrain.domain.TrackedDomainModel._persistence_checkFetched(TrackedDomainModel.java)
        at pl.freshbrain.domain.TrackedDomainModel._persistence_getcreatedByUser(TrackedDomainModel.java)
        at pl.freshbrain.domain.TrackedDomainModel.getCreatedByUser(TrackedDomainModel.java:59)
        at pl.freshbrain.domain.TrackedDomainModel$JaxbAccessorM_getCreatedByUser_setCreatedByUser_pl_freshbrain_domain_platform_User.get(MethodAccessor_Ref.java:52)
        at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:127)
        at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:340)
        at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
        at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:334)
        at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:593)
        at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:324)
        at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
        at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:315)
        at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:244)
        at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:74)
        at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.writeTo(AbstractRootElementProvider.java:171)
        at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.writeTo(AbstractRootElementProvider.java:149)
        at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:289)
        at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1029)
        at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:941)
        at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:932)
        at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:384)
        at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:451)
        at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:632)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
        at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
        at java.lang.Thread.run(Thread.java:619)
|#]
-----------------------------------------------------------------------------
Some explanation:
pl.freshbrain.domain.TrackedDomainModel is mapped superclass of User.class (pl.freshbrain.domain.platform.User) which contains common shared fields (createdByUser which is relation to User.class with id: 1)
I do not understand how the explanation of this exception can help me further. I have no access to UnitOfWork.validateObjectSpace(),
since it is in some deeper internals of EJB container. Two additional information which may be important:
- i am using com.sun.appserv.security.ProgrammaticLogin by some servlets to do some batch jobs (they for sure read User of id: 1).
More important: if I invoke the method for the second time there is NO exception!!!, all processes ok.

I will appreciate any help because it is a stopper for me. Thanks in advance.
[Message sent by forum member 'jszczepankiewicz']

http://forums.java.net/jive/thread.jspa?messageID=469929