Search code examples
eclipselibrarieswebsphere-libertycics

ClassCastException with ECIConnectionFactory running in Liberty


The problem - I am receiving the following message:

java.lang.ClassCastException: com.ibm.connector2.cics.ECIConnectionFactory incompatible with com.ibm.connector2.cics.ECIConnectionFactory

I am receiving it when trying to make the following statement:

eisDci = (ECIConnectionFactory)ctx.lookup(eisn);

The 'eisDci' has been defined previously: private static ECIConnectionFactory eisDci = null;

And the 'eisn' is the String with the name of the conection like 'eis/DCIXxxxECI'

These connection is defined in the Server.xml:

<connectionFactory id="DCIXxxxECI" jndiName="eis/DCIXxxxECI">
        <properties.cicseci ServerName="XXXX" TPNName="xx" connectionUrl="url" portNumber="2006"/>
</connectionFactory>

I understand that this is warning me that the cast is not possible. What I don't know is what I'm doing wrong. That must be comparing one version of the ECIConnectionFactory class with a different version of ECIConnectionFactory.

The server I'm working with is a Liberty, I'm going crazy, I can't figure out why Eclipse is comparing two different versions.

Similar problems I have searched for:

ClassCastException when casting to the same class

Waxwing's answer seems good, but I don't have access to make those changes, This connection is carried out by an external library.

First Thank you for your answer Ben Cox, in Liberty's server.xml (for LOCAL) I have declared the library:

<fileset caseSensitive="false" dir="C:\CICSECI"/>

And in the Liberty Runtime/Shared/resources I have cicseci.rar which I have declared in the server.xml as a resourceAdapter:

<resourceAdapter autoStart="true" id="cicseci" location="${shared.resource.dir}/cicseci.rar">
    <classloader apiTypeVisibility="spec, ibm-api, api, third-party"/>
</resourceAdapter>

I have checked the rest of the libraries that I am importing into the project, and so far I have not seen that I have the repeated library.


Solution

  • Already resolved

    I import global libraries from different directories of my computer, in two of them the libraries were repeated with different versions, the obsolete versions were renamed, but it doesn't matter, the system recognized them as .jar and loaded them, producing the conflict.

    I deleted the leftover libraries and it started working.

    You have helped me a lot, and for that, Thank you.