Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

my jsp code works only if i keep jars in Tomcat lib apart from lib folder in classpath  RSS feed

 
Monica Shiralkar
Ranch Hand
Posts: 919
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my application I am calling a bean from JSP and displaying data.I have kept all required jars in lib folder and that is in build path.When I run this bean it fetches the data successfully. But when I call this bean in JSP it says No Class defination.I found a workaround for this that is putting all the jars also in the lib folder of Tomcat.(apart from keeping in classpath). Means now i have to deploy the war and also put jars in tomcat lib.but why do i have to do this when jars are already in classpath.

thanks.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37222
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are the jars in the WEB-INF/lib directory of your war file? Because that is where a web application will look for them.

Note that the build path is a compile time concept. The manifest file (and WEB-INF/lib) is a runtime concept.
 
Monica Shiralkar
Ranch Hand
Posts: 919
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the Jars are in lib folder in web-inf......So the Java Bean is able to find the jars(tested standalone)......without any issue...but when i call this working bean JSP calls the bean..it says ClassNotFound..unliess i put in tomcat lib..also
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66187
148
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Monica. Shiralkar wrote:the Jars are in lib folder in web-inf

WEB-INF, not web-inf. Case counts.

You should not be putting jars into the Tomcat folder. Any jar in the WEB-INF/lib folder will be added to the classpath of the web app. As Jeanne pointed out, the build-time classpath is completely moot when the application is executing under the container.

Are you by any chance also copying the servlet and JSP API jars to WEB-INF/lib? If so, they need to be removed.
 
Stefan Evans
Bartender
Posts: 1836
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another possibility is that you have the WEB-INF directory in a place OTHER than the root directory of your web application.

If you're in a standard Tomcat deployment scenario then your web application "myWebApp" should be deployed somewhere like:
[TOMCAT]/webapps/myWebApp/WEB-INF/lib

A common mistake I have seen is people using the ROOT web application. ie:
[TOMCAT]/webapps/ROOT/myWebApp/WEB-INF/
This is NOT the correct approach.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!