Skip to main content

What is UnitOfWork ?

3 replies [Last post]
bjb
Offline
Joined: 2003-06-12

Dear all,

Anybody go an idea about what is UnitOfWork ? and what could "set" this in order for me not to get the following NPE ? A glance at the source code did not help much ...

Error Rendering View java.lang.NullPointerException at oracle.toplink.essentials.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:217)
at oracle.toplink.essentials.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:82)
at oracle.toplink.essentials.indirection.IndirectList.buildDelegate(IndirectList.java:193)
at oracle.toplink.essentials.indirection.IndirectList.getDelegate(IndirectList.java:315)
at oracle.toplink.essentials.indirection.IndirectList.size(IndirectList.java:640)
at javax.faces.model.ListDataModel.isRowAvailable(Unknown Source)
at javax.faces.model.ListDataModel.setRowIndex(Unknown Source)
at javax.faces.model.ListDataModel.setWrappedData(Unknown Source)
at javax.faces.model.ListDataModel.(Unknown Source)
at javax.faces.component.UIData.getDataModel(Unknown Source)
at javax.faces.component.UIData.setRowIndex(Unknown Source)
at com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(Unknown Source)
at javax.faces.component.UIComponentBase.encodeBegin(Unknown Source)
at javax.faces.component.UIData.encodeBegin(Unknown Source)
at javax.faces.component.UIComponentBase.encodeAll(Unknown Source)
at javax.faces.render.Renderer.encodeChildren(Unknown Source)
at javax.faces.component.UIComponentBase.encodeChildren(Unknown Source)
at javax.faces.component.UIComponentBase.encodeAll(Unknown Source)
at javax.faces.component.UIComponentBase.encodeAll(Unknown Source)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:455)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(Unknown Source)
at com.sun.faces.lifecycle.LifecycleImpl.phase(Unknown Source)
at com.sun.faces.lifecycle.LifecycleImpl.render(Unknown Source)
at javax.faces.webapp.FacesServlet.service(Unknown Source)
at sun.reflect.GeneratedMethodAccessor162.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:262)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:295)
at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:178)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:390)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:181)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:223)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:662)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:569)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)
at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:345)
at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:237)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:240)
at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)

Best Regards,
JB

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ss141213
Offline
Joined: 2005-03-30

Looks like you are accessing some persistence aware collection in an environment which does not know how to process the collection properly.

Is it something like this: your web application got an entity bean from a remote method call and you are getting that exception while using the bean?

If so, it looks similar to an issue discussed here:
http://forums.java.net/jive/thread.jspa?threadID=2595

You may like to file a bug.

-- Sahoo

bjb
Offline
Joined: 2003-06-12

Thanks Sahoo for the links.

You are right this is an issue related to detaching.
I realy tought that all traversed relationship are automatically detached with the master entity on serialization as soon as you "get" the relationship traversal property.

But reading more deeply the spec, I noticed that you must acces a field of the/all targeted entity(ies) that is not an @Id for this to happen.

That is what I did, so now I got some buch of "detaching workaround" code inside my service that just traverse what I need on the remote side and the serialization will just work as expected :)

For me this is not a bug, but more like an enhancement required, there should be a configurable way for an method to define what the EJB will keep from the PM context as soon as it crosses the PM "persistence border". Or maybe that having some bunch of "detaching code" is enough ?!

Not sure I should submit an issue on EJB3 as this is apparently a known issue of the spec ...

Rgs,
JB

ss141213
Offline
Joined: 2005-03-30

Glad you now know why you are seeing that exception.

With regards to whether the current behavior is a bug or not, I know it's a spec issue, but I certainly don't like the current spec on this one. It is expecting too much from users. [b]The goal of "ease of use" is not being met[/b].

Sahoo