- This topic has 6 replies, 3 voices, and was last updated 20 years, 10 months ago by Riyad Kalla.
-
AuthorPosts
-
sjavedMemberHi,
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.
Scott AndersonParticipantSJaved,
Is the jar file in the WEB-INF/lib directory?
sjavedMemberNo 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.
Riyad KallaMembersjaved,
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.
sjavedMemberRiyad,
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.
Riyad KallaMembersjaved,
Let me check with Scott on this as I believe that the two should behave the same (Java compiler and JSP compiler).
Riyad KallaMembersjaved,
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.
-
AuthorPosts