facebook

Certain jars should be sequestered as "server jars" & shouldn't be in war files?

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #628519 Reply

    rickh
    Participant

    I built the project, exported the war file, and ran it successfully on several servers. But then I came to one where I got this error:

    javax.servlet.ServletException: java.lang.LinkageError: loader constraint violation: when resolving interface method “javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;” the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, org/apache/jsp/index_jsp, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type avax/el/ExpressionFactory; used in the signature
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:268)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    root cause
    java.lang.LinkageError: loader constraint violation: when resolving interface method “javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;” the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, org/apache/jsp/index_jsp, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type avax/el/ExpressionFactory; used in the signature
    org.apache.jsp.index_jsp._jspInit(index_jsp.java:22)
    org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
    org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:159)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    Apparently, the Tomcat installation itself has a class loader, and the one I am supplying conflicts with it. The solution is to remove my class loader jar from my war file, and rely on the one that Tomcat supplies on the target server. These are the jars I am using:

    rhedin@RSOWEB6415 MINGW64 ~/Workspaces/MyEclipse CI/DTAG/WebRoot/WEB-INF/lib
    $ ls -lh
    total 4.2M
    -rw-r–r– 1 rhedin 1049089 185K Feb 21 2008 commons-beanutils-1.7.jar
    -rw-r–r– 1 rhedin 1049089 558K Dec 14 2007 commons-collections.jar
    -rw-r–r– 1 rhedin 1049089 203K Apr 2 2018 commons-lang.jar
    -rw-r–r– 1 rhedin 1049089 60K Jun 11 2008 commons-logging-1.1.1.jar
    -rw-r–r– 1 rhedin 1049089 85K Sep 22 2008 ezmorph.jar
    -rw-r–r– 1 rhedin 1049089 705K Mar 24 2015 httpclient-4.4.1.jar
    -rw-r–r– 1 rhedin 1049089 315K Mar 14 2015 httpcore-4.4.1.jar
    -rw-r–r– 1 rhedin 1049089 772K Jan 21 2014 ifxjdbc.jar
    -rw-r–r– 1 rhedin 1049089 38K Mar 19 2018 javax.el-api-2.2.4.jar
    -rw-r–r– 1 rhedin 1049089 676K Dec 12 2017 javax.faces-api-2.2.jar
    -rw-r–r– 1 rhedin 1049089 156K Nov 22 2013 json-lib-2.4-jdk15.jar
    -rw-r–r– 1 rhedin 1049089 24K Sep 6 2016 json-simple-1.1.1.jar
    -rw-r–r– 1 rhedin 1049089 379K Jun 11 2009 mail.jar
    -rw-r–r– 1 rhedin 1049089 87K Oct 16 2012 servlet-api.jar

    rhedin@RSOWEB6415 MINGW64 ~/Workspaces/MyEclipse CI/DTAG/WebRoot/WEB-INF/lib
    $

    I’ve tried removed certain jar files, for example servlet-api.jar. That sounded to me like one Tomcat might supply. But once I took it out, the program wouldn’t run locally, on my Tomcat server mediated by MyEclipse.

    I suspect there’s some way to separate the files that have to be there for the application, from the files that have to be there for the container for the application. What is the way?

    #628523 Reply

    Brian Fernandes
    Moderator

    Rick,

    It’s not the classloader (there will be several classloaders around, that’s normal) but it’s part of the Java EE API that’s being provided twice.

    .. have different Class objects for the type avax/el/ExpressionFactory; used in the signature – the problem is the javax.el.ExpressionFactory class (and the JAR that’s supplying it). You should probably be removing the javax.el-api-2.2.4.jar from the WEB-INF/lib folder. If the project was created by MyEclipse, we do supply this library in a special container that isn’t deployed. From the screenshots you sent last week (I realize that’s another project) – you had a JavaEE 5.0 Generic Library container in the project which would have provided this class.

    Hope this helps.

    #628783 Reply

    rickh
    Participant

    (Finally fought off other projects.) Yes, I see that I can remove javax.el-api-2.2.4.jar from my build path. And I did. Yes, I see JavaEE 5.0 Generic Library in the other project. But I can’t seem to put a copy of it in my DTAG project. I believe the project was created by MyEclipse, but I may have mangled it since then.

    Are there steps that should work to associate a non-deploying container with a current project?

    #628798 Reply

    Brian Fernandes
    Moderator

    Rick,

    1) Right click the project and choose Properties.
    2) Then go to the Java Build Path page, and click the Add Library button.
    3) Choose MyEclipse Library and click Next.
    4) Choose JavaEE 5.0 Generic Library from the list and click Finish.

    This should add the library to your project.

    #628799 Reply

    rickh
    Participant

    Thank you. That worked marvelously.

    (Is there a spot in the documentation I should have read, to know that?)

    #628801 Reply

    Brian Fernandes
    Moderator

    Glad that worked!

    No, we don’t really cover this in documentation because if you create the Web project in MyEclipse, we’d have already added the right library to it. Even if you created a similar type of project in Eclipse or with Maven, and imported it we’d still be able to detect it and add the correct library. Looks like your project didn’t qualify for unknown reasons.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Certain jars should be sequestered as "server jars" & shouldn't be in war files?

You must be logged in to post in the forum log in