0 Replies Latest reply on Sep 26, 2014 9:47 AM by unas

    Jaxb (classloading?) issue with Camel application deployed on Wildfly

    unas

      Hello,

      I have a scenario, where I am running an Apache Camel (2.14.0) application deployed as .war on Wildfly 8.1. This by itself works great and without any problems.

      But now I want to monitor the camel application via JMX using the hawtio console. Hawtio is also deployed as war to the same Wildfly.

      When I try to get the routes printed as diagram, I get the following Exception:

       

      java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl

       

      The complete stacktrace :

      javax.management.RuntimeErrorException: Error occurred in RequiredModelMBean while trying to invoke operation dumpRoutesAsXml

      at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1289)

      at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:1085)

      at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)

      at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)

      at org.jboss.as.jmx.PluggableMBeanServerImpl$TcclMBeanServer.invoke(PluggableMBeanServerImpl.java:1456)

      at org.jboss.as.jmx.PluggableMBeanServerImpl.invoke(PluggableMBeanServerImpl.java:732)

      at org.jolokia.handler.ExecHandler.doHandleRequest(ExecHandler.java:98)

      at org.jolokia.handler.ExecHandler.doHandleRequest(ExecHandler.java:40)

      at org.jolokia.handler.JsonRequestHandler.handleRequest(JsonRequestHandler.java:89)

      at org.jolokia.backend.MBeanServerExecutorLocal.handleRequest(MBeanServerExecutorLocal.java:109)

      at org.jolokia.backend.MBeanServerHandler.dispatchRequest(MBeanServerHandler.java:102)

      at org.jolokia.backend.LocalRequestDispatcher.dispatchRequest(LocalRequestDispatcher.java:98)

      at org.jolokia.backend.BackendManager.callRequestDispatcher(BackendManager.java:410)

      at org.jolokia.backend.BackendManager.handleRequest(BackendManager.java:158)

      at org.jolokia.http.HttpRequestHandler.executeRequest(HttpRequestHandler.java:197)

      at org.jolokia.http.HttpRequestHandler.handlePostRequest(HttpRequestHandler.java:137)

      at org.jolokia.http.AgentServlet$3.handleRequest(AgentServlet.java:425)

      at org.jolokia.http.AgentServlet.handleSecurely(AgentServlet.java:320)

      at org.jolokia.http.AgentServlet.handle(AgentServlet.java:291)

      at org.jolokia.http.AgentServlet.doPost(AgentServlet.java:259)

      at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)

      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)

      at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)

      at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130)

      at io.hawt.web.RedirectFilter.process(RedirectFilter.java:73)

      at io.hawt.web.RedirectFilter.doFilter(RedirectFilter.java:38)

      at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)

      at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)

      at io.hawt.web.AuthenticationFilter.doFilter(AuthenticationFilter.java:111)

      at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)

      at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)

      at io.hawt.web.CORSFilter.doFilter(CORSFilter.java:42)

      at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)

      at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)

      at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85)

      at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)

      at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)

      at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)

      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)

      at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113)

      at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56)

      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)

      at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)

      at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61)

      at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)

      at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)

      at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)

      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)

      at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)

      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)

      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)

      at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240)

      at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)

      at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)

      at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)

      at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177)

      at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727)

      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

      at java.lang.Thread.run(Thread.java:744)

      Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl

      at com.sun.xml.bind.v2.model.impl.RuntimeTypeInfoSetImpl.(RuntimeTypeInfoSetImpl.java:65)

      at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:133)

      at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:85)

      at com.sun.xml.bind.v2.model.impl.ModelBuilder.(ModelBuilder.java:156)

      at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.(RuntimeModelBuilder.java:93)

      at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:450)

      at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:298)

      at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:141)

      at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1163)

      at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:145)

      at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:236)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

      at java.lang.reflect.Method.invoke(Method.java:483)

      at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:137)

      at javax.xml.bind.ContextFinder.find(ContextFinder.java:294)

      at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:412)

      at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:375)

      at org.apache.camel.model.ModelHelper.createJaxbContext(ModelHelper.java:95)

      at org.apache.camel.model.ModelHelper.dumpModelAsXml(ModelHelper.java:47)

      at org.apache.camel.management.mbean.ManagedCamelContext.dumpRoutesAsXml(ManagedCamelContext.java:339)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

      at java.lang.reflect.Method.invoke(Method.java:483)

      at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)

      at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

      at java.lang.reflect.Method.invoke(Method.java:483)

      at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)

      at javax.management.modelmbean.RequiredModelMBean$4.run(RequiredModelMBean.java:1252)

      at java.security.AccessController.doPrivileged(Native Method)

      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)

      at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1246)

      ... 59 more

       

      The code from Camel that causes the Exception looks like this:

       

      public static JAXBContext createJaxbContext() throws JAXBException {
           // must use classloader from CamelContext to have JAXB working
           return JAXBContext.newInstance(Constants.JAXB_CONTEXT_PACKAGES, CamelContext.class.getClassLoader());
      }
      

       

      Seems to me like it could be a classloading issue regarding the JAXB classes.

      I tried this with having the jaxb api and impl (v. 2.2.7), that are referenced by Camel, in my deployment and also without them. I always end up with this Exception.

       

      Does anyone have an idea, what exactly could be causing this problem and what I could try to do, to get around this ?

       

      Regards

      Hendrik