10 Replies Latest reply on Mar 19, 2002 10:10 AM by Blandger

    Help pls to start working with J2EEUnit on Jboss3.0b   TomCa

    Blandger Newbie

      Hi all.

      We use that well known J2EEunit bundle in the EAR application for server side components testing on the WS 4.0 without problem but I can't start working with it on the JBoss 3.0 b TomCat 4.0.2.
      That bundle gives ability to run test in the browser window and see results.

      May be it doesn't work because it uses reflect API and something wrong with it in JBoss, may be servlet for test running should be rewritten...? Give me a clue, pls.

      It doesn't work neither in the EAR not in the separate WAR (WAR is preffered case).

      I attached my WAR with junit libs and simple test.
      War is mapped to /test. Test class name is com.EmptyTestCase.

      It's boring to test components, EJBs in the WS as it doesn't have hot-deploy so I'd like to use JBoss.

      Thanks for any help.

        • 1. Re: Help pls to start working with J2EEUnit on Jboss3.0b   T
          Blandger Newbie

          A little addition - no errors in the log,.
          Only HTTP 404 ...
          The requested resource (/test) is not available.
          :(

          • 2. Re: Help pls to start working with J2EEUnit on Jboss3.0b   T
            Adrian Brock Master

            I just tried it with Jetty and latest CVS

            I had to change action="test" to
            action="servlet/JUnitEETestServlet" to get it to work.

            Regards,
            Adrian

            • 3. Re: Help pls to start working with J2EEUnit on Jboss3.0b   T
              Blandger Newbie

              Thanks Adrian.. but still without success :(

              May be that is because I have error on deployment.
              I changed war name to junit.war, mapped it as you tried.

              16:45:02,029 INFO [MainDeployer] Deploying: file:/C:/Jboss/deploy/junit.war
              16:45:02,119 INFO [EmbeddedCatalinaServiceSX] deploy, ctxPath=/junit, warUrl=file:/C:/Jboss/tmp/deploy/95.jun
              it.war
              16:45:05,785 INFO [EmbeddedCatalinaServiceSX] WebappLoader[/junit]: Deploying class repositories to work dire
              ctory C:\Jboss\jakarta-tomcat-4.0.2\work\localhost\junit
              16:45:05,875 INFO [EmbeddedCatalinaServiceSX] StandardManager[/junit]: Seeding random number generator class
              java.security.SecureRandom
              16:45:05,895 INFO [EmbeddedCatalinaServiceSX] StandardManager[/junit]: Seeding of random number generator has
              been completed
              16:45:06,376 INFO [EmbeddedCatalinaServiceSX] ContextConfig[/junit]: Missing application web.xml, using defau
              lts only
              16:45:06,816 INFO [EmbeddedCatalinaServiceSX] ContextConfig[/junit]: Added certificates -> request attribute
              Valve
              16:45:06,836 WARN [EmbeddedCatalinaServiceSX] No /WEB-INF/web.xml descriptor found
              16:45:06,866 INFO [EmbeddedCatalinaServiceSX] StandardWrapper[/junit:default]: Loading container servlet defa
              ult
              16:45:08,739 INFO [EmbeddedCatalinaServiceSX] default: init
              16:45:08,759 INFO [EmbeddedCatalinaServiceSX] StandardWrapper[/junit:invoker]: Loading container servlet invo
              ker
              16:45:09,050 INFO [EmbeddedCatalinaServiceSX] invoker: init
              16:45:09,190 INFO [EmbeddedCatalinaServiceSX] jsp: init
              16:45:10,071 INFO [EmbeddedCatalinaServiceSX] Internal Error: File /WEB-INF/web.xml not found
              16:45:10,953 INFO [MainDeployer] Deploying: file:/C:/Jboss/deploy/jbossmq-state.xml
              16:45:10,963 INFO [MainDeployer] Deploying: file:/C:/Jboss/deploy/jboss.jcml
              16:45:11,023 INFO [MainDeployer] deploying non-jar/xml file: file:/C:/Jboss/deploy/jboss.jcml
              16:45:11,203 INFO [MainDeployer] Started

              But I can't find difference between tomcat-test.war
              I dropped it to /deploy and see:

              16:49:09,892 INFO [MainDeployer] Deploying: file:/C:/Jboss/deploy/tomcat-test.war
              16:49:09,912 INFO [EmbeddedCatalinaServiceSX] deploy, ctxPath=/tomcat-test, warUrl=file:/C:/Jboss/tmp/deploy/
              98.tomcat-test.war
              16:49:09,952 INFO [EmbeddedCatalinaServiceSX] WebappLoader[/tomcat-test]: Deploying class repositories to wor
              k directory C:\Jboss\jakarta-tomcat-4.0.2\work\localhost\tomcat-test
              16:49:09,972 INFO [EmbeddedCatalinaServiceSX] WebappLoader[/tomcat-test]: Deploy class files /WEB-INF/classes
              to C:\Jboss\jakarta-tomcat-4.0.2\work\localhost\tomcat-test\WEB-INF\classes
              16:49:10,323 INFO [EmbeddedCatalinaServiceSX] StandardManager[/tomcat-test]: Seeding random number generator
              class java.security.SecureRandom
              16:49:10,333 INFO [EmbeddedCatalinaServiceSX] StandardManager[/tomcat-test]: Seeding of random number generat
              or has been completed
              16:49:10,603 INFO [EmbeddedCatalinaServiceSX] ContextConfig[/tomcat-test]: Added certificates -> request attr
              ibute Valve
              16:49:32,206 ERROR [XmlFileLoader] External entity not found: "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd".
              :-1:5
              java.net.NoRouteToHostException: Operation timed out: connect
              at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3108)
              ....
              16:49:32,316 INFO [EmbeddedCatalinaServiceSX] StandardWrapper[/tomcat-test:default]: Loading container servle
              t default
              16:49:32,316 INFO [EmbeddedCatalinaServiceSX] default: init
              16:49:32,316 INFO [EmbeddedCatalinaServiceSX] StandardWrapper[/tomcat-test:invoker]: Loading container servle
              t invoker
              16:49:32,316 INFO [EmbeddedCatalinaServiceSX] invoker: init
              16:49:32,336 INFO [EmbeddedCatalinaServiceSX] jsp: init

              It seems what it's OK !
              In my jboss.jcml I have connector.

              >




              After

              What I doing wrong. I can't understand ?

              Regards.

              • 4. Re: Help pls to start working with J2EEUnit on Jboss3.0b   T
                Adrian Brock Master

                Try removing the dtd from web.xml
                If you are not connected to the net, it cannot find it.

                Regards,
                Adrian

                • 5. Re: Help pls to start working with J2EEUnit on Jboss3.0b   T
                  Blandger Newbie

                  I can't understand that staff.
                  When Jboss deploys my junit.war

                  18:34:21,310 INFO [MainDeployer] Deploying: file:/C:/Jboss/deploy/junit.war
                  18:34:21,560 INFO [EmbeddedCatalinaServiceSX] deploy, ctxPath=/junit, warUrl=file:/C:/Jboss/tmp/deploy/95.jun
                  it.war
                  18:34:25,286 INFO [EmbeddedCatalinaServiceSX] WebappLoader[/junit]: Deploying class repositories to work dire
                  ctory C:\Jboss\jakarta-tomcat-4.0.2\work\localhost\junit
                  18:34:25,396 INFO [EmbeddedCatalinaServiceSX] StandardManager[/junit]: Seeding random number generator class java.security.SecureRandom
                  18:34:25,456 INFO [EmbeddedCatalinaServiceSX] StandardManager[/junit]: Seeding of random number generator has been completed
                  18:34:26,017 INFO [EmbeddedCatalinaServiceSX] ContextConfig[/junit]: Missing application web.xml, using defaults only
                  18:34:26,437 INFO [EmbeddedCatalinaServiceSX] ContextConfig[/junit]: Added certificates -> request attribute Valve
                  18:34:26,437 WARN [EmbeddedCatalinaServiceSX] No /WEB-INF/web.xml descriptor found
                  18:34:26,457 INFO [EmbeddedCatalinaServiceSX] StandardWrapper[/junit:default]: Loading container servlet default
                  18:34:28,300 INFO [EmbeddedCatalinaServiceSX] default: init
                  18:34:28,320 INFO [EmbeddedCatalinaServiceSX] StandardWrapper[/junit:invoker]: Loading container servlet invoker
                  18:34:28,430 INFO [EmbeddedCatalinaServiceSX] invoker: init
                  18:34:28,591 INFO [EmbeddedCatalinaServiceSX] jsp: init
                  18:34:29,452 INFO [EmbeddedCatalinaServiceSX] Internal Error: File /WEB-INF/web.xml not found

                  When it deploys tomcat-test.jar

                  18:34:30,343 INFO [MainDeployer] Deploying: file:/C:/Jboss/deploy/tomcat-test.war
                  18:34:30,373 INFO [EmbeddedCatalinaServiceSX] deploy, ctxPath=/tomcat-test, warUrl=file:/C:/Jboss/tmp/deploy/
                  96.tomcat-test.war
                  18:34:30,393 INFO [EmbeddedCatalinaServiceSX] WebappLoader[/tomcat-test]: Deploying class repositories to work directory C:\Jboss\jakarta-tomcat-4.0.2\work\localhost\tomcat-test
                  18:34:30,423 INFO [EmbeddedCatalinaServiceSX] WebappLoader[/tomcat-test]: Deploy class files /WEB-INF/classes to C:\Jboss\jakarta-tomcat-4.0.2\work\localhost\tomcat-test\WEB-INF\classes
                  18:34:30,814 INFO [EmbeddedCatalinaServiceSX] StandardManager[/tomcat-test]: Seeding random number generator class java.security.SecureRandom
                  18:34:30,814 INFO [EmbeddedCatalinaServiceSX] StandardManager[/tomcat-test]: Seeding of random number generator has been completed
                  18:34:31,104 INFO [Default] PARSE error at line 2 column -1
                  18:34:31,104 INFO [Default] org.xml.sax.SAXParseException: Element type "web-app" is not declared.
                  18:34:31,134 ERROR [EmbeddedCatalinaServiceSX] ContextConfig[/tomcat-test] Parse error in application web.xml
                  org.xml.sax.SAXParseException: Element type "web-app" is not declared.
                  at org.apache.crimson.parser.Parser2.error(Parser2.java:3086)
                  at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1316)
                  ....

                  at org.jboss.system.Server.(Server.java:157)
                  at org.jboss.Main.boot(Main.java:263)
                  at org.jboss.Main.run(Main.java:48)
                  at java.lang.Thread.run(Thread.java:484)
                  18:34:31,215 INFO [EmbeddedCatalinaServiceSX] ContextConfig[/tomcat-test]: Occurred at line 2 column -1
                  18:34:31,215 INFO [EmbeddedCatalinaServiceSX] ContextConfig[/tomcat-test]: Marking this application unavailable due to previous error(s)
                  18:34:31,705 INFO [EmbeddedCatalinaServiceSX] StandardContext[/tomcat-test]: Context startup failed due to previous errors

                  They are really different.. but where ?
                  :(

                  • 6. Re: Help pls to start working with J2EEUnit on Jboss3.0b   T
                    Blandger Newbie

                    Sorry.. correction
                    "When it deploys tomcat-test.jar" should be - When it deploys tomcat-test.war

                    • 7. Re: Help pls to start working with J2EEUnit on Jboss3.0b   T
                      Adrian Brock Master

                      Now I'm confused

                      In your original example you had the web.xml below.
                      At some point you changed the "DOCTYPE" to reference
                      www.java.sun.com

                      But that obviously failed because you are not
                      connected the net (probably a proxy in the way?)
                      I told you to remove the java.sun.com reference.

                      I'm not sure what you have done now?

                      What is tomcat-test.war, where did that come from?

                      [pre]
                      <?xml version="1.0" encoding="UTF-8"?>
                      <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
                      "file:///c:/dtds/web-app_2_3.dtd">
                      <web-app>

                      <servlet-name>JUnitEETestServlet</servlet-name>
                      <servlet-class>
                      junit.htmlui.TestServlet
                      </servlet-class>

                      </web-app>
                      [/pre]
                      Regards,
                      Adrian

                      • 8. Re: Help pls to start working with J2EEUnit on Jboss3.0b   T
                        Blandger Newbie

                        Hi Adrian.
                        Ok I'll try to make it clear.

                        At the beginning I had my junit.war with DOCTYPE pointing to the local dtd file and tomcat-test.war with DOCTYPE pointing to the htpp://sun... The tomcat-test.war is came from tomcat-test.ear (JBoss 2.4.4 + TomCat).
                        At this point my junit.war deploys with error
                        "Internal Error: File /WEB-INF/web.xml not found"
                        but tomcat-test.war deploys with
                        "External entity not found: "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd".
                        :-1:5 java.net.NoRouteToHostException: Operation timed out" due to my local proxy. I think that error doesn't influence to the deployement because further it's ok.

                        Second try. I followed your advice "Try removing the dtd from web.xml".
                        I've removed reference from both WARs web.xml and get last different errors. In the junit.jar error is the same - "Internal Error: File /WEB-INF/web.xml not found". but in the tomcat-test.war parsing error - " org.xml.sax.SAXParseException: Element type "web-app" is not declared."

                        So I can't understand difference between that WARs.
                        Thank you Adrian.
                        Regards.

                        • 9. Re: Help pls to start working with J2EEUnit on Jboss3.0b   T
                          Adrian Brock Master

                          Hi,

                          For tomcat-test.war, I don't think this will be much
                          by itself. It needs to be installed as part of an
                          ear because it references ejbs in tomcat-test.jar

                          For your war, can your /WEB-INF/web.xml back
                          to what is posted above. i.e. it references the
                          dtd on your machine (avoiding the http connection problem).

                          If this still doesn't work, can you post
                          jar -tf junit.war

                          One common mistake is not putting it in the root,
                          e.g. it gets packaged in the war as something like

                          /development-directory/WEB-INF/web.xml

                          Regards,
                          Adrian

                          • 10. Re: Help pls to start working with J2EEUnit on Jboss3.0b   T
                            Blandger Newbie

                            Hi Adrian.
                            Finally I've found my problem.

                            The key difference between this two WARs can be seen in the log.

                            Working WAR generates log like this:

                            18:34:30,373 INFO [EmbeddedCatalinaServiceSX] deploy, ctxPath=/tomcat-test, warUrl=file:/C:/Jboss/tmp/deploy/
                            96.tomcat-test.war
                            18:34:30,393 INFO [EmbeddedCatalinaServiceSX] WebappLoader[/tomcat-test]: Deploying class repositories to work directory C:\Jboss\jakarta-tomcat-4.0.2\work\localhost\tomcat-test
                            18:34:30,423 INFO [EmbeddedCatalinaServiceSX] WebappLoader[/tomcat-test]: Deploy class files /WEB-INF/classes to C:\Jboss\jakarta-tomcat-4.0.2\work\localhost\tomcat-test\WEB-INF\classes

                            18:34:30,814 INFO [EmbeddedCatalinaServiceSX] StandardManager[/tomcat-test]: Seeding random number generator class java.security.SecureRandom

                            It uploads WEB-INF/classes... into Catalina directory.

                            My WAR didn't upload file to Catalina and didn't generate this lines.

                            18:34:25,286 INFO [EmbeddedCatalinaServiceSX] WebappLoader[/junit]: Deploying class repositories to work directory C:\Jboss\jakarta-tomcat-4.0.2\work\localhost\junit
                            18:34:25,396 INFO [EmbeddedCatalinaServiceSX] StandardManager[/junit]: Seeding random number generator class java.security.SecureRandom

                            It doesn't upload classes to the Catalina.
                            I my case the reason was.. It seems to me what I could use different archive program for packaging WAR but not a JAR utility. An "old not working" junit.war had 118,7 Kb size but "new working" WAR has 119.2 Kb. The difference is very little but obviously it's due to different utility (PKZIP).
                            I don't know is it considered as a bug or not.

                            Also I tried to remove reference to the DTD from web.xml. Jboss + TomCat generates parsing error. I dont' know is it bug or not. It seems to me what user should have ability to remove DTD reference.

                            As a little contribution, I could attach working JUnitEE web app - junit.war, but "Attach file and post message" button on the attach JSP doesn't work for me.
                            If somebody want to get it you can mail me and I'll try to attach it later in that thread.

                            There is one empty test case is included inside for tesing purpose.
                            After installation you can try http://localhost:8080/junit/
                            then in the text field type test case name - com.EmptyTestCase, hit Run button and see successful test result.

                            Thank you Adrian. You are like a mami for us. :)