Re: [Httpunit-develop] passing servletRunner web.xml as stream
Brought to you by:
russgold
From: Adam H. <aha...@cy...> - 2008-04-22 13:11:12
|
Hi, if you recall, I set up ServletUnit with a web.xml stream, and a servlet is trying to find web.xml. I traced it to here: JspServletWrapper.handleJspException(Exception) line: 492 JspServletWrapper.service(HttpServletRequest, HttpServletResponse, boolean) line: 357 JspServlet.serviceJspFile(HttpServletRequest, HttpServletResponse, String, Throwable, boolean) line: 320 JspServlet.service(HttpServletRequest, HttpServletResponse) line: 266 JspServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 853 RequestDispatcherImpl.forward(ServletRequest, ServletResponse) line: 54 ServletDispatcherResult.doExecute(String, ActionInvocation) line: 139 The JspServletWrapper is from the org.apache.jasper.servlet package. So your statement that my servlet is doing a request for the web.xml is only partially correct - it seems that jasper is the true culprit, trying to run the JSP. I didn't have the Jasper source code, but the next question is whether HttpUnit can handle it? Perhaps the config should be available to Jasper somehow? here's its logging: FINE 14:06:54 JspRuntimeContext.<init>(): Parent class loader is: sun.misc.Launcher$AppClassLoader@1858610 (org.apache.jasper.compiler) FINE 14:06:54 JspRuntimeContext.initClassPath(): Compilation classpath initialized: /home/adam/projects/atomic/build/:/home/java/httpunit/trunk/httpunit/build/:/home/java/httpunit/trunk/httpunit/jars/activation.jar:/home/java/httpunit/trunk/httpunit/jars/ant-dependencies.jar:/home/java/httpunit/trunk/httpunit/jars/mailapi.jar:/home/java/httpunit/trunk/httpunit/jars/quicksite.jar:/home/java/httpunit/trunk/httpunit/jars/js.jar:/home/java/httpunit/trunk/httpunit/jars/junit.jar:/home/java/httpunit/trunk/httpunit/jars/nekohtml.jar:/home/java/httpunit/trunk/httpunit/jars/servlet.jar:/home/java/httpunit/trunk/httpunit/jars/Tidy.jar:/home/java/httpunit/trunk/httpunit/jars/xercesImpl.jar:/home/java/httpunit/trunk/httpunit/jars/xmlParserAPIs.jar:/home/java/m2-repo/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/home/java/m2-repo/avalon-framework/avalon-framework/4.1.3/avalon-framework-4.1.3.jar:/home/java/m2-repo/com/opensymphony/xwork/2.0.4/xwork-2.0.4.jar:/home/java/m2-repo/commons-beanutils/commons-beanutils/1.8.0-BETA/commons-beanutils-1.8.0-BETA.jar:/home/java/m 2-repo/commons-collections/commons-collections/3.2/commons-collections-3.2.jar:/home/java/m2-repo/commons-configuration/commons-configuration/1.5/commons-configuration-1.5.jar:/home/java/m2-repo/commons-digester/commons-digester/1.8/commons-digester-1.8.jar:/home/java/m2-repo/commons-lang/commons-lang/2.3/commons-lang-2.3.jar:/home/java/m2-repo/freemarker/freemarker/2.3.8/freemarker-2.3.8.jar:/home/java/m2-repo/logkit/logkit/1.0.1/logkit-1.0.1.jar:/home/java/m2-repo/opensymphony/ognl/2.6.11/ognl-2.6.11.jar:/home/java/m2-repo/org/apache/struts/struts2-core/2.0.9/struts2-core-2.0.9.jar:/home/java/m2-repo/org/apache/struts/struts2-tiles-plugin/2.0.9/struts2-tiles-plugin-2.0.9.jar:/home/java/m2-repo/org/apache/tiles/tiles-jsp/2.0.4/tiles-jsp-2.0.4.jar:/home/java/m2-repo/org/apache/tiles/tiles-api/2.0.4/tiles-api-2.0.4.jar:/home/java/m2-repo/org/apache/tiles/tiles-core/2.0.4/tiles-core-2.0.4.jar:/home/java/m2-repo/org/apache/commons/commons-io/1.3.2/commons-io-1.3.2.jar:/home/java /m2-repo/taglibs/standard/1.1.2/standard-1.1.2.jar:/home/java/m2-repo/javax/servlet/jstl/1.1.2/jstl-1.1.2.jar:/home/java/m2-repo/commons-logging/commons-logging/1.1/commons-logging-1.1.jar:/home/java/m2-repo/commons-fileupload/commons-fileupload/1.2.1/commons-fileupload-1.2.1.jar:/home/java/m2-repo/commons-math/commons-math/1.1/commons-math-1.1.jar:/home/java/m2-repo/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3.jar:/home/java/m2-repo/org/easymock/easymock/2.3/easymock-2.3.jar:/home/java/m2-repo/org/easymock/easymockclassextension/2.3/easymockclassextension-2.3.jar:/home/java/m2-repo/org/permacode/atomic-test-jar/1.0-SNAPSHOT/atomic-test-jar-1.0-SNAPSHOT.jar:/home/java/m2-repo/org/dbunit/dbunit/2.2/dbunit-2.2.jar:/home/java/m2-repo/httpunit/httpunit/1.6.2/httpunit-1.6.2.jar:/home/java/m2-repo/org/apache/tomcat/jasper/6.0.13/jasper-6.0.13.jar:/home/java/m2-repo/org/apache/tomcat/juli/6.0.13/juli-6.0.13.jar:/home/java/m2-repo/org/apache/tomcat/jasper-el/6.0.13/jasper-el-6.0.13.jar: /home/java/m2-repo/org/apache/tomcat/jasper-jdt/6.0.13/jasper-jdt-6.0.13.jar:/home/java/m2-repo/org/apache/geronimo/specs/geronimo-jpa_3.0_spec/1.1.1/geronimo-jpa_3.0_spec-1.1.1.jar:/home/java/m2-repo/javax/transaction/jta/1.0.1B/jta-1.0.1B.jar:/home/java/m2-repo/p6spy/p6spy/1.3-patch/p6spy-1.3-patch.jar:/home/java/m2-repo/postgresql/postgresql/8.2-507.jdbc3/postgresql-8.2-507.jdbc3.jar:/home/java/m2-repo/com/h2database/h2/1.0.64/h2-1.0.64.jar:/home/java/m2-repo/mysql/mysql-connector-java/5.0.5/mysql-connector-java-5.0.5.jar:/home/java/m2-repo/hsqldb/hsqldb/1.8.0.7/hsqldb-1.8.0.7.jar:/home/java/m2-repo/org/apache/derby/derby/10.3.2.1/derby-10.3.2.1.jar:/home/java/m2-repo/commons-dbutils/commons-dbutils/1.1/commons-dbutils-1.1.jar:/home/java/m2-repo/org/springframework/spring-aop/2.0.6/spring-aop-2.0.6.jar:/home/java/m2-repo/org/springframework/spring-beans/2.0.6/spring-beans-2.0.6.jar:/home/java/m2-repo/org/springframework/spring-context/2.0.6/spring-context-2.0.6.jar:/home/j ava/m2-repo/org/springframework/spring-core/2.0.6/spring-core-2.0.6.jar:/home/java/m2-repo/org/springframework/spring-dao/2.0.6/spring-dao-2.0.6.jar:/home/java/m2-repo/org/springframework/spring-jdbc/2.0.6/spring-jdbc-2.0.6.jar:/home/java/m2-repo/org/springframework/spring-jpa/2.0.6/spring-jpa-2.0.6.jar:/home/java/eclipse-3.3.1.1/plugins/org.junit4_4.3.1/junit.jar:/home/java/m2-repo/org/hibernate/hibernate/3.2.5.ga/hibernate-3.2.5.ga.jar:/home/java/m2-repo/org/hibernate/hibernate-annotations/3.3.0.ga/hibernate-annotations-3.3.0.ga.jar:/home/java/m2-repo/org/hibernate/hibernate-entitymanager/3.3.1.ga/hibernate-entitymanager-3.3.1.ga.jar:/home/java/m2-repo/jboss/jboss-archive-browsing/5.0.0alpha-200607201-119/jboss-archive-browsing-5.0.0alpha-200607201-119.jar:/home/java/m2-repo/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/home/java/m2-repo/org/hibernate/hibernate-commons-annotations/3.0.0.ga/hibernate-commons-annotations-3.0.0.ga.jar:/home/java/m2-repo/jboss/javassist/3.3.ga/javassist-3 .3.ga.jar:/home/java/m2-repo/antlr/antlr/2.7.6/antlr-2.7.6.jar:/home/java/m2-repo/cglib/cglib/2.1_3/cglib-2.1_3.jar:/home/java/m2-repo/asm/asm/1.5.3/asm-1.5.3.jar:/home/java/m2-repo/org/apache/openjpa/openjpa-jdbc/1.1.0-SNAPSHOT/openjpa-jdbc-1.1.0-SNAPSHOT.jar:/home/java/m2-repo/org/apache/openjpa/openjpa/1.1.0-SNAPSHOT/openjpa-1.1.0-SNAPSHOT.jar:/home/java/m2-repo/net/sourceforge/serp/serp/1.13.1/serp-1.13.1.jar:/home/java/m2-repo/org/apache/openjpa/openjpa-examples/1.1.0-SNAPSHOT/openjpa-examples-1.1.0-SNAPSHOT.jar:/home/java/m2-repo/com/oracle/toplink/toplink-essentials/2.0-b58g-fcs/toplink-essentials-2.0-b58g-fcs.jar:/home/java/m2-repo/com/oracle/toplink/toplink-essentials-agent/2.0-b58g-fcs/toplink-essentials-agent-2.0-b58g-fcs.jar:/home/java/m2-repo/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar:/home/java/m2-repo/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar:/home/adam/projects/atomic-jdk-logging/build/:/home/java/eclipse-3.3.1.1/configuration/org.eclipse.osgi/bundl es/384/1/.cp/:/home/java/eclipse-3.3.1.1/configuration/org.eclipse.osgi/bundles/92/1/.cp/:/home/java/eclipse-3.3.1.1/configuration/org.eclipse.osgi/bundles/9/1/.cp/:/tmp:null (org.apache.jasper.compiler) FINE 14:06:54 JspServlet.init(): Scratch dir for the JSP engine is: /tmp (org.apache.jasper.servlet) FINE 14:06:54 JspServlet.init(): IMPORTANT: Do not modify the generated servlets (org.apache.jasper.servlet) FINE 14:06:54 JspServlet.service(): JspEngine --> /test.jsp (org.apache.jasper.servlet) FINE 14:06:54 JspServlet.service(): ServletPath: /test.jsp (org.apache.jasper.servlet) FINE 14:06:54 JspServlet.service(): PathInfo: null (org.apache.jasper.servlet) FINE 14:06:54 JspServlet.service(): RealPath: /home/adam/projects/atomic/test.jsp (org.apache.jasper.servlet) FINE 14:06:54 JspServlet.service(): RequestURI: /test/test.jsp (org.apache.jasper.servlet) FINE 14:06:54 JspServlet.service(): QueryString: code=1 (org.apache.jasper.servlet) FINE 14:06:54 JspServlet.service(): Request Params: (org.apache.jasper.servlet) FINE 14:06:54 JspServlet.service(): code = 1 (org.apache.jasper.servlet) FINE 14:06:54 Compiler.removeGeneratedFiles(): Deleting /tmp/org/apache/jsp/test_jsp.class (org.apache.jasper.compiler) FINE 14:06:54 Compiler.removeGeneratedFiles(): Deleting /tmp/org/apache/jsp/test_jsp.java (org.apache.jasper.compiler) Russell Gold on 09/04/08 01:13, wrote: > Based on the stack trace, it appears that your servlet is doing a > request for the web.xml on its own. The input stream allows you to > specify the web.xml for ServletUnit to use to interpret requests; > however, if one of your servlets looks for that file, it will be > treated as any other web request. > > > On Apr 8, 2008, at 10:09 AM, Adam Hardy wrote: > >> I am trying to figure out the exception from the following code (see >> below for >> stacktrace). >> >> What more do I need to do? I have done this: >> >> - instantiated servletRunner with XML stream for deployment descriptor >> - created a WebRequest object >> - passed in the request to the getResponse() call >> >> Yet ServletRunner is looking for the deployment descriptor again, >> which it >> should already have. >> >> >> StringBuilder xml = new StringBuilder(); >> xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); >> xml.append("<web-app version=\"2.4\""); >> xml.append(" xmlns=\"http://java.sun.com/xml/ns/j2ee\""); >> xml.append(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance >> \""); >> xml.append(" xsi:schemaLocation=\"http://java.sun.com/xml/ns/j2ee"); >> xml.append(" http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd\">"); >> xml.append("<filter><filter-name>Struts</filter-name>"); >> xml.append("<filter-class>"); >> xml.append("org.apache.struts2.dispatcher.FilterDispatcher"); >> xml.append("</filter-class></filter>"); >> xml.append("<filter-mapping><filter-name>Struts</filter-name>"); >> xml.append("<url-pattern>*.html</url-pattern></filter-mapping>"); >> xml.append("<servlet><servlet-name>bla</servlet-name><servlet- >> class>"); >> xml.append("bug.EmptyServlet"); >> xml.append("</servlet-class></servlet>"); >> xml.append("<servlet-mapping><servlet-name>bla</servlet-name>"); >> xml.append("<url-pattern>*.html</url-pattern></servlet-mapping>"); >> xml.append("</web-app>"); >> ServletRunner servletRunner = >> new ServletRunner(new ByteArrayInputStream(xml.toString() >> .getBytes()), "/test"); >> servletRunner.registerServlet("bla", EmptyServlet.class.getName()); >> ServletUnitClient client = servletRunner.newClient(); >> File file = new File("src/test/resources/results.csv"); >> WebRequest getRequest = >> new GetMethodWebRequest( >> "http://localhost/test/test-result/edit.html"); >> WebResponse response = servletRunner.getResponse(getRequest); >> >> >> >> >> com.meterware.httpunit.HttpInternalErrorException: Error on HTTP >> request: 500 >> javax.servlet.ServletException: >> /home/adam/projects/bug-httpunit-struts/WEB-INF/web.xml (No such >> file or >> directory) [http://localhost/test/test-result/edit.html] >> at >> com >> .meterware >> .servletunit.ServletUnitClient.newResponse(ServletUnitClient.java:121) |