Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

set classpath for JSP files  RSS feed

 
Sham Grandhe
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In one of my JSP I have extended a custom servlet class which is available from the jars which are located in my lib folder, when the JSP's servlet gets executed it says that class is not available how do I set the class path for those files.

Any suggestions appreciated

Thank you,


java.lang.NoClassDefFoundError
at com.pennywise.framework.mvc.Jsp.process(Jsp.java:65)
at com.pennywise.framework.mvc.Jsp.service(Jsp.java:49)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:162)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)



Sham
[ November 19, 2005: Message edited by: kumar shyam ]
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually you do not want to extend a custom class in a JSP. You may loose some functionality by doing so. Since this is a custom servlet class, which already extends HttpServlet, you may be able to get away with it. If you have your custom class under the appropriate folder in WEB-INF, and it's still not found, I don't know.
[ November 19, 2005: Message edited by: Bosun Bello ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually you do not want to extend a custom class in a JSP. You may loose some functionality by doing so.


Huh?

how do I set the class path for those files.


All classes in jar files in the WEB-INF/lib folder are automatically added to the classpath. If your class is not being found it is either because there's an error in your setup, the class isn't really there, or the exception is not for the class that you think it is.
 
Sham Grandhe
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bibeault,

If your class is not being found it is either because there's an error in your setup


To ensure that the setup is fine I have put some other simple sevlets and jsp and checked.

the class isn't really there, or the exception is not for the class that you think it is.


To ensure this I have opened the jar and check it, the file exists.

If you feel this is not correct, can you please advise me as of what is to be done.

Thank you,

Sham
 
geeta lalchandani
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a similar problem...

I generated code through JAXB,and imported that package in the jsp.
Now when i just refer to that jaxb object(Radio), there is a stack trace on the screen

Unable to compile class for JSP C:\gcb_workspace\GCB2\WebContent\WEB-INF\lib\gcb_jaxb_2.0.jar(com/hsbc/gf/gcb/xml/jaxb/Radio.java):40: class Radio is public, should be declared in a file named Radio.java (source unavailable)

This jar is in the WEB-INF lib folder.
What do i do to access this object???
 
geeta lalchandani
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
found out that the generated jar contained the java and class files.
The jsp was trying to compile the java classes.

If we remove the source from the jar, and just keep the class files, it works.

Probably it was some class path settings, that were not on the PC, so there was the probelm in compilation.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!