Integrating with third party libraries/JARs may result inClassCastExceptionerrors forWstxEventFactory/XMLEventFactoryatruntime.

Integrating with third party libraries/JARs may result inClassCastExceptionerrors forWstxEventFactory/XMLEventFactoryatruntime.

book

Article ID: KB0093776

calendar_today

Updated On:

Products Versions
TIBCO ActiveMatrix BusinessWorks -
Not Applicable -

Description

Description:
Integrating with third party libraries/JARs may result in ClassCastException errors at runtime even when there are no issues at Design time. While testing in Studio, there may be no issues but when deploying the application to appnode there will be classnotfound issues at runtime.


Symptoms:
The following exception is seen in bwappnode.log.
+++

 ERROR [bwEngThread:In-Memory Process Worker-2] TIBCO-BW-PALETTE-JAVA-500001: While executing method [invoke] encountered exception [java.lang.reflect.InvocationTargetException] [null].-{ActivityName=JavaInvoke, ProcessName=MyProcess, ModuleName=xxx.xxx.module}
at com.tibco.bw.palette.java.runtime.JavaInvokeActivity.execute(JavaInvokeActivity.java:198)
at com.tibco.bw.core.runtime.bx.BWBxActivityBridgeImpl.eval(BWBxActivityBridgeImpl.java:773)
at com.tibco.bx.core.behaviors.activity.BxExtensionBehavior.doEval(BxExtensionBehavior.java:161)
at com.tibco.bx.core.behaviors.activity.BxActivityBaseBehavior.eval(BxActivityBaseBehavior.java:781)
at com.tibco.bx.core.behaviors.activity.BxActivityBaseBehavior.eval(BxActivityBaseBehavior.java:1)
at com.tibco.pvm.infra.api.impl.util.director.IpmEventDirectorBase.handleModelEvent(IpmEventDirectorBase.java:170)
at com.tibco.pvm.infra.api.impl.util.director.IpmEventDirectorBase.handleEvent(IpmEventDirectorBase.java:90)
.
.
. at com.tibco.pvm.im.rt.xm.util.work.ImxSTWorkRunnable.run(ImxSTWorkRunnable.java:62)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
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 com.tibco.bw.palette.java.runtime.JavaInvokeActivity.execute(JavaInvokeActivity.java:164)
... 13 more
Caused by: java.lang.ExceptionInInitializerError
at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:162)
.
.
.
at org.apache.poi.openxml4j.opc.OPCPackage.create(OPCPackage.java:338)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.newPackage(XSSFWorkbook.java:452)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:225)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:217)
at charter.bw.enterprise.webapi.statement.StatementsExcel.invoke(StatementsExcel.java:59)
... 18 more
Caused by: java.lang.ClassCastException: com.ctc.wstx.stax.WstxEventFactory cannot be cast to javax.xml.stream.XMLEventFactory
at javax.xml.stream.XMLEventFactory.newInstance(Unknown Source)
at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.<clinit>(PackagePropertiesMarshaller.java:41)
... 27 more

++++

Cause:
Issue with OSGi classloading.

Issue/Introduction

Integrating with third party libraries/JARs may result inClassCastExceptionerrors forWstxEventFactory/XMLEventFactoryatruntime.

Resolution

Add the missing package (javax.xml.stream.events) in the dependencies tab for the application module's Module Descriptor in Business Studio. However, this will result in following " java.lang.LinkageError"  error while running in Studio.



+++

12:16:02.700 ERROR [bwEngThread:In-Memory Process Worker-2] TIBCO-BW-PALETTE-JAVA-500001: While executing method [invoke] encountered exception [java.lang.reflect.InvocationTargetException] [null].-{ActivityName=JavaInvoke, ProcessName=MyProcess, ModuleName=xxx.xxx.module}
at com.tibco.bw.palette.java.runtime.JavaInvokeActivity.execute(JavaInvokeActivity.java:198)
at com.tibco.bw.core.runtime.bx.BWBxActivityBridgeImpl.eval(BWBxActivityBridgeImpl.java:773)
at com.tibco.bx.core.behaviors.activity.BxExtensionBehavior.doEval(BxExtensionBehavior.java:161)
at com.tibco.bx.core.behaviors.activity.BxActivityBaseBehavior.eval(BxActivityBaseBehavior.java:781)
at com.tibco.bx.core.behaviors.activity.BxActivityBaseBehavior.eval(BxActivityBaseBehavior.java:1)
at com.tibco.pvm.infra.api.impl.util.director.IpmEventDirectorBase.handleModelEvent(IpmEventDirectorBase.java:170)
at com.tibco.pvm.infra.api.impl.util.director.IpmEventDirectorBase.handleEvent(IpmEventDirectorBase.java:90)
at com.tibco.pvm.infra.support.work.impl.WorkItemAbstract.execute(WorkItemAbstract.java:140)
at com.tibco.pvm.im.rt.xm.util.work.ImxSTWorkRunnable.doWorkBlock(ImxSTWorkRunnable.java:170)
at com.tibco.pvm.infra.services.engine.impl.STWorkRunnable.run(STWorkRunnable.java:50)
at com.tibco.pvm.im.rt.xm.util.work.ImxSTWorkRunnable.run(ImxSTWorkRunnable.java:62)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
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 com.tibco.bw.palette.java.runtime.JavaInvokeActivity.execute(JavaInvokeActivity.java:164)
... 13 more
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) previously initiated loading for a different type with name "javax/xml/stream/events/Namespace"
at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.marshall(PackagePropertiesMarshaller.java:98)
at org.apache.poi.openxml4j.opc.internal.marshallers.ZipPackagePropertiesMarshaller.marshall(ZipPackagePropertiesMarshaller.java:52)
at org.apache.poi.openxml4j.opc.ZipPackage.saveImpl(ZipPackage.java:485)
at org.apache.poi.openxml4j.opc.OPCPackage.save(OPCPackage.java:1441)
at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:212)
at charter.bw.enterprise.webapi.statement.StatementsExcel.invoke(StatementsExcel.java:290)
... 18 more

++++


Add the" javax.xml.stream" package as well in the Dependencies tab for the application module's Module Descriptor in Business Studio as shown in the attached screenshot (Filename: depenstream.png). Recreate the EAR and re-deploy the application.


Attachments

Integrating with third party libraries/JARs may result inClassCastExceptionerrors forWstxEventFactory/XMLEventFactoryatruntime. get_app