ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 44103] New: - Ant classloader return input stream of the resource, but disallows class loading and get URL
Date Wed, 19 Dec 2007 11:32:08 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44103>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=44103

           Summary: Ant classloader return input stream of the resource, but
                    disallows class loading and get URL
           Product: Ant
           Version: 1.7.0
          Platform: Other
        OS/Version: Windows XP
            Status: NEW
          Severity: major
          Priority: P2
         Component: Core
        AssignedTo: notifications@ant.apache.org
        ReportedBy: m_pashka@mail.ru


Start ANT using org.apache.tools.ant.Main class, specify something in the ANT
classloader.
Try to get resource from your custom classpath as stream - it is ok.
Try to get resource URL from your custom class path - it returns null.
Try to load class from your custom class path - it fails.


Severity is major because it breaks using XML (JAXP) in standard way through
DocumentBuilderFactory in case of specifying xerces.jar in ANT classpath.
Factory can find properties file, defined in xerces.jar, but fails to load
implementation class from it.


ANT start script:
%JAVA_HOME%\bin\java.exe -Xmx650M -cp
%GLOBAL_BUILD_DIR%\3rdparty\xerces\xercesImpl.jar org.apache.tools.ant.Main
-listener org.apache.tools.ant.listener.Log4jListener



ANT task
        <java classname="AntClassLoaderTest" failonerror="true" fork="false" />



AntClassLoaderTest code
        ClassLoader cl = AntClassLoaderTest.class.getClassLoader();
        URL url =
cl.getResource("org/apache/xerces/jaxp/DocumentBuilderFactoryImpl.class");
        System.out.println("URL = " + url);

        InputStream in =
cl.getResourceAsStream("org/apache/xerces/jaxp/DocumentBuilderFactoryImpl.class");
        System.out.println("in = " + in);

        byte[] buf = new byte[16];
        in.read(buf);
        boolean equals = Arrays.equals(buf, new byte[]{(byte) 0xCA, (byte) 0xFE,
(byte) 0xBA, (byte) 0xBE, 0x00, 0x03, 0x00, 0x2D, 0x00, (byte) 0x8B, 0x0A, 0x00,
0x29, 0x00, 0x47, 0x09});
        in.close();
        System.out.println("Equals = " + equals);
        System.out.println("Class loader = " + cl);
        try {
            cl.loadClass("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
        } catch (Exception e) {
            e.printStackTrace();
        }




Result:
URL is not found
InputStream is found and equals to defined
Class Loading failed


     [java] URL = null
     [java] in = sun.net.www.protocol.jar.JarURLConnection$JarURLInputStream@1ea8dbd
     [java] Equals = true
     [java] Class loader =
AntClassLoader[C:\Projects\jnetx\4.0\jnetx\slee\slee-implementation\build\lib\slee-implementation.jar;C:\Projects\jnetx\4.0\build\3rdparty\dom4j\dom4j-core.jar;C:\Projects\jnetx\4.
0\build\3rdparty\dom4j\dom4j-full.jar;C:\Projects\jnetx\4.0\build\3rdparty\dom4j\dom4j.jar;C:\Projects\jnetx\4.0\build\3rdparty\excalibur-naming\excalibur-naming-1.0.jar;C:\Projects\jnetx\4.0\build\3rdparty\
jain-slee-specification\jain-slee-specification.jar;C:\Projects\jnetx\4.0\build\3rdparty\jarv\isorelax.jar;C:\Projects\jnetx\4.0\build\3rdparty\jaxen\jaxen.jar;C:\Projects\jnetx\4.0\build\3rdparty\jaxen\saxp
ath.jar;C:\Projects\jnetx\4.0\build\3rdparty\jta\jta-1.0.1.jar;C:\Projects\jnetx\4.0\build\3rdparty\log4j\log4j.jar;C:\Projects\jnetx\4.0\build\3rdparty\xerces-jarv\XercesJARV.jar;C:\Projects\jnetx\4.0\build
\comp\configuration-core\configuration-core.jar;C:\Projects\jnetx\4.0\build\comp\container\lib\container-test.jar;C:\Projects\jnetx\4.0\build\comp\container\lib\container.jar;C:\Projects\jnetx\4.0\build\comp
\container\lib\util-test.jar;C:\Projects\jnetx\4.0\build\comp\dsm-api\lib\dsm-api.jar;C:\Projects\jnetx\4.0\build\comp\dsm-api\lib\test-dsm-api.jar;C:\Projects\jnetx\4.0\build\comp\gms-api\lib\gms-api.jar;C:
\Projects\jnetx\4.0\build\comp\gms-api\lib\test-gms-api.jar;C:\Projects\jnetx\4.0\build\comp\slee-lib\jnetx-types.jar;C:\Projects\jnetx\4.0\build\comp\slee-lib\lib\slee-lib.jar;C:\Projects\jnetx\4.0\build\co
mp\slee-lib\slee-core.jar;C:\Projects\jnetx\4.0\build\comp\slee-lib\standard-types.jar;C:\Projects\jnetx\4.0\build\comp\util\lib\util-test.jar;C:\Projects\jnetx\4.0\build\comp\util\lib\util.jar]
     [java] java.lang.ClassNotFoundException:
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
     [java]     at
org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1383)
     [java]     at
org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1324)
     [java]     at
org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1078)
     [java]     at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
     [java]     at
com.jnetx.slee.standalone.deployment.DeploymentUnitPrecompiler.main(DeploymentUnitPrecompiler.java:73)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]     at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:597)
     [java]     at
org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
     [java]     at
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
     [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:747)
     [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:201)
     [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:104)
     [java]     at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]     at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:597)
     [java]     at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
     [java]     at org.apache.tools.ant.Task.perform(Task.java:348)
     [java]     at org.apache.tools.ant.Target.execute(Target.java:357)
     [java]     at org.apache.tools.ant.Target.performTasks(Target.java:385)
     [java]     at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
     [java]     at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
     [java]     at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
     [java]     at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
     [java]     at org.apache.tools.ant.Main.runBuild(Main.java:698)
     [java]     at org.apache.tools.ant.Main.startAnt(Main.java:199)
     [java]     at org.apache.tools.ant.Main.start(Main.java:161)
     [java]     at org.apache.tools.ant.Main.main(Main.java:250)

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

Mime
View raw message