Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Jar Conflict between Server Library and User Library  RSS feed

 
murali jackson
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am working on a EAR Project which is used to process mail box and do further processing.
I am using mail-1.4.7 jar . I have tested my code by running it as a stand alone program. It worked without any issues.
After then I added the piece of code in my EAR project, then i started getting below exception when i try to connect to my Mail store.



I know for a fact that why this error is occuring. My EAR Project has WAS 6.1 server library and inside the server library we have one jar named j2ee.jar which also has outdated javamail API.
So while runtime instead of loading my mail-1.4.7 jar, the JVM is loading this server jar and as a result it throws the above error.
Unfortunately I cannot remove the WAS 6.1 library from class path as other components are dependent on it.

I tried adding my JAR to WAR - Libraries but it did not resolve the issue. Dont know how to proceed.
Please throw some light on it.

the statement in my Code where the exception is thrown for Reference .



Build path is below
Build Path

 
Paul Clapham
Sheriff
Posts: 22267
38
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's been years since I used Websphere (happily for me...) but I think I recall a checkbox somewhere, where you can tell Websphere to use the jars in your EAR file's classloader before looking in Websphere's classloader. As I say I don't remember where, but it would most likely be in the procedure where you install the EAR file into Websphere. Sorry to be so vague and unhelpful about that, but I think it's probably a solution to your problem.

You could also consider updating Websphere to a later version, so that you wouldn't have the problem caused by the outdated JavaMail jar. But having had to update Websphere myself in the past I can see why you might not rank that idea too highly.
 
Mikalai Zaikin
Ranch Hand
Posts: 3409
16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to use PARENT LAST option for classloader https://www.ibm.com/support/knowledgecenter/en/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/trun_classload_server.html
Also, would be good to have 1 classloader per app (option MULTIPLE CLASSLOADERS) https://www.ibm.com/support/knowledgecenter/en/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/trun_classload_server.html
 
Paul Clapham
Sheriff
Posts: 22267
38
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's the option I was thinking of. I'm sure it already existed in Websphere 6.1 which is apparently what Murali is using. (Surely by now that version isn't even supported by IBM any more?)
 
murali jackson
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul , Zaikin for the response !!!

I have changed the classloader settings as shown in the below image.
classloader
Now my functionality is working (email processing). But the program crashes in various other places showing java.lang.verify error.

I did not paste the code where it is failing because it is not just in one place, it is failing randomly in various places.

Stack Trace follows :

I think changing the classloader settings is having side effects to other parts of the program but not sure how to fix it.
Please advise. Unfortunately I cannot change anything on the server because server admin wont allow as other apps are hosted on the same server.
I have to fix my code in someway for this to work.



 
Mikalai Zaikin
Ranch Hand
Posts: 3409
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question has been answered here
Please use Google in future before asking...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!