Topic
  • 5 replies
  • Latest Post - ‏2013-07-22T21:42:35Z by Mavenizer
BillKoch
BillKoch
3 Posts

Pinned topic m2eclipse and RAD 7.5.5 - Duplicate jars on classpath at runtime

‏2010-06-30T02:38:40Z |
I'm attempting to use m2eclipse 0.10.0 with RAD 7.5.5 for a simple web application. Using WebSphere's Class Loader Viewer, I've noticed that duplicate versions of my jar dependencies are on the classpath: one comes from m2eclipse that points to my local Maven repository, the other is copied into the .metadata/.plugins/org.eclipse.wst.server.core/tmp0 folder (I've attached a screenshot of the Class Loader Viewer to this post for clarification).

My application also uses Struts2 which has logic to check for duplicate classes on the classpath, and because 2 copies of the Struts2 jars are on my classpath, Struts2 fails to initialize. Specifically, I get the following Exception from Struts2:


Caused by: Bean type 

class com.opensymphony.xwork2.ObjectFactory with the name xwork has already been loaded by bean - wsjar:file:/C:/workspace/rad75/playground/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/struts2-example-web/WEB-INF/lib/struts2-core-2.1.6.jar!/struts-default.xml:29:72 - bean - wsjar:file:/C:/maven2/.m2/repository/org/apache/struts/struts2-core/2.1.6/struts2-core-2.1.6.jar!/struts-default.xml:29:72


I've tried tweaking the Java EE Module Dependencies (under my web project) so that the Web Libraries tab doesn't have the Maven Dependencies library checked. However, after doing this, my dependencies don't show up at all (not in .metadata/.plugins/org.eclipse.wst.server.core/tmp0 or as pointers to my local Maven repository).

Is there a way to prevent my dependencies from being copied into .metadata/.plugins/org.eclipse.wst.server.core/tmp0?

Thanks for your help.

Bill
Updated on 2010-09-03T15:25:05Z at 2010-09-03T15:25:05Z by lukman
  • BillKoch
    BillKoch
    3 Posts

    Re: m2eclipse and RAD 7.5.5 - Duplicate jars on classpath at runtime

    ‏2010-06-30T14:51:58Z  
    I have a potential work around for this issue: if I change WebSphere's publishing settings to "Run server with resources on Server", I no longer have duplicate jars on my classpath. The effect of this change is that RAD no longer uses WTP for publishing the application, but instead deploys the application into my WebSphere profile itself. Attached to this post is a screenshot of the settings change.

    While this approach works, it makes publishing more complex applications take quite a bit longer, which is validated by this IBM article: http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.ws.ast.st.v6.ui.doc/topics/tpublishv6.html

    I'd still like to find a way to take advantage of the faster publishing through WTP, if possible.
  • lukman
    lukman
    2 Posts

    Re: m2eclipse and RAD 7.5.5 - Duplicate jars on classpath at runtime

    ‏2010-09-01T17:37:06Z  
    hi Bill

    i got a similar problem to yours. I had to check the box Maven Dependencies in the dialog box in Java EE Module Dependencies in order to avoid the ClassNotFoundException exception when starting up the application.
    However, by checking that check box, it brings me to the problem you mention in your post, it looks like there is a library duplication.... i also tried your solution but it doesn't work....

    any ideas?
    Patria
  • BillKoch
    BillKoch
    3 Posts

    Re: m2eclipse and RAD 7.5.5 - Duplicate jars on classpath at runtime

    ‏2010-09-01T21:38:59Z  
    • lukman
    • ‏2010-09-01T17:37:06Z
    hi Bill

    i got a similar problem to yours. I had to check the box Maven Dependencies in the dialog box in Java EE Module Dependencies in order to avoid the ClassNotFoundException exception when starting up the application.
    However, by checking that check box, it brings me to the problem you mention in your post, it looks like there is a library duplication.... i also tried your solution but it doesn't work....

    any ideas?
    Patria
    Hi Patria,

    First, I apologize -- I should've listed the details of my WebSphere installation, since it could be something that only works for my version. I'm running WebSphere 6.1.0.21, with the web services feature pack. What version of WebSphere are you running?

    After changing the WebSphere setting to "Run server with resources on Server", what error message are you getting?
  • lukman
    lukman
    2 Posts

    Re: m2eclipse and RAD 7.5.5 - Duplicate jars on classpath at runtime

    ‏2010-09-03T15:25:05Z  
    • BillKoch
    • ‏2010-09-01T21:38:59Z
    Hi Patria,

    First, I apologize -- I should've listed the details of my WebSphere installation, since it could be something that only works for my version. I'm running WebSphere 6.1.0.21, with the web services feature pack. What version of WebSphere are you running?

    After changing the WebSphere setting to "Run server with resources on Server", what error message are you getting?
    hi Bill

    thanks for your reply and no need for apologies.
    I'm running Websphere 7.0.0, the test environment within RAD 7.5.5.
    and your solution is also working for that version.I tried it again yesterday and it works beautifully.
    don't know really the difference between the different ways of publishing applications and that's a homework of mine.
    thanks a lot for sharing your findings and time
    cheers
    Patria
  • Mavenizer
    Mavenizer
    3 Posts

    Re: m2eclipse and RAD 7.5.5 - Duplicate jars on classpath at runtime

    ‏2013-07-22T21:42:35Z  

    Hey ... i know this issue is kinda old, but right now i'm facing the same issue with struts2-core jars which are added twice to rad/was61.

    Once by the M2_REPO variable needed by maven, second time by the dependency itsself.

    Is there any other solution than running websphere in this mode? Cause our web-project has an upload directory right in the exploded "war" and when doing a clean on the server this upload directory disappears (quite logical), which is not handsome for developing. I just want to evaluate other possibilities than relinking our "upload" directory to an other folder...

    Any experiences? Could somebody help me? :-)

    Is there a possibility to say WAS that the upload folder within the exploded war shouldn't be touched or is protected?

    Cheers