1 Reply Latest reply: Apr 9, 2012 5:33 PM by u j RSS

    JSFUnit 2.0.0.Beta3-SNAPSHOT error including javascript files

    Luis Fernandez Newbie

      Hi all!

       

      I'm evaluating JSFUnit framework to test our build Jsf webapps.

       

      We have found it very usefull and helpfull but then there's that little error that

      happens when a javascript file is included inside a jsf page.

       

      I just added inside the index.xhtml the following lines (in the arquillian-hellojsf project):

       

       

      <head>

            <script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/js/hello.js"></script>

      </head>

       

       

      When executing the test with an embedded tomcat it just throws the error:

       

      com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException:

      404 Not Found for http://localhost:8080/01c34205-2186-4e9e-bd36-d6986d17b9a2/js/hello.js

       

      When executing the initial page it can't find the js file.

       

      Researching for the problem, It seems that the htmlunit framework has some problems when executing the request and

      getting the js files included. Some workaround to solve the problem is to

      override the webclient request call and return a status OK when requesting js files, done with a subclass of

      SimpleInitialRequestStrategy and overriding the method Page doInitialRequest.

      When trying this approach inside JsfUnit, it seems that the request call is done before the subclass of

      SimpleInitialRequestStrategy is executing, so the code inside Page doInitialRequest is never executed,

      resulting in the same 404 Not Found error.

       

      Anybody can point me another workaround to solve the js files included in the jsf pages?

       

      Thanks!

       

       

       

       

       

       


        • 1. Re: JSFUnit 2.0.0.Beta3-SNAPSHOT error including javascript files
          u j Novice

          Hi,

           

          I face a similar problem, have you found any solution?

          I use RichFaces 4.1.0.

           

          On the server console appears:

           

          17:56:08,454 INFO  [org.jboss.as.server] (management-handler-thread - 51) JBAS018559: Deployed "test.war"

          17:56:35,562 WARN  [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] (http-localhost-127.0.0.1-8080-3) Obsolete content type encountered: 'text/javascript'.

          17:56:36,670 WARN  [com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument] (http-localhost-127.0.0.1-8080-3) getElementById(script1334004996666) did a getElementByName for Internet Explorer

          17:56:36,692 ERROR [com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter] (http-localhost-127.0.0.1-8080-3) runtimeError: message=[The data necessary to complete this operation is not yet available.] sourceName=[http://127.0.0.1:8080/test/javax.faces.resource/jquery.js.jsf] line=[945] lineSource=[null] lineOffset=[0]

          17:56:44,581 WARN  [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] (http-localhost-127.0.0.1-8080-3) Obsolete content type encountered: 'text/javascript'.

          17:56:44,635 INFO  [com.gargoylesoftware.htmlunit.WebClient] (http-localhost-127.0.0.1-8080-3) statusCode=[404] contentType=[text/html]

           

          and on the test log:

           

          java.lang.RuntimeException: Could not inject method parameters

              at org.jboss.jsfunit.arquillian.container.JSFUnitTestEnricher.resolve(JSFUnitTestEnricher.java:89)

              at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.enrichArguments(LocalTestExecuter.java:94)

              at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60)

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

              at java.lang.reflect.Method.invoke(Method.java:597)

              at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

              at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

              at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

              at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

              at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)

              at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)

              at org.jboss.arquillian.container.test.impl.execution.ContainerTestExecuter.execute(ContainerTestExecuter.java:38)

          ...

          Caused by: com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException: 404 Not Found for http://127.0.0.1:8080/test/RES_NOT_FOUND

              at com.gargoylesoftware.htmlunit.WebClient.throwFailingHttpStatusCodeExceptionIfNecessary(WebClient.java:531)

              at com.gargoylesoftware.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:1007)

              at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:959)

              at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:363)

              at com.gargoylesoftware.htmlunit.html.HtmlScript$1.execute(HtmlScript.java:225)

              at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:245)

              at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:578)

              at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)

              at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:536)

              at org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1136)

              at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1038)

              at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:206)

              at org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:329)

              at org.cyberneko.html.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:2999)

              at org.cyberneko.html.HTMLScanner$ContentScanner.scan(HTMLScanner.java:1991)

              at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:895)

              at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:499)

              at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:452)

              at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)

              at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:765)

              at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:211)

              at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:165)

              at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:225)

              at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:108)

              at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:429)

              at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:307)

              at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:369)

              at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:354)

              at org.jboss.jsfunit.framework.SimpleInitialRequestStrategy.doInitialRequest(SimpleInitialRequestStrategy.java:48)

              at org.jboss.jsfunit.framework.WebClientSpec.doInitialRequest(WebClientSpec.java:259)

              at org.jboss.jsfunit.jsfsession.JSFSession.<init>(JSFSession.java:81)

              at org.jboss.jsfunit.arquillian.container.JSFUnitSessionFactory.createJSFSession(JSFUnitSessionFactory.java:107)

              at org.jboss.jsfunit.arquillian.container.JSFUnitSessionFactory.findJSFSession(JSFUnitSessionFactory.java:92)

              at org.jboss.jsfunit.arquillian.container.JSFUnitSessionFactory.getJSFServerSession(JSFUnitSessionFactory.java:70)

              at org.jboss.jsfunit.arquillian.container.JSFUnitTestEnricher.resolve(JSFUnitTestEnricher.java:84)

              ... 103 more