-
1. Re: java.lang.NoClassDefFoundError: org/apache/cactus/Servl
ssilvert Aug 11, 2008 2:52 PM (in response to slabside)Hi Gerry,
All JSFUnit questions are welcome here.
Can you post the full stack trace? I can't tell if this error is coming from inside the container or if it is coming from your ant script.
If the cactus jar is in WEB-INF/lib then I suspect it is the later. In that case, you just need to make sure that the cactus jar is in your classpath when you execute the test from ant.
Note that when you run a JSFUnit/Cactus test from Ant or Maven you are running the JUnit test both inside and outside the container. See this Cactus page for details on how this works:
http://jakarta.apache.org/cactus/how_it_works.html
Regards,
Stan -
2. Re: java.lang.NoClassDefFoundError: org/apache/cactus/Servl
slabside Aug 12, 2008 7:08 AM (in response to slabside)Thanks Stan,
I added the cactus jar to the classpath and things have moved on... however....
I am now getting a different error -
Error in JSFClientSession constructor. /ViewBankDetails.faces probably does not map to FacesServlet in web.xml. See full URL in HttpException.
java.lang.IllegalArgumentException: Error in JSFClientSession constructor. /ViewBankDetails.faces probably does not map to FacesServlet in web.xml. See full URL in HttpException. at org.jboss.jsfunit.facade.JSFClientSession.doInitialRequest(JSFClientSession.java:135) at org.jboss.jsfunit.facade.JSFClientSession.(JSFClientSession.java:82) at uk.co.slc.cst.jsfunit.ViewBankDetailsTest.testInitialPage(ViewBankDetailsTest.java:23) at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153) at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119) at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:93) at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:217) at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java) at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101) at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:217) at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java) at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72) at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:217) at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java) at javax.servlet.http.HttpServlet.service(HttpServlet.java:743) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65) at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:122) at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:623) at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370) at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453) at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111) at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260) at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239) at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34) at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880) at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303) at java.lang.Thread.run(Thread.java:595)Caused by: com.meterware.httpunit.HttpInternalErrorException: Error on HTTP request: 500 Internal Error [http://localhost:8888/BankDetails/ViewBankDetails.faces] at com.meterware.httpunit.WebClient.validateHeaders(WebClient.java:573) at com.meterware.httpunit.WebClient.updateClient(WebClient.java:464) at com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:139) at com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:130) at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:121) at com.meterware.httpunit.WebClient.getResponse(WebClient.java:113) at org.jboss.jsfunit.facade.JSFClientSession.doWebRequest(JSFClientSession.java:200) at org.jboss.jsfunit.facade.JSFClientSession.doInitialRequest(JSFClientSession.java:131) ... 36 more
Here is the instrumented web.xml<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "web-app_2_3.dtd"> <web-app> <display-name>Customer Bank Details</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:/uk/co/slc/cst/bankdetails/api/spring/applicationContext.xml classpath:/uk/co/slc/cst/bankdetails/spring/datasource-applicationContext.xml </param-value> </context-param> <filter> <filter-name>ServletTestFilter</filter-name> <filter-class>org.jboss.jsfunit.framework.JSFUnitFilter</filter-class> </filter> <filter-mapping> <filter-name>JSFUnitFilter</filter-name> <url-pattern>/ServletRedirector</url-pattern> </filter-mapping> <filter-mapping> <filter-name>ServletTestFilter</filter-name> <url-pattern>/ServletTestRunner</url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <description>State saving method: "client" or "server" (= default) See JSF Specification 2.5.3</description> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>client</param-value> </context-param> <context-param> <description>Only applicable if state saving method is "server" (= default). Defines the amount (default = 20) of the latest views are stored in session.</description> <param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name> <param-value>20</param-value> </context-param> <context-param> <description>Only applicable if state saving method is "server" (= default). If true (default) the state will be serialized to a byte stream before it is written to the session. If false the state will not be serialized to a byte stream.</description> <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name> <param-value>true</param-value> </context-param> <context-param> <description>Only applicable if state saving method is "server" (= default) and if org.apache.myfaces.SERIALIZE_STATE_IN_SESSION is true (= default) If true (default) the serialized state will be compressed before it is written to the session. If false the state will not be compressed.</description> <param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name> <param-value>true</param-value> </context-param> <context-param> <description>This parameter tells MyFaces if javascript code should be allowed in the rendered HTML output. If javascript is allowed, command_link anchors will have javascript code that submits the corresponding form. If javascript is not allowed, the state saving info and nested parameters will be added as url parameters. Default: "true"</description> <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name> <param-value>false</param-value> </context-param> <context-param> <description>If true, rendered HTML code will be formatted, so that it is "human readable". i.e. additional line separators and whitespace will be written, that do not influence the HTML code. Default: "true"</description> <param-name>org.apache.myfaces.PRETTY_HTML</param-name> <param-value>true</param-value> </context-param> <context-param> <description>If true, a javascript function will be rendered that is able to restore the former vertical scroll on every request. Convenient feature if you have pages with long lists and you do not want the browser page to always jump to the top if you trigger a link or button action that stays on the same page. Default: "false"</description> <param-name>org.apache.myfaces.AUTO_SCROLL</param-name> <param-value>true</param-value> </context-param> <context-param> <description> Used for encrypting view state. Only relevant for client side state saving. See MyFaces wiki/web site documentation for instructions on how to configure an application for diffenent encryption strengths. </description> <param-name>org.apache.myfaces.SECRET</param-name> <param-value>NzY1NDMyMTA=</param-value> </context-param> <context-param> <description> Validate managed beans, navigation rules and ensure that forms are not nested. </description> <param-name>org.apache.myfaces.VALIDATE</param-name> <param-value>true</param-value> </context-param> <context-param> <description>A class implementing the org.apache.myfaces.shared.renderkit.html.util.AddResource interface. It is responsible to place scripts and css on the right position in your HTML document. Default: "org.apache.myfaces.shared.renderkit.html.util.DefaultAddResource" Follow the description on the MyFaces-Wiki-Performance page to enable StreamingAddResource instead of DefaultAddResource if you want to gain performance. </description> <param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name> <param-value>org.apache.myfaces.renderkit.html.util.DefaultAddResource</param-value> <!--param-value>org.apache.myfaces.component.html.util.StreamingAddResource</param-value--> </context-param> <context-param> <description> A very common problem in configuring MyFaces-web-applications is that the Extensions-Filter is not configured at all or improperly configured. This parameter will check for a properly configured Extensions-Filter if it is needed by the web-app. In most cases this check will work just fine, there might be cases where an internal forward will bypass the Extensions-Filter and the check will not work. If this is the case, you can disable the check by setting this parameter to false. </description> <param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name> <param-value>true</param-value> </context-param> <filter> <filter-name>extensionsFilter</filter-name> <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class> <init-param> <description>Set the size limit for uploaded files. Format: 10 - 10 bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB</description> <param-name>uploadMaxFileSize</param-name> <param-value>100m</param-value> </init-param> <init-param> <description>Set the threshold size - files below this limit are stored in memory, files above this limit are stored on disk. Format: 10 - 10 bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB</description> <param-name>uploadThresholdSize</param-name> <param-value>100k</param-value> </init-param> </filter> <filter> <filter-name>JSFUnitFilter</filter-name> <filter-class>org.jboss.jsfunit.framework.JSFUnitFilter</filter-class> </filter> <filter-mapping> <filter-name>extensionsFilter</filter-name> <url-pattern>*.jsf</url-pattern> </filter-mapping> <filter-mapping> <filter-name>extensionsFilter</filter-name> <url-pattern>*.faces</url-pattern> </filter-mapping> <filter-mapping> <filter-name>extensionsFilter</filter-name> <url-pattern>/faces/*</url-pattern> </filter-mapping> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>ServletRedirector</servlet-name> <servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-class> </servlet> <servlet> <servlet-name>ServletTestRunner</servlet-name> <servlet-class>org.apache.cactus.server.runner.ServletTestRunner</servlet-class> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.faces</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>ServletRedirector</servlet-name> <url-pattern>/ServletRedirector</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>ServletTestRunner</servlet-name> <url-pattern>/ServletTestRunner</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsf</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>index.html</welcome-file> </welcome-file-list> <taglib> <taglib-uri>http://java.sun.com/jsf/html</taglib-uri> <taglib-location>/WEB-INF/myfaces_html.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://java.sun.com/jsf/core</taglib-uri> <taglib-location>/WEB-INF/myfaces_core.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://myfaces.apache.org/tomahawk</taglib-uri> <taglib-location>/WEB-INF/lib/tomahawk-1.1.6.jar</taglib-location> </taglib> </web-app>
Any pointers much appreciated
cheers
Gerry -
3. Re: java.lang.NoClassDefFoundError: org/apache/cactus/Servl
ssilvert Aug 12, 2008 8:28 AM (in response to slabside)I think the important part of your stack trace is here:
com.meterware.httpunit.HttpInternalErrorException: Error on HTTP request: 500 Internal Error [http://localhost:8888/BankDetails/ViewBankDetails.faces] at com.meterware.httpunit.WebClient.validateHeaders(WebClient.java:573) at com.meterware.httpunit.WebClient.updateClient(WebClient.java:464) at
If you type http://localhost:8888/BankDetails/ViewBankDetails.faces in a browser, what happens?
I suspect that you will get the same 500 error. So you need to look on the server and find out what caused the HttpInternalErrorException. There is probably something in the server's log.
BTW, which app server are you using?
Stan -
4. Re: java.lang.NoClassDefFoundError: org/apache/cactus/Servl
slabside Aug 12, 2008 9:52 AM (in response to slabside)Hi Stan
I am using oc4j 0.1.3.3.0...
I think I found what the issue is. It looks like the web.xml is not being instrumented correctly by the <jsfunitwar task> due to the DOC TYPE statement url not being resolved. (proxy issue?) I tried various commands with ant but get the connection error.
I also tried ant's replace task (to swap out the DOC TYPE url value) but ran into a windows file locking issue: see here
http://markmail.org/message/xue7t5qagr3pk7rw#query:%3Creplace%20file%20%22java.io.IOException%3A%20Failed%20to%20delete%22%20ant+page:1+mid:ftajzftfsh3y7275+state:results
If I correct that, say set it to /WEB-INF/web-app_2_3.dtd and place the dtd in WEB-INF the tests run and the report output is as expected.
Not sure if there is a way round this, locally anyway. I'm hoping to be running tests on a unix/linux env (once the POC is done!) and I'm lead to believe the file locking issue does not occur.
If you have any ideas I'd be glad to hear them!
thanks for your assistance
Gerry -
5. Re: java.lang.NoClassDefFoundError: org/apache/cactus/Servl
ssilvert Aug 12, 2008 9:44 PM (in response to slabside)"slabside" wrote:
I think I found what the issue is. It looks like the web.xml is not being instrumented correctly by the <jsfunitwar task> due to the DOC TYPE statement url not being resolved. (proxy issue?) I tried various commands with ant but get the connection error.
I don't understand. If the DOC TYPE is not resolved, how is that a <jsfunitwar task> issue? I don't think the ant task should change the DOC TYPE. Is that what is happening?
Stan -
6. Re: java.lang.NoClassDefFoundError: org/apache/cactus/Servl
slabside Aug 13, 2008 8:02 AM (in response to slabside)Stan
I found that if the web.xml DOC TYPE url was http://java.sun.com/dtd/web-app_2_3.dtd" then the web.xml was not getting instrumented. The console output of my build script suggested that the connection issue was occurring while running <jsfunitwar task>.jsfunit.exploded.war: [echo] Running jsfunit exloded war target [jsfunitwar] java.net.ConnectException: Connection refused: connect [jsfunitwar] at java.net.PlainSocketImpl.socketConnect(Native Method) [jsfunitwar] at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) [jsfunitwar] at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) [jsfunitwar] at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) [jsfunitwar] at java.net.Socket.connect(Socket.java:519) [jsfunitwar] at java.net.Socket.connect(Socket.java:469) [jsfunitwar] at sun.net.NetworkClient.doConnect(NetworkClient.java:157) [jsfunitwar] at sun.net.www.http.HttpClient.openServer(HttpClient.java:382) [jsfunitwar] at sun.net.www.http.HttpClient.openServer(HttpClient.java:494) [jsfunitwar] at sun.net.www.http.HttpClient.<init>(HttpClient.java:231) [jsfunitwar] at sun.net.www.http.HttpClient.New(HttpClient.java:304) [jsfunitwar] at sun.net.www.http.HttpClient.New(HttpClient.java:316) [jsfunitwar] at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:817 [jsfunitwar] at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:769) [jsfunitwar] at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:694) [jsfunitwar] at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:938) [jsfunitwar] at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source) [jsfunitwar] at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source) [jsfunitwar] at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source) [jsfunitwar] at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source) [jsfunitwar] at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source) [jsfunitwar] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) [jsfunitwar] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) [jsfunitwar] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) [jsfunitwar] at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) [jsfunitwar] at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) [jsfunitwar] at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) [jsfunitwar] at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:172) [jsfunitwar] at org.jboss.jsfunit.ant.JSFUnitWarTask.getWebXml(JSFUnitWarTask.java:300) [jsfunitwar] at org.jboss.jsfunit.ant.JSFUnitWarTask.JSFUnitExplodedWar(JSFUnitWarTask.java:263) [jsfunitwar] at org.jboss.jsfunit.ant.JSFUnitWarTask.execute(JSFUnitWarTask.java:228) [jsfunitwar] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [jsfunitwar] at org.apache.tools.ant.Task.perform(Task.java:364) [jsfunitwar] at org.apache.tools.ant.Target.execute(Target.java:341) [jsfunitwar] at org.apache.tools.ant.Target.performTasks(Target.java:369) [jsfunitwar] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [jsfunitwar] at org.apache.tools.ant.Project.executeTarget(Project.java:1185) [jsfunitwar] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) [jsfunitwar] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [jsfunitwar] at org.apache.tools.ant.Main.runBuild(Main.java:668) [jsfunitwar] at org.apache.tools.ant.Main.startAnt(Main.java:187) [jsfunitwar] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246) [jsfunitwar] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67) [echo] End jsfunit exloded war target
And the ant target<!-- ========================================================== --> <!-- jsfunit.exploded.war target --> <!-- ========================================================== --> <target name="jsfunit.exploded.war" depends="clean" description="builds a JSFUnified war from the out put of the maven goal local-build"> <echo> Running jsfunit exloded war target</echo> <taskdef name="jsfunitwar" classname="org.jboss.jsfunit.ant.JSFUnitWarTask"/> <jsfunitwar srcfile="${cst.war}" destfile="${jsf.cst.war}" autoAddJars="false"> <lib dir="${remote.jsfunit.lib}"> <include name="*.jar"/> </lib> <TestRunner/> </jsfunitwar> <echo> End jsfunit exloded war target</echo> </target>
The build completes and the tests run but fail because the web.xml has not been instrumented. I don't know why this occurs .. I have not looked at the source of the <jsfunitwar task>.
I have a workaround to this so it's not a pressing issue.
cheers
Gerry -
7. Re: java.lang.NoClassDefFoundError: org/apache/cactus/Servl
kragoth Aug 14, 2008 2:32 AM (in response to slabside)It would appear as though the dtd is trying to be resolved and as you suggested your proxy is blocking the connection.
I am behind a proxy as well but I declare my web.xml like this:<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
This works fine for me.
Is there any reason why you have to use 2.3?