1 2 Previous Next 20 Replies Latest reply on Jul 16, 2008 8:19 PM by jinpsu

    Unable To Get Started With Ant Task

      I am new to JSFUnit and just trying to get the Ant task to bundle the right kind of war file. Unfortunately, I get this error:

      Automatically adding JSFunit required jars to the new war
      Could not find the JSFUnit jar in the classpath. Cannot automatically add this jar to the war
      Could not find the AspectJ jar in the classpath. Cannot automatically add this jar to the war
      Could not find the Cactus jar in the classpath. Cannot automatically add this jar to the war
      Could not find the HttpUnit jar in the classpath. Cannot automatically add this jar to the war
      Could not find the JUnit jar in the classpath. Cannot automatically add this jar to the war
      Could not find the NekoHTML jar in the classpath. Cannot automatically add this jar to the war
      Could not find the JTidy jar in the classpath. Cannot automatically add this jar to the war
      


      Here is the relevant portion of my build file:
      <property name="jsfunit.ant.jar" location="${jsfunit.lib.dir}/jboss-jsfunit-ant-1.0.0.Beta2.jar"/>
       <property name="aspectjrt.jar" location="${jsfunit.lib.dir}/aspectjrt-1.2.1.jar"/>
       <property name="jsfunit.jar" location="${jsfunit.lib.dir}/jboss-jsfunit-core-1.0.0.Beta2.jar"/>
       <property name="cactus.jar" location="${jsfunit.lib.dir}/cactus-13-1.7.1.jar"/>
       <property name="cactus.ant.jar" location="${jsfunit.lib.dir}/cactus-13-1.7.1.jar"/>
       <property name="httpunit.jar" location="${jsfunit.lib.dir}/httpunit-1.6.1.jar"/>
       <property name="junit.jar" location="${jsfunit.lib.dir}/junit-3.8.1.jar"/>
       <property name="jtidy.jar" location="${jsfunit.lib.dir}/jtidy-4aug2000r7-dev.jar"/>
       <property name="cargo.jar" location="${jsfunit.lib.dir}/cargo-core-uberjar-0.9.jar"/>
       <path id="jsfunit.class.path.libs">
       <fileset dir="${jsfunit.lib.dir}">
       <include name="*.jar"/>
       </fileset>
       </path>
       <target name="build-jsfunit-war">
       <ant antfile="build-war.xml" target="war-for-dev"/>
       <jsfunitwar srcfile="${dist.dir}/srm.war"
       destfile="${dist.dir}/srm-jsfunit.war">
       <!--<TestRunner/>-->
       </jsfunitwar>
       </target>
      


      The directory jsfunit.lib.dir does indeed point to the right location. As you can see, I have even commented out the TestRunner task. What does that do anyway?

      Any insight into the issue is much appreciated.

      Thanks.

        • 1. Re: Unable To Get Started With Ant Task
          kragoth

          You are only missing a tiny part to make this work.

          Take a look at my ant code

          <taskdef
           name="jsfunitwar"
           classname="org.jboss.jsfunit.ant.JSFUnitWarTask"
           classpathref="jsfunit.classpath"/>
          
          <jsfunitwar srcfile="${exploded.dir}"
           destfile="${exploded-jsfunit.dir}">
           <classes dir="${classes.test}"
           includes="**/jsfunit/**/*.class">
           </classes>
           <TestRunner/>
          </jsfunitwar>
          


          All you are missing is the <taskdef .../> part. Once you do this and set the classpathref attribute to the location of all those jars you will be good to go :).

          Hope this helps. Let me know if this doesn't work and I'll have a closer look.



          • 2. Re: Unable To Get Started With Ant Task

            My apoloigies, Kragoth. I actually forgot to include the taskdef in my post, but it was always in my build script as follows:

            <taskdef name="jsfunitwar"
             classname="org.jboss.jsfunit.ant.JSFUnitWarTask"
             classpathref="jsfunit.class.path.libs"/>
            


            So that is there, and the classpathref is right. Yet the Ant task can't find the jars found in jsfunit.class.path.libs, which as I mentioned before is as follows:

             <path id="jsfunit.class.path.libs">
             <fileset dir="${jsfunit.lib.dir}">
             <include name="*.jar"/>
             </fileset>
             </path>
            


            So I am still in need of guidance. I am sure it is something silly, but I do hope to resolve this as soon as poossible.

            Thanks.

            • 3. Re: Unable To Get Started With Ant Task

              I actually had the same problem. The auto add never worked for me. Instead, I turned the auto add feature off and specified the libs I needed to add:

               <jsfunitwar srcfile="${distDir}/${appName}.war"
               destfile="${distDir}/${jsfunitAppName}.war"
               autoAddJars="false">
               <lib dir="${jsfunitlibDir}">
               <include name="*.jar"/>
               </lib>
               <TestRunner/>
               </jsfunitwar>
              


              • 4. Re: Unable To Get Started With Ant Task
                ssilvert

                I opened a jira to track this problem.

                http://jira.jboss.com/jira/browse/JSFUNIT-144

                Stan

                • 5. Re: Unable To Get Started With Ant Task

                  Also note that even if the autoAddJars feature did work, you'd still have problems if you're using the htmlunit version of jsfunit. The list of automatically added jars needs to be updated.

                  justin

                  • 6. Re: Unable To Get Started With Ant Task
                    ssilvert

                     

                    "jinpsu" wrote:
                    Also note that even if the autoAddJars feature did work, you'd still have problems if you're using the htmlunit version of jsfunit. The list of automatically added jars needs to be updated.

                    justin

                    Good point. I'll add that to the jira.

                    Stan

                    • 7. Re: Unable To Get Started With Ant Task

                      Unfortunately, when I try your approach, jinpsu, I get this:


                      Unexpected attribute "autoAddJars"


                      I know I have the latest version of JSFUnit, so I don't know what the issue is.

                      Thanks.

                      • 8. Re: Unable To Get Started With Ant Task

                        Well, I just add the lib child to jsfunitwar and it works. I still get the error messages, but they don't seem to affect anything since the parent war task finds the jars just fine.

                        Thanks.

                        • 9. Re: Unable To Get Started With Ant Task

                          I deployed the output of jsfunitwar to WebLogic, but I got the following exception:

                          javax.servlet.ServletException: [HTTP:101249][weblogic.servlet.internal.WebAppServletContext@17bb286 - appName: 'myapp-jsfunit', name: 'myapp-jsfunit.war', context-path: '/myapp-jsfunit']: Servlet class org.apache.cactus.server.runner.ServletTestRunner for servlet ServletTestRunner could not be loaded because the requested class was not found in the classpath .
                          java.lang.ClassFormatError: org.apache.cactus.server.runner.ServletTestRunner.
                           at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:516)
                           at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:235)
                           at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
                           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
                           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
                           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
                           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
                           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
                           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
                           at org.ajax4jsf.Filter.doFilter(Filter.java:175)
                           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
                           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
                           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
                           at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:122)
                           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
                           at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:26)
                           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
                           at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3243)
                           at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
                           at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
                           at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2003)
                           at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1909)
                           at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1359)
                          


                          I took a look, and I found cactus-13-1.7.1.jar in WEB-INF/lib as it should be.

                          Does anyone have any ideas as to what is going on?

                          Thanks.

                          • 10. Re: Unable To Get Started With Ant Task

                            Well to address the format error, I replaced the cactus jar with the latest from the Cactus website and added other dependencies to get rid of some NoClassDefFoundErrors. I have run jsfunitwar over and over and verified the contents of the generated file are as they should be.

                            When I try to run the test by navigating to the right URL, I get 404 File Not Found errors. I have done this many, many times and find the same issue. These have been just the latest in a long line of failures.

                            I am sure Stan and his team have worked very hard to make JSFUnit a great tool, and I am sure people smarter than I am have gotten it to work for them. However, as much as I want to find an easy-to-use, automatable, and effective integration testing tool for my Seam-JSF app, I am finding JSFUnit (or more precisely, the setup and automation of JSFUnit and even the wiki itself with its broken links to sample war files, etc.) to be very disappointing.

                            Thanks.

                            • 11. Re: Unable To Get Started With Ant Task
                              ssilvert

                              Sorry you are having such trouble. Does the 404 happen on the request to the ServletRunner like this?:
                              http://localhost:8080/myjsfapp/ServletTestRunner?suite=com.foo.JSFUnitTest&xsl=cactus-report.xsl

                              If so, then it means that the URL is not pointing to your web app and you need to change the "myjsfapp" part of the URL. Or, it means that /ServletTestRunner is not properly mapped in your web.xml.

                              If the 404 is happening at some other time then I'm not sure what you are meaning.

                              I'm very much aware that the Ant task needs to be updated. And also, that packaging and deployment in general needs to be easier. Also, Seam support is only half-baked at the moment. Lack of solid Seam support is one of the reasons we're still in beta.

                              So all of your criticisms are valid, but we're addressing them as quickly as possible. On that note, what do you see as "broken" in the wiki? I'm going to go through the entire wiki and update it before GA, but if there is something truly broken then I'll try to address it sooner.

                              Lastly, we actually have a lot of happy users right now and overall I'm very pleased with our progress. Frankly, I'm astounded at the number of developers who are already using JSFUnit in production at this stage in the game. It's still beta, but we are getting closer to GA quality every day.

                              Thanks for your patience,

                              Stan

                              • 12. Re: Unable To Get Started With Ant Task

                                Stan, as you suggested, the 404 happens when I make the request to the ServletRunner just as you described. At first glance, the web.xml looks fine to me, but I will inspect again. Also, this is the web.xml generated by the Ant task, so I would hope it would be correct. I also made sure the app name is correct in the URL.

                                I haven't gone through the whole wiki, but the link that got my attention is this one:

                                http://wiki.jboss.org/wiki-files/attach?page=GettingStartedGuide%2FjsfunitTomcat.war

                                found here: http://wiki.jboss.org/wiki/GettingStartedGuide

                                with the text "For servlet containers that do not include JSF
                                jsfunitTomcat.war works for Tomcat and other servlet containers that do not ship with a JSF implementation. "

                                By the way, what exactly do you mean by Seam support?

                                Incidentally, I totally think JSFUnit has the potential to be a really awesome tool, and I hope I didn't sound too much like a jerk. I want to make it clear that I respect the work you and your team are doing, and I certainly respect just how tough the task is you have chosen to take on. It is just that I have my own client to please, and I have found my initial experience with JSFUnit to be quite frustrating--especially for someone like me who is such a testing freak.

                                Thanks again to you, your team, and the forum.

                                • 13. Re: Unable To Get Started With Ant Task
                                  ssilvert

                                  Thanks for the feedback. It's quite valuable.

                                  It also occurred to me that it might not be finding the cactus-report.xsl file. It expects this to be bundled in the root of your WAR.

                                  By Seam support, I mainly mean the ability to inspect conversation-scoped managed beans. But there are other things I'd like to do to make Seam testing easier.

                                  Stan

                                  • 14. Re: Unable To Get Started With Ant Task

                                    Not sure if this is related to your issue, but I ran into problems with the ant task properly editing web.xml. I found that the ant task was inserting the filters, servlets, and mappings (seemingly) at random throughout the file. For example, filter mappings would be defined before the filter itself and my web app would choke on it.

                                    To get around this, I moved all my existing < filter >, < filter-mapping >, < servlet >, and < servlet-mapping > tags to the top of web.xml. Only then did it seem to correctly modify the file and allow my app to cleanly start up.

                                    I believe the code is using a cargo API to edit web.xml, so it may not even be a jsfunit-specific problem.

                                    Justin.

                                    1 2 Previous Next