views:

54

answers:

1

Hi, I am writing a JEE app with Java 6 and Glassfish. I use Drools rules engine in it and it works fine until I undeploy the application. When I do that I get this Exception over and over again. Restarting the app server is the only way to stop it. Of course that is unacceptable in productive environment...

Any Ideas? Is the META-INF/services/javax.xml.datatype.DatatypeFactory missing? According to jarfinder it is included in the rt.jar of the appserver... including it manually does not help either.

[#|2010-07-19T15:50:10.123+0200|WARNING|sun-appserver2.1|javax.enterprise.system.core.classloading|_ThreadID=24;_ThreadName=Thread-258;_RequestID=22a7d379-0813-4248-9095-3fba7f4cb95a;|LDR5206: EJBClassLoader EJBClassLoader : 
doneCalled = true
doneSnapshot = EJBClassLoader.done() called ON EJBClassLoader : 
urlSet = [URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/jaxp-api-1.3.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/mvel2-2.0.10.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/activation-1.1.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/stax-1.2.0.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/jms-1.1.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/commons-lang-2.4.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/joda-time-1.6.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/drools-compiler-5.0.1.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/commons-email-1.2.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/commons-beanutils-core-1.8.0.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/Mailforwarder-pojo-1.0.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/xml-apis-1.0.b2.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/commons-logging-1.1.1.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/janino-2.5.15.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/commons-digester-1.8.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/drools-api-5.0.1.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/commons-net-2.0.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/commons-lang-2.5.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/core-3.4.2.v_883_R34x.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/xpp3_min-1.1.4c.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/stax-api-1.0.1.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/commons-configuration-1.6.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/commons-collections-3.2.1.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/xstream-1.3.1.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/commons-beanutils-1.7.0.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/core-pojo-1.0.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/core-common-1.0.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/xml-writer-0.2.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/antlr-runtime-3.1.1.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/mail-1.4.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/activation.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/lib/drools-core-5.0.1.jar, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/applications/j2ee-apps/mailforwarder/Mailforwarder-ejbjar-1.0_jar/, URLEntry : file:/home/arne/env/runtime/glassfish/domains/domain1/generated/ejb/j2ee-apps/mailforwarder/]
doneCalled = false 
 Parent -> EJBClassLoader : 
urlSet = []
doneCalled = false 
 Parent -> java.net.URLClassLoader@898540


 AT Mon Jul 19 15:47:21 CEST 2010 
 BY :com.sun.enterprise.loader.EJBClassLoader.printStackTraceToString(EJBClassLoader.java:813)
com.sun.enterprise.loader.EJBClassLoader.done(EJBClassLoader.java:173)
com.sun.enterprise.server.AbstractLoader.done(AbstractLoader.java:355)
com.sun.enterprise.server.ApplicationLoader.unload(ApplicationLoader.java:268)
com.sun.enterprise.server.TomcatApplicationLoader.unload(TomcatApplicationLoader.java:218)
com.sun.enterprise.server.ExtendedApplicationLoader.unload(ExtendedApplicationLoader.java:263)
com.sun.enterprise.server.ApplicationManager.applicationUndeployed(ApplicationManager.java:525)
com.sun.enterprise.server.ApplicationManager.applicationUndeployed(ApplicationManager.java:703)
com.sun.enterprise.admin.event.AdminEventMulticaster.invokeApplicationDeployEventListener(AdminEventMulticaster.java:961)
com.sun.enterprise.admin.event.AdminEventMulticaster.handleApplicationDeployEvent(AdminEventMulticaster.java:943)
com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent(AdminEventMulticaster.java:467)
com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(AdminEventMulticaster.java:182)
com.sun.enterprise.admin.server.core.DeploymentNotificationHelper.multicastEvent(DeploymentNotificationHelper.java:308)
com.sun.enterprise.deployment.phasing.DeploymentServiceUtils.multicastEvent(DeploymentServiceUtils.java:231)
com.sun.enterprise.deployment.phasing.ServerDeploymentTarget.sendStopEvent(ServerDeploymentTarget.java:332)
com.sun.enterprise.deployment.phasing.ApplicationStopPhase.runPhase(ApplicationStopPhase.java:136)
com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:108)
com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:966)
com.sun.enterprise.deployment.phasing.PEDeploymentService.undeploy(PEDeploymentService.java:333)
com.sun.enterprise.deployment.phasing.PEDeploymentService.undeploy(PEDeploymentService.java:308)
com.sun.enterprise.admin.mbeans.ApplicationsConfigMBean.undeploy(ApplicationsConfigMBean.java:667)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:390)
com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:373)
com.sun.enterprise.admin.config.BaseConfigMBean.invoke(BaseConfigMBean.java:477)
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.sun.enterprise.admin.util.proxy.ProxyClass.invoke(ProxyClass.java:90)
$Proxy1.invoke(Unknown Source)
com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor.invoke(SunoneInterceptor.java:304)
com.sun.enterprise.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:170)
com.sun.enterprise.deployment.autodeploy.AutoDeployer.invokeUndeploymentService(AutoDeployer.java:903)
com.sun.enterprise.deployment.autodeploy.AutoDeployer.undeployJavaEEArchive(AutoDeployer.java:399)
com.sun.enterprise.deployment.autodeploy.AutoDeployer.undeployApplication(AutoDeployer.java:381)
com.sun.enterprise.deployment.autodeploy.AutoDeployer.undeployAll(AutoDeployer.java:315)
com.sun.enterprise.deployment.autodeploy.AutoDeployControllerImpl$AutoDeployTask.run(AutoDeployControllerImpl.java:375)
java.util.TimerThread.mainLoop(Timer.java:512)
java.util.TimerThread.run(Timer.java:462)
 Parent -> EJBClassLoader : 
urlSet = []
doneCalled = false 
 Parent -> java.net.URLClassLoader@898540

 was requested to find resource META-INF/services/javax.xml.datatype.DatatypeFactory after done was invoked from the following stack trace
java.lang.Throwable
        at com.sun.enterprise.loader.EJBClassLoader.findResource(EJBClassLoader.java:459)
        at java.lang.ClassLoader.getResource(ClassLoader.java:978)
        at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:1168)
        at com.sun.enterprise.loader.EJBClassLoader.getResourceAsStream(EJBClassLoader.java:796)
        at javax.xml.datatype.SecuritySupport$4.run(SecuritySupport.java:92)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.xml.datatype.SecuritySupport.getResourceAsStream(SecuritySupport.java:85)
        at javax.xml.datatype.FactoryFinder.findJarServiceProvider(FactoryFinder.java:250)
        at javax.xml.datatype.FactoryFinder.find(FactoryFinder.java:223)
        at javax.xml.datatype.DatatypeFactory.newInstance(DatatypeFactory.java:131)
        at com.thoughtworks.xstream.converters.extended.DurationConverter.<init>(DurationConverter.java:33)
        at sun.reflect.GeneratedConstructorAccessor70.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at com.thoughtworks.xstream.XStream.dynamicallyRegisterConverter(XStream.java:725)
        at com.thoughtworks.xstream.XStream.setupConverters(XStream.java:696)
        at com.thoughtworks.xstream.XStream.<init>(XStream.java:445)
        at com.thoughtworks.xstream.XStream.<init>(XStream.java:385)
        at com.thoughtworks.xstream.XStream.<init>(XStream.java:323)
        at org.drools.audit.WorkingMemoryFileLogger.writeToDisk(WorkingMemoryFileLogger.java:120)
        at org.drools.audit.ThreadedWorkingMemoryFileLogger.writeToDisk(ThreadedWorkingMemoryFileLogger.java:38)
        at org.drools.audit.ThreadedWorkingMemoryFileLogger$Writer.run(ThreadedWorkingMemoryFileLogger.java:50)
        at java.lang.Thread.run(Thread.java:619)
|#]
+1  A: 

The cause of the problem is that drools tries to continue to work (See org.drools.audit.WorkingMemoryFileLogger.writeToDisk()) while the application is trying to shut down.

The fix is to kill this thread (ThreadedWorkingMemoryFileLogger) before shutting down the app.

Aaron Digulla
Thanks for your answer, the exceptions are not endless any more but they are still thrown. I would like to remove them, too, so here is what I do:In the @PreDestroy Method of the MDB I call this cleanUp method of the pojo that uses the rules engine:<code>public void cleanUp() { // the ThreadedFileLogger decisionLogger.close(); // StatefulKnowledgeSession ksession.dispose(); ksession = null; // the KnowledgeBase kbase = null; }</code>I still get some of the above mentioned Exceptions, but they stop eventually. What can I do to avoid them completely?
Arne
Make sure that the loggers actually run before you close them. The exception shows that the XML parser is started (which tells me that the logger is trying to load its config).
Aaron Digulla
What I do to test this is putting some test facts into the rule engine. I delete the log before that and see a new log that shows the facts I just put in, so I think the logger is working. After that I undeploy the app and get those exceptions.
Arne
Sorry, my brain wasn't working yesterday. The stacktrace shows that no XML parser is loaded but that ThreadedWorkingMemoryFileLogger is trying to look up a service ("META-INF/services/javax.xml.datatype.DatatypeFactory") during shutdown. That tells me that the logger is still active. Did you stop the logger before shutdown? Did you wait for it to terminate with `Thread.join()`?
Aaron Digulla
I call the close() method on the logger, I can not join on the thread because it is encapsulated inside the logger. I call the close() method in the finalize() method of the pojo that uses it and I think it is too late. @PreDestroy would be earlier but that is called from the container during lifecycle management and I cannot say whether it is this or if the app is undeploying. What is the "normal" way to end a Drools app with this logger? What am I doing differently?
Arne
To clarify: A MDB references a pojo which references the Drools objects (knowledge base, logger, etc). The container creates more than one MDB, but all use the same pojo. I use Glassfish 2.1, JEE 5, JSE 6, Drools 5.0.
Arne
1. Don't use finalize(), especially not in an EJB environment. 2. You must find a way to synchronize the creation and destruction of your pojo with the app. I can't tell you how to do this from the top of my hat; I suggest to ask a question here.
Aaron Digulla
OK, thank you very much for your help.
Arne