7 Replies Latest reply: Aug 17, 2010 8:05 AM by Stan Silvert RSS

JSFUnit with Glassfish 3.0.1 is not working

Nadine Abdel Hamid Newbie

Hi,

 

I'm trying to use JSFUnit, but it's getting me 404 error page

 

I'm using JSF2.0, Glassfish 3.0.01 and primefaces 2.1

 

According to what is mentioned in http://community.jboss.org/wiki/UsingJSFUnitwithServlet30 and http://labs.jboss.com/jsfunit/gettingstarted.html, all what I had to do to get my tests run is to actually to write my test , and put the required jars.

 

I didn't need to modify my web.xml or include cactus-report.xsl in my app as I'm using Glassfish V3 JEE6

 

I tried to run through the browser using: http://localhost:8080/mywebapp/jsfunit, but it's getting me 404

I tried to run it form eclipse, it's getting me the following exception

 

org.apache.cactus.util.ChainedRuntimeException: Failed to get the test results at [http://localhost:8080/eldaftar/ServletRedirector]
at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody0(DefaultHttpClient.java:92)
at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody1$advice(DefaultHttpClient.java:288)
at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest(DefaultHttpClient.java)
at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runWebTest(HttpProtocolHandler.java:159)
at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest_aroundBody0(HttpProtocolHandler.java:80)
at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest_aroundBody1$advice(HttpProtocolHandler.java:288)
at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest(HttpProtocolHandler.java)
at org.apache.cactus.internal.client.ClientTestCaseCaller.runTest(ClientTestCaseCaller.java:144)
at org.apache.cactus.internal.AbstractCactusTestCase.runBareClient(AbstractCactusTestCase.java:215)
at org.apache.cactus.internal.AbstractCactusTestCase.runBare(AbstractCactusTestCase.java:133)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
org.apache.cactus.internal.client.ParsingException: Not a valid response [302 Moved Temporarily]
at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.callGetResult(DefaultHttpClient.java:211)
at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody0(DefaultHttpClient.java:87)
at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody1$advice(DefaultHttpClient.java:288)
at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest(DefaultHttpClient.java)
at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runWebTest(HttpProtocolHandler.java:159)
at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest_aroundBody0(HttpProtocolHandler.java:80)
at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest_aroundBody1$advice(HttpProtocolHandler.java:288)
at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest(HttpProtocolHandler.java)
at org.apache.cactus.internal.client.ClientTestCaseCaller.runTest(ClientTestCaseCaller.java:144)
at org.apache.cactus.internal.AbstractCactusTestCase.runBareClient(AbstractCactusTestCase.java:215)
at org.apache.cactus.internal.AbstractCactusTestCase.runBare(AbstractCactusTestCase.java:133)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

 

 

Any help?

  • 1. Re: JSFUnit with Glassfish 3.0.1 is not working
    Stan Silvert Master

    For the 404 error, it sounds like the filter and servlet declarations were not auto-added by Servlet 3.0.  As it states in the Using JSFUnit with Servlet 3.0, you need all three of the following:

     

    • Use a Servlet 3.0 container
    • Use the Servlet 2.5 or Servlet 3.0 deployment descriptor in your web.xml.
    • Do not set metadata-complete=true

     

    Sounds like you are using Servlet 3.0.  Double-check the other two.

     

    Also, check the server log for errors.  If you still can't figure it out please post the full 404 stack trace and your WAR.

     

    Regards,

     

    Stan

  • 2. Re: JSFUnit with Glassfish 3.0.1 is not working
    Stan Silvert Master

    Nadine Abdel Hamid wrote:

     


     

    I tried to run through the browser using: http://localhost:8080/mywebapp/jsfunit, but it's getting me 404

    I tried to run it form eclipse, it's getting me the following exception

     

    org.apache.cactus.util.ChainedRuntimeException: Failed to get the test results at [http://localhost:8080/eldaftar/ServletRedirector]
    at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody0(DefaultHttpClient.java:92)

    BTW, "mywebapp" is just a place holder.  In your case to access the JSFUnit Console you would need to say:

     

    http://localhost:8080/eldaftar/jsfunit

     

    Maybe that wasn't clear from the documentation?

     

    Stan

  • 3. Re: JSFUnit with Glassfish 3.0.1 is not working
    Nadine Abdel Hamid Newbie

    yes I have already put my context root.

    Kindly find attached the war

    I'm using JSF 2.0, GlassFish 3.0

    and the url I'm using is http://localhost:8080/test/jsfunit

  • 4. Re: JSFUnit with Glassfish 3.0.1 is not working
    Stan Silvert Master

    I got your WAR to work on JBoss AS6 M3.  You need to add something to the URL:

    http://localhost:8080/test/jsfunit/index.jsfunit

     

    I need to take a closer look at this because the abbreviated version of the URL doesn't work unless you have index.html in your welcome file section of web.xml.

     

    Also, I noticed that you are using the wrong htmlunit version.  You need to update some of your jars to go with JSFUnit 1.3.0.Final.  Take a look at the getting started page for the complete list.

    http://www.jboss.org/jsfunit/gettingstarted.html

     

    Stan

  • 5. Re: JSFUnit with Glassfish 3.0.1 is not working
    Nadine Abdel Hamid Newbie

    Thanks Stan for your answer,  I have updated my jars now and still it's not working!

     

    But when I adjusted web.xml by adding jsfunit servlets and the cactus-report.xsl and referred to

    http://localhost:8080/test/ServletTestRunner?suite=test.JSFUnitTest&xsl=cactus-report.xsl

    And added the jars to the server lib directory, It worked but gave me another exception

     

    testLoginPageErrororg/apache/commons/httpclient/HttpMethod

     

    java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod
    at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.callRunTest(DefaultHttpClient.java:158)
    at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody0(DefaultHttpClient.java:80)
    at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody1$advice(DefaultHttpClient.java:288)
    at org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest(DefaultHttpClient.java)
    at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runWebTest(HttpProtocolHandler.java:159)
    at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest_aroundBody0(HttpProtocolHandler.java:80)
    at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest_aroundBody1$advice(HttpProtocolHandler.java:288)
    at org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest(HttpProtocolHandler.java)
    at org.apache.cactus.internal.client.ClientTestCaseCaller.runTest(ClientTestCaseCaller.java:144)
    at org.apache.cactus.internal.AbstractCactusTestCase.runBareClient(AbstractCactusTestCase.java:215)
    at org.apache.cactus.internal.AbstractCactusTestCase.runBare(AbstractCactusTestCase.java:133)
    at org.apache.cactus.server.runner.ServletTestRunner.run(ServletTestRunner.java:308)
    at org.apache.cactus.server.runner.ServletTestRunner.doGet_aroundBody0(ServletTestRunner.java:186)
    at org.apache.cactus.server.runner.ServletTestRunner.doGet_aroundBody1$advice(ServletTestRunner.java:217)
    at org.apache.cactus.server.runner.ServletTestRunner.doGet(ServletTestRunner.java)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
    at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.HttpMethod
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

     

    I have two questions now

    1) How to solve this exeption?

     

    2) Why did I got it working as if I'm not using Servlet 3.0 Container?

    I'm using GlassFish 3  Java EE 6, isn't that considered Servlet 3.0 Container

    and also my web.xml is defining the usage of Servlet 3.0

    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">

    maybe it's something server specific, but at least am I right to get confused?

  • 6. Re: JSFUnit with Glassfish 3.0.1 is not working
    Stan Silvert Master

    I just found an error on the getting started page.  HtmlUnit needs the new httpclient 4.0.1.  But Cactus is still using commons-httpclient 2.0.2.  So you need both.  I never saw this problem because I was using Maven to automatically resolve the dependencies.

     

    The reason you got it working as if you were not using Servlet 3.0 is because JSFUnit still works outside the JSFUnit console.  If you use Servlet 3.0 then the filters and servlets needed by JSFUnit and Cactus are automatically added at deploy time.  So the two advantages of Servlet 3.0 with JSFUnit are:

    • You don't need to change your WEB-INF/web.xml
    • You can use the JSFUnit console

     

    But everything still works the old way.

     

    Stan

  • 7. Re: JSFUnit with Glassfish 3.0.1 is not working
    Stan Silvert Master

    Also, 500 Internal Server Error where I have attached a WAR that works with Glassfish 3.0.1.

     

    Stan