two packages in one jar file have the same class

1.1k views Asked by At

My app was using com.ibm.ws.Transaction.TransactionManagerFactory in websphere runtime 6.1 (com.ibm.ws.runtime_6.1.0.jar).

Now it needs to be migrated to websphere 8.5. But in the runtime 8.5 (com.ibm.ws.runtime.jar), TransactionManagerFactory is defined in two packages: com.ibm.tx.jta.TransactionManagerFactory and com.ibm.ws.Transaction.TransactionManagerFactory.

When the app is compiled, the compiler always seems to use the one in com.ibm.tx.jta, and shows the error:

cannot access com.ibm.tx.jta.TransactionManagerFactory [javac] class file for com.ibm.tx.jta.TransactionManagerFactory not found [javac] com.ibm.ws.Transaction.WebSphereTransactionManager tm = com.ibm.ws.Transaction.TransactionManagerFactory.getTransactionManager();

How can I make the compiler to use the right class? Does anyone have ideas on how to solve the problem?

Thanks in advance

2

There are 2 answers

0
Csaba Toth On

If this is a compile time error then you just need to fully qualify the class type, and spell out the type in full length. This way the compiler will no which one you want to use, and you won't have to guess either. You may need to adjust project dependencies too, hopefully that will yield a correct classpath and you won't have to poke around manually. Furthermore, use the one what your project depends on. I guess it's not Maven if it's a really old project.

0
Brett Kail On

com.ibm.ws.Transaction is not API, so you shouldn't be using it in the first place. WAS_HOME/dev/was_public.jar contains the public APIs for the product. Perhaps UOWManagerFactory or UOWSynchronizationRegistry would be better?