JasperException (god do I hate jsp exceptions)

Discussion in 'Java' started by Felix, Aug 6, 2003.

  1. Felix

    Felix Guest

    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 = 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
    Felix, Aug 6, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. madhu
    Replies:
    2
    Views:
    6,182
    Sudsy
    Jul 23, 2003
  2. Tim Meals
    Replies:
    0
    Views:
    4,844
    Tim Meals
    Sep 5, 2003
  3. Price Ellington

    JSP Import problem - JasperException?

    Price Ellington, Oct 7, 2003, in forum: Java
    Replies:
    2
    Views:
    801
    Chris Riesbeck
    Oct 7, 2003
  4. Nicky
    Replies:
    4
    Views:
    394
    Andrew Thompson
    Apr 8, 2004
  5. Jack Saalweachter

    God, software patents, I hate you, die.

    Jack Saalweachter, Oct 25, 2005, in forum: C++
    Replies:
    1
    Views:
    283
    Jack Saalweachter
    Oct 25, 2005
Loading...

Share This Page