-
1. Re: WELD-000019 Error destroying an instance
pmuir Jan 29, 2010 9:56 PM (in response to hallidave)No documentation yet, that is still in the works. You'll need to figure out how to get the exception out of GlassFish (it's logged at debug level, we need to add that to the message...)
-
2. Re: WELD-000019 Error destroying an instance
hallidave Jan 29, 2010 10:40 PM (in response to hallidave)Thanks for the reply. I set the logging to FINE on GlassFish and got the following stacktrace. Looks like it's being thrown from GlassFish code, not Weld. Maybe I need a @Disposes method to close the EntityManager that I injected?
java.lang.IllegalStateException at com.sun.enterprise.container.common.impl.EntityManagerWrapper.close(EntityManagerWrapper.java:826) 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:597) at org.jboss.weld.bean.builtin.CallableMethodHandler.invoke(CallableMethodHandler.java:46) at javax.persistence.EntityManager_$$_javassist_62.close(EntityManager_$$_javassist_62.java) at org.jboss.weld.bean.builtin.ee.PersistenceContextProducerField.defaultDispose(PersistenceContextProducerField.java:58) at org.jboss.weld.bean.builtin.ee.PersistenceContextProducerField.defaultDispose(PersistenceContextProducerField.java:29) at org.jboss.weld.bean.ProducerField$1.dispose(ProducerField.java:88) at org.jboss.weld.bean.ProducerField.destroy(ProducerField.java:113) at org.jboss.weld.context.ForwardingContextual.destroy(ForwardingContextual.java:18) at org.jboss.weld.context.DependentInstancesStore.destroy(DependentInstancesStore.java:79) at org.jboss.weld.context.DependentInstancesStore.destroyDependentInstances(DependentInstancesStore.java:73) at org.jboss.weld.context.CreationalContextImpl.release(CreationalContextImpl.java:79) at org.jboss.weld.bean.ManagedBean.destroy(ManagedBean.java:181) ...
-
3. Re: WELD-000019 Error destroying an instance
hallidave Jan 29, 2010 11:03 PM (in response to hallidave)The GlassFish code that gets called by Weld looks like this:
public void close() { Agent callFlowAgent = Switch.getSwitch().getCallFlowAgent(); if(callFlowAgent.isEnabled()) { callFlowAgent.entityManagerMethodStart(EntityManagerMethod.CLOSE); callFlowAgent.entityManagerMethodEnd(); } // close() not allowed on container-managed EMs. throw new IllegalStateException(); }
Seems like Weld should not be calling close() on the EntityManager? I added a
do nothing
@Disposes method and that suppresses the error.public class MyDatabase { @PersistenceContext(unitName = "myPU") private EntityManager em; @Produces public EntityManager getEm() { return em; } public void doNothing(@Disposes EntityManager em) { // don't call close } }
I'm still not clear if this a problem with how I'm using EntityManagers or if Weld is doing the wrong thing in this case. Any insight?
-
4. Re: WELD-000019 Error destroying an instance
pmuir Jan 30, 2010 8:13 PM (in response to hallidave)Yup, well known issue in 1.0.0, fixed in 1.0.1 which I just pushed to Maven, and hopefully GlassFish will pick up soon.