facebook

JSP Compile Problem [Closed]

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

    sjaved
    Member

    Hi,
    I am using MyEclipse 2.6.3. I have a statement like
    <%@ page import=”org.apache.log4j.Category” %>
    in my JSP. I get an error “The import org.apache.log4j cannot be
    resolved” when MyEclipse tries to automatically compile the JSP.
    I have included the log4j jar as an external jar in the web project. How can I get the JSP complier to resolve the import by including the log4j.jar in the compile path for the JSP ?

    thanks.

    #203553 Reply

    Scott Anderson
    Participant

    SJaved,

    Is the jar file in the WEB-INF/lib directory?

    #203577 Reply

    sjaved
    Member

    No it is not. Thanks for the response. I figured this out myself earlier. I guess all externally referenced jars have to be in the WEB-INF/lib directory
    I was just hoping that I did not need to do that since at run time JBOSS already has a log4j.jar that I can use and I do not want to duplicate jars at various places.
    Thanks for your help once again.

    #203578 Reply

    Riyad Kalla
    Member

    sjaved,
    This is a common problem and solved by simply adding an External JAR to your project’s build path. I develop for Tomcat and have this problem quite often with the servlet-api.jar, jsp-api.jar and common’s libraries that I need. Instead of copying them into my WEB-INF/lib, I’ll just link to them externally since I know they will be there when the app is deployed.

    Hope this helps.

    #203588 Reply

    sjaved
    Member

    Riyad,
    Adding the external jar to the project’s build path does not resolve the problem for classes imported from a JSP. For example, having
    log4j.jar in the build path causes compile problems in a JSP with a statement <%@ page import=”org.apache.log4j.Category” %> but works
    fine for import statements from Java code. Looks like the JSP compiler in myeclipse does not process the external jars the same way as the
    java compiler.

    #203592 Reply

    Riyad Kalla
    Member

    sjaved,
    Let me check with Scott on this as I believe that the two should behave the same (Java compiler and JSP compiler).

    #203593 Reply

    Riyad Kalla
    Member

    sjaved,
    I checked with Scott and he correctly pointed out that the JSP compiler is intended to behave this way. If it considered what was in your build path, then it would be very possible that you could setup your build path such that your project built fine, and as soon as you deployed it, it crashed.

    The JSP compiler is meant to key off of the lib dir because these are the only libs you will have access to when you deploy (sans any included with the application server you are using). And since its not possible to account for every app server’s included JARs or everyone’s configuration of each app server’s included jars, the best we can do is go off of the lib dir since we *know* at the least your webapp will have this directory to load with.

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: JSP Compile Problem [Closed]

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