aspose file tools*
The moose likes Servlets and the fly likes null pointer in _jspInit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "null pointer in _jspInit" Watch "null pointer in _jspInit" New topic
Author

null pointer in _jspInit

Kay Green
Greenhorn

Joined: Sep 24, 2008
Posts: 3
I am pulling my hair out.
I keep getting this null pointer Exception


for this code

WelcomeLoft.jsp

I have it as jsp because I am using jsp:include. I took that out to simplify the code

Here is the servlet created _jspInit and an * by the line where it throws the exception.

I have javax.servlet.jar in the lib directory of my web app and servler_api.jar in the lib directory of tomcat.

Here is the error message given in the console where tomcat is running

INFO: Reloading this Context has started
Sep 23, 2008 8:24:27 PM org.apache.catalina.loader.WebappClassLoader validateJar
File
INFO: validateJarFile(C:\apache-tomcat-6.0.18\webapps\Loft\WEB-INF\lib\javax.ser
vlet.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class
: javax/servlet/Servlet.class

Do you think that having javax.servlet.jar in my web app lib directory is causing this exception?

Here is Servlet Spec 2.3 section 9.7.2

SRV.9.7.2 Web Application Class Loader
The class loader that a container uses to load a servlet in a WAR must allow the
developer to load any resources contained in library JARs within the WAR
following normal J2SE semantics using getResource. As described in the Java EE
license agreement, servlet containers that are not part of a Java EEproduct should
not allow the application to override Java SE platform classes, such as those in the
java.* and javax.* namespaces, that Java SE does not allow to be modified. The
container should not allow applications to override or access the container�s
implementation classes. It is recommended also that the application class loader be
implemented so that classes and resources packaged within the WAR are loaded in
preference to classes and resources residing in container-wide library JARs.

Which sounds like to me that I can have a jar file in my web app with servlet.class and a jar file in the tomcat lib directory with servlet.class

What do you think is causing this null pointer exception?

Any help would be appreciated and thanks in advanced for the help.

Kay
[ September 25, 2008: Message edited by: Kay Green ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

Originally posted by Kay Green:
I have it as jsp because I am using jsp:include. I took that out to simplify the code
Taking it out to "simplify the code" likely also removes any chance we night have to find out what's going on.

Please also show us the contents of the include file.

And, please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

I have javax.servlet.jar in the lib directory of my web app...

Why?
Do you think that having javax.servlet.jar in my web app lib directory is causing this exception?
Could very well be. Where did you get it, and why did you feel the need to put it there? Tomcat will provide the servlet and JSP APIs.
[ September 24, 2008: Message edited by: Bear Bibeault ]
Kay Green
Greenhorn

Joined: Sep 24, 2008
Posts: 3
I took the javax.servlet.jar out of my webapp lib directory, stopped and restarted tomcat and got the same error.
The jsp file that I get the error on is the one listed in the original post.
Sorry about not using the around the code. This is the first time I have posted on this form.

Not sure what to try next.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

Maybe you should give us some more info about what you've put in WEB-INF/lib.
Kay Green
Greenhorn

Joined: Sep 24, 2008
Posts: 3
I have quite a large list of lib. Here it is.
I have tried taking out all WEB-INF/lib entries and then adding back as needed. This did work until I added one too many. I tried backing out the .jar files one at a time to try to find which one was causing the error but I still got the error. I think I will try that again, taking out all .jar files and adding back one at a time. I know that I don't need the ant jars and probably others.

ant-1.6.5.jar
ant-antlr-1.6.5.jar
ant-junit-1.6.5.jar
ant-launcher-1.6.5.jar
ant-swing-1.6.5.jar
antlr-2.7.6.jar
asm.jar
c3p0-0.9.1.jar
cglib-2.1.3.jar
checkstyle-all.jar
cleanimports.jar
commons-collections-2.1.1.jar
commons-logging-1.0.4.jar
concurrent-1.3.2.jar
dom4j-1.6.1.jar
ehcache-1.2.3.jar
hibernate3.jar
jaas.jar
jacc-1_0-fr.jar
javassist.jar
jaxen-1.1-beta-7.jar
jboss-cache.jar
jboss-common.jar
jboss-jmx.jar
jboss-system.jar
jgroups-2.2.8.jar
jsp-api.jar
jstl.jar
jta.jar
junit-3.8.1.jar
log4j-1.2.11.jar
ojdbc14.jar
oscache-2.1.jar
proxool-0.8.3.jar
standard.jar
swarmcache-1.0rc2.jar
syndiag2.jar
versioncheck.jar
xerces-2.6.2.jar
xml-apis.jar

Thanks for looking at this. I know it is probably a simple fix, because this app was working great until I tried to add Custom tag. I am reading Head First JSP and Servlets and trying to use things learned in this app.
Sameer maker
Greenhorn

Joined: Feb 28, 2009
Posts: 2
Removing jsp-api.jar from WEB-INF/lib folder of the application should resolve the issue.
Sameer maker
Greenhorn

Joined: Feb 28, 2009
Posts: 2
Sameer maker wrote:Removing jsp-api.jar from WEB-INF/lib folder of the application should resolve the issue.

Sameer
Jack Souza
Greenhorn

Joined: Dec 03, 2010
Posts: 2
Shameer:

You didn't say why getting rid of the jsp-api.jar would resolve the problem. I was having the same problem and took your advice sort of. I didn't have jsp-api.jar in my lib dir but figured if getting rid of all refs to JSP anything.jar would work--it did. It seems like the JSP (BTW I made a completely blank one and still got the problem) itself generates a sort of "_impl" whereby it generates some code to have the _jspinit() work on. I assume your fix meant that there was an override situation going on and the wrong routine was being called??? Looking for a bit more of an explanation. Many people seem to have had this problem without good explanation.

Jack Souza
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

Jack Souza wrote:You didn't say why getting rid of the jsp-api.jar would resolve the problem.

Because the servlet and JSP APIs are provided by the container and putting them into the WEB-INF/lib of the web app really boofs up the class loading.
Jack Souza
Greenhorn

Joined: Dec 03, 2010
Posts: 2
Thanks, Bear. Not very technical, but satisfying. I think you agreed with my assumption.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: null pointer in _jspInit