Encountered below strange ClassCastException when implementing RTC plain java libs on a WAS8.5 server.
[1/8/16 16:40:33:329 SGT] 000000ed RTCWorkItemHa E com.ibm.gpo.test.resources.RTCWorkItemHandler establishRTCClient java.lang.ClassCastException: com.ibm.wbit.al.config.impl.ALConfigPackageImpl incompatible with org.eclipse.emf.ecore.EPackage
at com.ibm.team.repository.common.internal.util.InternalTeamPlatform$1.handleExtensionAdded(InternalTeamPlatform.java:284)
at com.ibm.team.repository.common.util.ExtensionReader.internalReadElement(ExtensionReader.java:202)
at com.ibm.team.repository.common.util.ExtensionReader.readRegistry(ExtensionReader.java:350)
at com.ibm.team.repository.common.util.ExtensionReader.start(ExtensionReader.java:380)
at com.ibm.team.repository.common.util.ExtensionReader.earlyStart(ExtensionReader.java:127)
at com.ibm.team.repository.common.internal.util.InternalTeamPlatform.initializeGeneratedPackages(InternalTeamPlatform.java:317)
at com.ibm.team.repository.common.internal.util.InternalTeamPlatform.start(InternalTeamPlatform.java:108)
at com.ibm.team.repository.client.TeamPlatform.startup(TeamPlatform.java:50)
at com.ibm.gpo.test.utils.rtc.RTCClient.<init>(RTCClient.java:104)
at com.ibm.gpo.test.resources.RTCWorkItemHandler.establishRTCClient(RTCWorkItemHandler.java:133)
It seems to be a class loading issue. As the problematic code snippet is as below:
protected boolean handleExtensionAdded(IConfigurationElement element {
if(element.getName().equals("package"))
{
String packageURI = element.getAttribute("uri");
String className = element.getAttribute("class");
if(packageURI != null && className != null)
{
if(org.eclipse.emf.ecore.EPackage.Registry.INSTANCE.get(packageURI) != null)
return true;
EPackage ePackage = null;
try
{
Class javaClass = getClass().getClassLoader().loadClass(className);
Field field = javaClass.getField("eINSTANCE");
ePackage = (EPackage)field.get(null);
}
catch(ClassNotFoundException _ex) { }
catch(IllegalAccessException _ex) { }
catch(NoSuchFieldException _ex) { }
if(ePackage != null)
org.eclipse.emf.ecore.EPackage.Registry.INSTANCE.put(packageURI, ePackage);
}
}
return true;
}
The code can't be changed as it's part of the RTC jar. Can this be worked around in other ways?
Comments
Have you checked what's passed to the below two APIs?
The involved API should be from IBM Integration Designer. Does it ring a bell?The APIs were written locally and called through a simple REST client like postman. The code used to work properly on my local WAS server until I installed IBM Business Process Manager onto the server. Not sure any plug-ins added or properties changed by BPM could cause this issue.
<Removed duplicate comment entry>
<Removed duplicate comment entry>
Does the installation of IBM Business Process Manager require adding any shared library in the WAS server? Generally speaking, using the "parent last" class loading policy should give you better application isolation, but it still depends on how the application is designed.
No. The installation did not require any manual addition of new shared library to the WAS server. The class loading policy has been configured before as you suggested. I even tried to package all the RTC plain jars to a shared library and let my application reference it such that WAS server can refer to it using an isolated class loader. The approach didn't help either.
If you're still struggling with that, I suggest you contact Support, preferably WebSphere as that's a class loading issue.