1 2 Previous Next 21 Replies Latest reply on Sep 9, 2008 12:27 PM by Scott Stark

    virtualFile.toURL().openStream() does not provide a JarInput

    Carlo de Wolf Master

      This issue has popped again: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=124223&postdays=0&postorder=asc&start=20

      If I have vfszip:a.ear/b.war/WEB-INF/classes and I try to open a JarInputStream on it the first entry is null.

        • 1. Re: virtualFile.toURL().openStream() does not provide a JarI
          Marko Strukelj Master

          Is there a failing test case to go with that?

          Or if you can give me some instructions how to reproduce the problem?

          - marko

          • 2. Re: virtualFile.toURL().openStream() does not provide a JarI
            Adrian Brock Master

            Try either of the following in the JBossAS testsuite:

            ./build.sh one-test -Dtest=org.jboss.test.jpa.test.WebClassesJPAUnitTestCase
            ./build.sh one-test -Dtest=org.jboss.test.jpa.test.WebClassesEARJPAUnitTestCase
            


            The annotated entities are found when they are packaged in WEB-INF/lib/*.jar

            ./build.sh one-test -Dtest=org.jboss.test.jpa.test.WebLibsJPAUnitTestCase
            ./build.sh one-test -Dtest=org.jboss.test.jpa.test.WebLibsEARJPAUnitTestCase
            



            • 3. Re: virtualFile.toURL().openStream() does not provide a JarI
              Carlo de Wolf Master

              Basically all JPA implementations expect the URL to point to a jar, so anything packed in a jar will work.

              The trickery is in the fact that they all interpret jar:mywar.war!/WEB-INF/classes/ as a special jar url. Where they start at mywar.war and use the rest as the starting point entry for scanning.

              This works if wars in ears are exploded out first (previous VFS). But now doesn't work anymore.

              In which case all JPA implementations fallback to doing:

              new JarInputStream(url.openStream());


              So the vfszip url handler must hook up into that ultimate fallback.

              • 5. Re: virtualFile.toURL().openStream() does not provide a JarI
                Marko Strukelj Master

                I've commited a fix that gets the new test passing. See if it gets TCK tests passing as well.

                Maybe the fix doesn't address the issue completely. I see these two JbossAS tests:

                ./build.sh one-test -Dtest=org.jboss.test.jpa.test.WebLibsJPAUnitTestCase
                ./build.sh one-test -Dtest=org.jboss.test.jpa.test.WebLibsEARJPAUnitTestCase
                


                are passing. But these two:

                ./build.sh one-test -Dtest=org.jboss.test.jpa.test.WebClassesJPAUnitTestCase
                ./build.sh one-test -Dtest=org.jboss.test.jpa.test.WebClassesEARJPAUnitTestCase
                


                are not.

                It's very difficult to get close to the relevant action in this setup (jbossAS testsuite) so I didn't get far getting to the root cause ...

                - marko





                • 6. Re: virtualFile.toURL().openStream() does not provide a JarI
                  Scott Stark Master

                  I'll try the vfs trunk. Basically we just need to be able to iterate through the WEB-INF/classes VirtualFile as a JarInputStream that lists all of the class files. If trunk is not working I'll update the vfs test to further validate what needs to be seen from the JarInputStream.

                  • 7. Re: virtualFile.toURL().openStream() does not provide a JarI
                    Scott Stark Master

                    The jbossas tests are passing:

                    [616][valkyrie: testsuite]$ ant -Dtest=org.jboss.test.jpa.test.WebClassesEARJPAUnitTestCase one-test
                    Buildfile: build.xml
                    
                    one-test:
                     [delete] Deleting: /Users/svn/JBossHead/jboss-head/testsuite/output/log/test.log
                     [junit] Running org.jboss.test.jpa.test.WebClassesEARJPAUnitTestCase
                     [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 2.561 sec
                    
                    BUILD SUCCESSFUL
                    Total time: 6 seconds
                    [617][valkyrie: testsuite]$ ant -Dtest=org.jboss.test.jpa.test.WebClassesJPAUnitTestCase one-test
                    Buildfile: build.xml
                    
                    one-test:
                     [delete] Deleting: /Users/svn/JBossHead/jboss-head/testsuite/output/log/test.log
                     [junit] Running org.jboss.test.jpa.test.WebClassesJPAUnitTestCase
                     [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.729 sec
                    
                    BUILD SUCCESSFUL
                    


                    but the tck tests are not. I updated the vfs test, and it is missing a few of the war entries:

                    junit.framework.AssertionFailedError: No missing entries: [WEB-INF/jboss-web.xml, META-INF/MANIFEST.MF, WEB-INF/, WEB-INF/web.xml] expected:<0> but was:<4>
                     at junit.framework.Assert.fail(Assert.java:47)
                     at junit.framework.Assert.failNotEquals(Assert.java:282)
                     at junit.framework.Assert.assertEquals(Assert.java:64)
                     at junit.framework.Assert.assertEquals(Assert.java:201)
                     at org.jboss.test.virtual.test.JARVFSContextUnitTestCase.testWarClassesJarInputStream(JARVFSContextUnitTestCase.java:314)
                    

                    The jpa layer I doubt is looking at these, but I don't know. I need to debug the tck test failure further.


                    • 8. Re: virtualFile.toURL().openStream() does not provide a JarI
                      Scott Stark Master

                      I don't know why, but in the tck test the first read of the jar input stream is failing with an EOFException so its still not seeing any of the classes to scan for entities.

                      • 9. Re: virtualFile.toURL().openStream() does not provide a JarI
                        Scott Stark Master

                        Note I updated the vfs test to use a src/test/resources/vfs/test/web_pkg_scope.ear from the vfs project itself. To change the ear edit the vfs/archives/web_pkg_scope maven projects and then you can generate the web_pkg_scope.ear by doing mvn package from archives/web_pkg_scope:

                        [558][valkyrie: web_pkg_scope]$ mvn package
                        [INFO] Scanning for projects...
                        [INFO] Reactor build order:
                        [INFO] web_pkg_scope parent
                        [INFO] web_pkg_scope war
                        [INFO] web_pkg_scope ear
                        [INFO] ------------------------------------------------------------------------
                        [INFO] Building web_pkg_scope parent
                        [INFO] task-segment: [package]
                        [INFO] ------------------------------------------------------------------------
                        [INFO] [site:attach-descriptor]
                        [INFO] ------------------------------------------------------------------------
                        [INFO] Building web_pkg_scope war
                        [INFO] task-segment: [package]
                        [INFO] ------------------------------------------------------------------------
                        [INFO] [resources:resources]
                        [INFO] Using default encoding to copy filtered resources.
                        [INFO] [compiler:compile]
                        [INFO] Compiling 2 source files to /Users/svn/JBossAS/projects/vfs/trunk/archives/web_pkg_scope/war/target/classes
                        [INFO] [resources:testResources]
                        [INFO] Using default encoding to copy filtered resources.
                        [INFO] [compiler:testCompile]
                        [INFO] No sources to compile
                        [INFO] [surefire:test]
                        [INFO] No tests to run.
                        [INFO] [war:war]
                        [INFO] Packaging webapp
                        [INFO] Assembling webapp[web_pkg_scope_web] in [/Users/svn/JBossAS/projects/vfs/trunk/archives/web_pkg_scope/war/target/web_pkg_scope_web]
                        [INFO] Processing war project
                        [INFO] Webapp assembled in[52 msecs]
                        [INFO] Building war: /Users/svn/JBossAS/projects/vfs/trunk/archives/web_pkg_scope/war/target/web_pkg_scope_web.war
                        [INFO] ------------------------------------------------------------------------
                        [INFO] Building web_pkg_scope ear
                        [INFO] task-segment: [package]
                        [INFO] ------------------------------------------------------------------------
                        [INFO] [ear:generate-application-xml]
                        [INFO] Generating application.xml
                        [INFO] [resources:resources]
                        [INFO] Using default encoding to copy filtered resources.
                        [INFO] [ear:ear]
                        [INFO] Copying artifact[war:org.jboss.vfs:web_pkg_scope_web:1.0-SNAPSHOT] to[web_pkg_scope_web.war]
                        [INFO] Could not find manifest file: /Users/svn/JBossAS/projects/vfs/trunk/archives/web_pkg_scope/ear/src/main/application/META-INF/MANIFEST.MF - Generating one
                        [INFO] Building jar: /Users/svn/JBossAS/projects/vfs/trunk/archives/web_pkg_scope/ear/target/web_pkg_scope.ear
                        [INFO]
                        [INFO]
                        [INFO] ------------------------------------------------------------------------
                        [INFO] Reactor Summary:
                        [INFO] ------------------------------------------------------------------------
                        [INFO] web_pkg_scope parent .................................. SUCCESS [2.141s]
                        [INFO] web_pkg_scope war ..................................... SUCCESS [1.710s]
                        [INFO] web_pkg_scope ear ..................................... SUCCESS [0.442s]
                        [INFO] ------------------------------------------------------------------------
                        [INFO] ------------------------------------------------------------------------
                        [INFO] BUILD SUCCESSFUL
                        [INFO] ------------------------------------------------------------------------
                        [INFO] Total time: 4 seconds
                        [INFO] Finished at: Fri Sep 05 13:02:49 PDT 2008
                        [INFO] Final Memory: 11M/20M
                        [INFO] ------------------------------------------------------------------------
                        [559][valkyrie: web_pkg_scope]$ jar -tf ear/target/web_pkg_scope.ear
                        META-INF/
                        META-INF/MANIFEST.MF
                        META-INF/application.xml
                        web_pkg_scope_web.war
                        META-INF/maven/
                        META-INF/maven/org.jboss.vfs/
                        META-INF/maven/org.jboss.vfs/web_pkg_scope_ear/
                        META-INF/maven/org.jboss.vfs/web_pkg_scope_ear/pom.xml
                        META-INF/maven/org.jboss.vfs/web_pkg_scope_ear/pom.properties
                        


                        and the test fails to show any of the contents under the WEB-INF/classes, which is consistent with the tck test.
                        junit.framework.AssertionFailedError: No missing entries: [META-INF/, web_pkg_scope/servlet/, web_pkg_scope/, web_pkg_scope/entity/Account.class, web_pkg_scope/entity/, web_pkg_scope/servlet/JpaServlet.class, META-INF/persistence.xml] expected:<0> but was:<7>
                         at junit.framework.Assert.fail(Assert.java:47)
                         at junit.framework.Assert.failNotEquals(Assert.java:282)
                         at junit.framework.Assert.assertEquals(Assert.java:64)
                         at junit.framework.Assert.assertEquals(Assert.java:201)
                         at org.jboss.test.virtual.test.JARVFSContextUnitTestCase.testWarClassesJarInputStream(JARVFSContextUnitTestCase.java:284)
                        


                        • 10. Re: virtualFile.toURL().openStream() does not provide a JarI
                          Carlo de Wolf Master

                          The EOFException happens when the jar contains an 'empty' entry. There is some wicked logic in Hibernate that triggers it.

                          I've updated my patch on Jira. With it that test passes, but I get 4 other failures.

                          • 11. Re: virtualFile.toURL().openStream() does not provide a JarI
                            Carlo de Wolf Master

                            Now if I add:

                            public static Test suite()
                             {
                             System.setProperty(VFSUtils.FORCE_COPY_KEY, "true");
                             ...
                             }

                            The test (among others) fails in the same manner as on AS.

                            • 12. Re: virtualFile.toURL().openStream() does not provide a JarI
                              Marko Strukelj Master

                              I commited Carlo's patch.

                              I noticed I was calling write(zero-length-buffer) for directory entries. Maybe this has to do with EOFException. I fixed that so maybe it works better now.

                              - marko

                              • 13. Re: virtualFile.toURL().openStream() does not provide a JarI
                                Scott Stark Master

                                I tried it and its still failing. I updated the test to set the VFSUtils.FORCE_COPY_KEY property to true because that is what is used in jbossas. As Carlo said, this fails with the immediate eof exception on first read of the stream as is the case for the tck test.

                                • 14. Re: virtualFile.toURL().openStream() does not provide a JarI
                                  Marko Strukelj Master

                                  I've commited more fixes. All four AS tests are passing now.

                                  Give it a try with tck.

                                  1 2 Previous Next