Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JasperException (god do I hate jsp exceptions)

2 views
Skip to first unread message

Felix

unread,
Aug 5, 2003, 7:10:35 PM8/5/03
to
Hello All,

I've written a java file that reads xml data and creates java objects
provided from classes created by JAXB based on an xml schema. The java
file is called Application and it instantiates an object called
cwLoader that actually handles reading the xml file and returning
objects. Once the application java file gets the object it just grabs
a device within the object and prints out a serial number. When i run
Application from a console it works fine. Prints out a serial number
and everything. When I try and get it to run from a jsp scriptlet all
hell breaks lose.

I know for certain that my tomcat installation is correct because i
can get it to generate a time stamp via java.util.Date() but for some
reason I can't get this code to execute. Any ideas?

I can run this file (Application.java) from the console no problem:
----------------------------------------------
package cisco;

public class Application{
public static void main(String args[]){

cwLoader loader = new cwLoader();
System.out.println("loader created.");
loader.initiliaze();
System.out.println("loader initiliazed.");
CiscoChassisType myCiscoDevice = loader.getCiscoDevice(0);
System.out.println("first cisco device loaded.");
System.out.println("The device serial number is " +
myCiscoDevice.getSerialNumber());
}

}
------------------------------------------------

This file calls on cwLoader.java which seems to be the root of all
evil.
------------------------------------------------
package cisco;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.Validator;
import java.io.File;
import java.io.FileOutputStream;
import java.util.List;

public class cwLoader{
InvDetails inv;
CiscoChassisType[] deviceArray;
String Hello = "hello";


//--------------------------------------
public String getHello(){return (Hello);}

public void setHello(String message){message = Hello;}

//--------------------------------------
public CiscoChassisType getCiscoDevice(int deviceIndex){
CiscoChassisType tempCCT = deviceArray[deviceIndex];
return tempCCT;
}

public void setCiscoDevice(){}

//--------------------------------------
public CiscoChassisType[] getCiscoDeviceArray(){
return deviceArray;
}

public void setCiscoDeviceArray(){}


//--------------------------------------
public InvDetails getInventory(){
return inv;
}

public void setInventory(InvDetails inv){
this.inv =inv;
}


//Non get sets -------------------------

public void initiliaze(){
try{
System.out.println("calling loader");
JAXBContext jc = JAXBContext.newInstance("cisco");
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
new Boolean(true));
Unmarshaller unmarshaller = jc.createUnmarshaller();
unmarshaller.setValidating(true);
Validator validator = jc.createValidator();
inv = (InvDetails)unmarshaller.unmarshal(new
File("200308115248inventory.xml"));
System.out.println("xml file loaded");
populateDeviceArray();
}
catch (Exception e) {System.out.println( e );}
}

public void populateDeviceArray(){
CiscoChassisType[] tempArray = new
CiscoChassisType[inv.getRMEPlatform().size()];
for(int i =0; i < inv.getRMEPlatform().size(); i++){
RMEPlatformType tempRME =
(RMEPlatformType)inv.getRMEPlatform().get(i);
CiscoChassisType tempCCT =
(CiscoChassisType)tempRME.getCiscoChassis().get(0);
tempArray[i] = tempCCT;
}
deviceArray = tempArray;
System.out.println("Array loaded.");
}


}//end class
-----------------------------------------------

When I run "Application" from the console I get a device serial number
which was read from a java object which was bound from an xml file.

When I try to execute the same code in a java scriplet in a jsp file
all hell breaks lose. Below is the jsp file.
----------------------------------------------------
<%@ page import="cisco.*" %>
<%@ page import="cisco.cwLoader" %>
<jsp:useBean id="loader" class="cisco.cwLoader" scope="application"/>
<HTML>
<BODY>
Hello! The time is now <%= new java.util.Date() %>
<%
System.out.println("loader created.");
loader.initiliaze();
System.out.println("loader initiliazed.");
CiscoChassisType myCiscoDevice = loader.getCiscoDevice(0);
System.out.println("first cisco device loaded.");
System.out.println("The device serial number is " +
myCiscoDevice.getSerialNumber());
%>

</BODY>
</HTML>
-----------------------------------------------------

I get this error:

type Exception report

message

description The server encountered an internal error () that prevented
it from fulfilling this request.

exception

org.apache.jasper.JasperException: cisco.cwLoader.initiliaze()V
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)


root cause

javax.servlet.ServletException: cisco.cwLoader.initiliaze()V
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
at org.apache.jsp.hello_jsp._jspService(hello_jsp.java:79)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)
-----------------------------------------------------

I can't believe that the above output is useful information for
anything. Am I doing something obviously stupid?

I always wonder about people who respond to my post and the amazing
patience they must have to be willing to go through a post like this.
Thanks kind reader.

-Felix

John C. Bollinger

unread,
Aug 11, 2003, 11:09:02 AM8/11/03
to
Felix wrote:
> Hello All,
>
> I've written a java file that reads xml data and creates java objects
> provided from classes created by JAXB based on an xml schema. The java
> file is called Application and it instantiates an object called
> cwLoader that actually handles reading the xml file and returning
> objects. Once the application java file gets the object it just grabs
> a device within the object and prints out a serial number. When i run
> Application from a console it works fine. Prints out a serial number
> and everything. When I try and get it to run from a jsp scriptlet all
> hell breaks lose.
>
> I know for certain that my tomcat installation is correct because i
> can get it to generate a time stamp via java.util.Date() but for some
> reason I can't get this code to execute. Any ideas?

[Code removed]

JasperExceptions indicate a problem with translating or compiling your
JSP page. In this case I would recommend that you make sure that a
compatible version of your bean class is located in a place where Tomcat
can find it -- the webapp's WEB-INF/classes or inside a jar in
WEB-INF/lib would be a good place. Make sure there isn't an
incompatible version of the class anywhere, including in the Tomcat-wide
shared library directory (the name varies a bit with version of Tomcat).
Sometimes it is intructive to look at the java source built from your
JSP; you'll find it under Tomcat's work directory somewhere.

Good Luck,

John Bollinger
jobo...@indiana.edu

0 new messages