You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Michael B Allen <io...@gmail.com> on 2011/10/21 22:58:32 UTC

pathelement triggers NoClassDefFoundError: com/sun/net/ssl/internal/ssl/Provider

Hello,

I'm posting this to dev instead of users because my best guess is that
this is a bug. But hopefully I'm wrong.

Consider the following target which runs a Java program MakeFoo.class:

<target name="foo">
    <java classname="MakeFoo">
        <classpath>
            <pathelement location="."/>
        </classpath>
        <arg line="-o foo -d 'maken some foo'"/>
    </java>
</target>

This generates the following exception:

$ ant foo
Buildfile: /some/path/to/build.xml

foo:
     [java] java.lang.NoClassDefFoundError:
com/sun/net/ssl/internal/ssl/Provider
     [java]     at
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:194)
     [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:771)
     [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221)
     [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
     [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
     [java]     at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
     [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:106)
     [java]     at org.apache.tools.ant.Task.perform(Task.java:348)
     [java]     at org.apache.tools.ant.Target.execute(Target.java:390)
     [java]     at org.apache.tools.ant.Target.performTasks(Target.java:411)
     [java]     at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
     [java]     at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
     [java]     at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
     [java]     at
org.apache.tools.ant.Project.executeTargets(Project.java:1251)
     [java]     at org.apache.tools.ant.Main.runBuild(Main.java:809)
     [java]     at org.apache.tools.ant.Main.startAnt(Main.java:217)
     [java]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
     [java]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
     [java] Caused by: java.lang.NoClassDefFoundError:
com/sun/net/ssl/internal/ssl/Provider
     [java]     at java.lang.Class.forName0(Native Method)
     [java]     at java.lang.Class.forName(Class.java:247)
     [java]     at
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:135)
     [java]     ... 21 more
     [java] Caused by: java.lang.ClassNotFoundException:
com.sun.net.ssl.internal.ssl.Provider
     [java]     at
org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1361)
     [java]     at
org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1311)
     [java]     at
org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1070)
     [java]     at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
     [java]     ... 24 more
     [java] Java Result: -1

Java and Ant versions are pretty much the latest:

$ java -version
java version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) 64-Bit Server VM (build 20.2-b06, mixed mode)
$ ant -version
Apache Ant(TM) version 1.8.2 compiled on December 20 2010

And I know from using strace that Ant is actually using Sun's Java and
not openjdk.

If I remove the pathelement directive, the build works.

The com.sun.net.ssl.internal.ssl.Provider class is in
${JAVA_HOME}/lib/jsse.jar and that jar is present.

So it seems Ant does not load jsse.jar when using pathelement. Why?

I would appreciate it if someone has a work-around for me. I need to
specify a bunch of jars in the classpath using fileset and once I do
that I need to add '.' so that the program itself is in the classpath.
But once I do this pathement triggers the jsse.jar problem. And
obviously I don't want to add a jsse.jar dep in the build.xml. So I'm
stuck. Please help.

Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: pathelement triggers NoClassDefFoundError: com/sun/net/ssl/internal/ssl/Provider

Posted by Stefan Bodewig <bo...@apache.org>.
On 2011-10-24, Michael B Allen wrote:

> I would argue that if pathelement requires jsse.jar, it should
> automatically include it in the classpath just as it does rt.jar.

Huh?  I must have misread your original post, sorry.

<pathelement> certainly doesn't require jsse.jar, not much in Ant would
do (the SSH tasks and the mail layer if TLS is used).  It must be your
code that requires it.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: pathelement triggers NoClassDefFoundError: com/sun/net/ssl/internal/ssl/Provider

Posted by Michael B Allen <io...@gmail.com>.
On Sat, Oct 22, 2011 at 1:13 AM, Stefan Bodewig <bo...@apache.org> wrote:
> Hi Michael,
>
> On 2011-10-21, Michael B Allen wrote:
>
>> I'm posting this to dev instead of users because my best guess is that
>> this is a bug.
>
> Probably not.
>
>> Consider the following target which runs a Java program MakeFoo.class:
>
>> <target name="foo">
>>     <java classname="MakeFoo">
>>         <classpath>
>>             <pathelement location="."/>
>>         </classpath>
>>         <arg line="-o foo -d 'maken some foo'"/>
>>     </java>
>> </target>
>
>> This generates the following exception:
>
>> $ ant foo
>> Buildfile: /some/path/to/build.xml
>
>> foo:
>>      [java] java.lang.NoClassDefFoundError:
>> com/sun/net/ssl/internal/ssl/Provider
>>      [java]     at
>> org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:194)
> [...]
>>      [java] Java Result: -1
>
>> Java and Ant versions are pretty much the latest:
>
>> If I remove the pathelement directive, the build works.
>
> If you don't specify the <classpath> explicitly your Java process runs
> with the same CLASSPATH that is used by Ant internally - which includes
> jsse.jar.
>
> If you specify it, then you only get what you have asked for (unless you
> fiddle with the build.sysclasspath property), or close to it.  I think
> it should work if you explicitly add
>
> <pathelement path="${java.class.path}"/>

Hi Stefan,

Adding that pathelement had no effect. I still get precisely the same error.

I would argue that if pathelement requires jsse.jar, it should
automatically include it in the classpath just as it does rt.jar.

> if you don't like hardcoding jsse.jar (which you could address relative
> to ${java.home}).

I ended up just copying jsse.jar into my jars directory which is part
of the classpath using a fileset so that the issue would at least no
pollute my build.xml. Of course when I update Java this could break.
But I could not think of another way to do it.

Thanks anyway. I just posted for posterity mostly.

Mike

-- 
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: pathelement triggers NoClassDefFoundError: com/sun/net/ssl/internal/ssl/Provider

Posted by Stefan Bodewig <bo...@apache.org>.
Hi Michael,

On 2011-10-21, Michael B Allen wrote:

> I'm posting this to dev instead of users because my best guess is that
> this is a bug.

Probably not.

> Consider the following target which runs a Java program MakeFoo.class:

> <target name="foo">
>     <java classname="MakeFoo">
>         <classpath>
>             <pathelement location="."/>
>         </classpath>
>         <arg line="-o foo -d 'maken some foo'"/>
>     </java>
> </target>

> This generates the following exception:

> $ ant foo
> Buildfile: /some/path/to/build.xml

> foo:
>      [java] java.lang.NoClassDefFoundError:
> com/sun/net/ssl/internal/ssl/Provider
>      [java]     at
> org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:194)
[...]
>      [java] Java Result: -1

> Java and Ant versions are pretty much the latest:

> If I remove the pathelement directive, the build works.

If you don't specify the <classpath> explicitly your Java process runs
with the same CLASSPATH that is used by Ant internally - which includes
jsse.jar.

If you specify it, then you only get what you have asked for (unless you
fiddle with the build.sysclasspath property), or close to it.  I think
it should work if you explicitly add

<pathelement path="${java.class.path}"/>

if you don't like hardcoding jsse.jar (which you could address relative
to ${java.home}).

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org