ESB Service doesn't work on server (..DefaultDocument cannot be cast t

Four Stars

ESB Service doesn't work on server (..DefaultDocument cannot be cast t

I have deployed my first real world ESB Service to our production server. I can get the wsdl just fine, but calling the actual service doesn't work, instead I get the following error:
CurrentPriceListsOperation has thrown exception, unwinding now org.apache.cxf.interceptor.Fault: org.dom4j.tree.DefaultDocument cannot be cast to org.dom4j.Document
What could be causing this? Is there some way I could figure out what step in my job is causing the error?
Here's the full exception
14:08:26,261 | WARN | qtp26362458-39 | ache.cxf.common.logging.LogUtils 405 | - - | Application {http://www.talend.org/service/}CurrentPriceLists#{http://www.talend.org/service/}CurrentPriceListsOp... has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: org.dom4j.tree.DefaultDocument cannot be cast to org.dom4j.Document
at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162)
at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.createFault(AbstractJAXWSMethodInvoker.java:213)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128)
at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:178)
at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:64)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:75)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:211)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:193)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:129)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:187)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:110)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:166)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:547)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:480)
at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:70)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:941)
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:117)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:409)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:875)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:72)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
at org.eclipse.jetty.server.Server.handle(Server.java:349)
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:441)
at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:919)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:588)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: org.dom4j.tree.DefaultDocument cannot be cast to org.dom4j.Document
at mycompanyesb.currentpricelistsoperation_0_1.CurrentPriceListsOperation.tESBProviderRequest_1_LoopProcess(CurrentPriceListsOperation.java:1496)
at mycompanyesb.currentpricelistsoperation_0_1.CurrentPriceListsOperation.runJobInTOS(CurrentPriceListsOperation.java:3584)
at org.talend.esb.job.controller.internal.RuntimeESBProviderCallback.run(RuntimeESBProviderCallback.java:120)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
... 1 more
One Star

Re: ESB Service doesn't work on server (..DefaultDocument cannot be cast t

Hi,
what version of OS, Java, TOS and ESB do you use?
org.apache.cxf.interceptor.Fault: org.dom4j.tree.DefaultDocument cannot be cast to org.dom4j.Document

this looks more like redundant library or something similar..
 at mycompanyesb.currentpricelistsoperation_0_1.CurrentPriceListsOperation.runJobInTOS(CurrentPriceListsOperation.java:3584)

how did you deployed the service? are you sure you invoke the service on the server? (running on ESB)
regards
Gabriel
Four Stars

Re: ESB Service doesn't work on server (..DefaultDocument cannot be cast t

Here are the versions in use:
OS Version
Development : Windows 7 Enterprise SP1
Production : Windows Server 2008 R2 Datacenter

Java version
Development :
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)
Production :
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) 64-Bit Server VM (build 17.0-b17, mixed mode)

ESB Version
Development :
Talend Open Studio for ESB
Version: 5.1.1
Build id: r84309-20120530-0614
Production :
Talend ESB Standard Edition 5.1.1
I deployed the service by selecting export from TOS ESB, then copying the resulting .kar file to servers \mycompany-container\deploy folder. I can see from the logs that the service has been installed properly, but calling it results in the error.
I can run sayHello example from the same environment.
Employee

Re: ESB Service doesn't work on server (..DefaultDocument cannot be cast t

just to reduce possible sources of error and simplify, I would suggest trying it with the same version of JDK on production and dev.
You might also try a newer version of jdk 1.6. There was one minor version that had some problems. I know 1.6.0_25 and 1.6.0_30 worked fine.
Four Stars

Re: ESB Service doesn't work on server (..DefaultDocument cannot be cast t

I have production and development running the same java version now (1.6.0_31), but I still get the same error in production (development works fine).
What other steps could I take in order to resolve this problem?
Employee

Re: ESB Service doesn't work on server (..DefaultDocument cannot be cast t

When you say it is working fine in development, do you mean it works fine in Studio and you can deploy it to a runtime in development, or is that it works in Studio and not on the runtime. I'm thinking the latter. In that case I think it may be a missing or conflicting jar. I'd file a JIRA ticket and post the JIRA ticket here. If the data is not sensitive, and you export the route by right clicking and select Export Items and post it as an attachment on the JIRA I will take a look and see if I can replicate the error.
Four Stars

Re: ESB Service doesn't work on server (..DefaultDocument cannot be cast t

Yes, the service works on studio but not on runtime.
I copied the file dom4j-1.6.1.jar to my containers lib folder, and now the error message changed to org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory. So I quess the problem is related to java libraries, especially this dom4j thingie. I don't have any idea how to fix it though :\
Full exception:
org.apache.cxf.interceptor.Fault: org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162)
at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.createFault(AbstractJAXWSMethodInvoker.java:213)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128)
at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:178)
at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:64)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:75)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:211)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:193)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:129)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:187)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:110)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:166)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:547)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:480)
at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:70)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:941)
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:117)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:409)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:875)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:72)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
at org.eclipse.jetty.server.Server.handle(Server.java:349)
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:441)
at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:919)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:588)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
at org.talend.esb.job.controller.internal.GenericServiceProviderImpl.invoke(GenericServiceProviderImpl.java:110)
at org.talend.esb.job.controller.internal.GenericServiceProviderImpl.invoke(GenericServiceProviderImpl.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
... 44 more
Caused by: org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.dom4j.io.SAXReader.read(SAXReader.java:343)
at org.talend.esb.job.controller.internal.util.DOM4JMarshaller.sourceToDocument(DOM4JMarshaller.java:59)
at org.talend.esb.job.controller.internal.GenericServiceProviderImpl.invoke(GenericServiceProviderImpl.java:82)
... 51 more
Employee

Re: ESB Service doesn't work on server (..DefaultDocument cannot be cast t

Hi,
The problem is that Dom4J and required bundles are embedded in OSGi bundle and re-imported from outside. To fix this problem please contact Support.
If you don't have a Support subscription, then you can do following:
1. Raise a JIRA about it.
2. Make sure that Dom4J bundles are not imported into OSGi bundle.
In your case Dom4J is embedded because of tFileInputXML component, so you need to go to the
TOS_HOME/plugins/org.talend.designer.components.localprovider_5.1.1.rXXXXX/components/tFileInputXML
There edit file tFileInputXML_java.xml
You need to change this:
		<IMPORTS>
<IMPORT NAME="Java_DOM4J1.6" MODULE="dom4j-1.6.1.jar"
REQUIRED_IF="GENERATION_MODE == 'DOM4J'" />
<IMPORT NAME="Java_JAXEN1.1" MODULE="jaxen-1.1.1.jar"
REQUIRED_IF="GENERATION_MODE == 'DOM4J'" />
<IMPORT NAME="Java_xercesImpl" MODULE="xercesImpl.jar"
REQUIRED_IF="GENERATION_MODE == 'XERCES'" />
<IMPORT NAME="Java_talendSAX" MODULE="TalendSAX.jar"
REQUIRED_IF="GENERATION_MODE == 'SAX'" />
</IMPORTS>

Into this:
		<IMPORTS>
<IMPORT NAME="Java_DOM4J1.6" MODULE="dom4j-1.6.1.jar"
BundleID="org.apache.servicemix.bundles.dom4j"
REQUIRED_IF="GENERATION_MODE == 'DOM4J'" />
<IMPORT NAME="Java_JAXEN1.1" MODULE="jaxen-1.1.1.jar"
BundleID="org.apache.servicemix.bundles.dom4j"
REQUIRED_IF="GENERATION_MODE == 'DOM4J'" />
<IMPORT NAME="Java_xercesImpl" MODULE="xercesImpl.jar"
BundleID=""
REQUIRED_IF="GENERATION_MODE == 'XERCES'" />
<IMPORT NAME="Java_talendSAX" MODULE="TalendSAX.jar"
BundleID=""
REQUIRED_IF="GENERATION_MODE == 'SAX'" />
</IMPORTS>

Note the new BundleID attributes.
After that you need to make sure code generator re-indexed Java files (better do this modification on the fresh Studio before it's first start). After that your exported OSGi bundle will no longer contain Dom4J JAR files.
Renat
One Star

Re: ESB Service doesn't work on server (..DefaultDocument cannot be cast t

I faced the problem, where I created talend esb service in open studio.
To consume this service I created a client in route which will accept input from activemq.
There it was working in talend open studio, but when i deployed it in talend esb runtime I was getting faults like
org.apache.cxf.interceptor.Fault: Provider net.sf.saxon.TransformerFactoryImpl not found
org.apache.cxf.interceptor.Fault: Could not initialize class org.talend.esb.job.controller.internal.util.DOM4JMarshaller
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.talend.esb.job.controller.internal.util.DOM4JMarshaller

Also wsdl url in browser was generating 500 error in browser.
But when I copied saxon9.jar and saxon9-dom.jar in talend - karaf - libs folder, it was working fine. Also generating proper wsdl in browser.
One Star

Re: ESB Service doesn't work on server (..DefaultDocument cannot be cast t

I have a similar issue,
Both the jars are in the bundle, and the issue is intermittent, sometimes I see no errors, and sometimes I see this error. I suspect the server start up sometimes loads the jars, and sometimes does not.
For now, I have used the suggestion above and have placed both the libraries in the karaf lib, and problems has disappeared.
I think this is a defect which needs to be addressed. I am using version 5.3.1.

http://www.talend.org/service/}ProcessMessage has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Provider net.sf.saxon.TransformerFactoryImpl not found
at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162)
at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.createFault(AbstractJAXWSMethodInvoker.java:213)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128)
at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:178)
at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:68)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:75)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:107)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:203)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:243)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:163)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:219)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Employee

Re: ESB Service doesn't work on server (..DefaultDocument cannot be cast t

Hi,
This thread is from August 2012. Will you please create another one to address your specific issue?

Kind Regards,
Ben