You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Jon Schewe <jp...@eggplant.mtu.net> on 2000/11/25 19:05:15 UTC

IllegalAccessError when using java task

I'm trying to call one of my own java programs from inside Ant.  When I
specify fork="yes" everything works fine, if I don't specify that I get this
IllegalAccessError:
/home/jpschewe/projects/java/foo/antTest/build.xml:47: java.lang.IllegalAccessError: try to access class org.tcfreenet.schewe.assert.ColumnTracker from class org.tcfreenet.schewe.assert.JonsAssert
java.lang.IllegalAccessError: try to access class org.tcfreenet.schewe.assert.ColumnTracker from class org.tcfreenet.schewe.assert.JonsAssert
	at org.tcfreenet.schewe.assert.JonsAssert.parseFile(JonsAssert.java:162)
	at org.tcfreenet.schewe.assert.JonsAssert.doFile(JonsAssert.java:127)
	at org.tcfreenet.schewe.assert.JonsAssert.doFile(JonsAssert.java:121)
	at org.tcfreenet.schewe.assert.JonsAssert.doFile(JonsAssert.java:121)
	at org.tcfreenet.schewe.assert.JonsAssert.main(JonsAssert.java:93)
	at java.lang.reflect.Method.invoke(Native Method)
	at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:107)
	at org.apache.tools.ant.taskdefs.Java.run(Java.java:245)
	at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:122)
	at org.apache.tools.ant.taskdefs.Java.execute(Java.java:86)
	at org.apache.tools.ant.Target.execute(Target.java:142)
	at org.apache.tools.ant.Project.runTarget(Project.java:818)
	at org.apache.tools.ant.Project.executeTarget(Project.java:532)
	at org.apache.tools.ant.Project.executeTargets(Project.java:506)
	at org.apache.tools.ant.Main.runBuild(Main.java:420)
	at org.apache.tools.ant.Main.main(Main.java:149)

The class ColumnTracker does indeed have package access, but the class it's
being called from, JonsAssert, is in the same package, so I'm not sure what
the problem is.  I'd rather not have the extra overhead of starting up another
process.

I'm using Ant 1.2 with JDK 1.3.0 and jikes 1.12 on Linux.


-- 
Jon Schewe | http://eggplant.mtu.net/~jpschewe
For I am convinced that neither death nor life, neither angels 
nor demons, neither the present nor the future, nor any 
powers, neither height nor depth, nor anything else in all 
creation, will be able to separate us from the love of God that 
is in Christ Jesus our Lord. - Romans 8:38-39
NOTE: My first name has no 'h' in it!  Please be observant.


Re: IllegalAccessError when using java task

Posted by Jon Schewe <jp...@eggplant.mtu.net>.
Thank you that worked.

"Conor MacNeill" <co...@ebinteractive.com.au> writes:

> Don't give it a classpath.
> 
> --
> Conor MacNeill
> conor@cortexebusiness.com.au
> Cortex eBusiness 
> http://www.cortexebusiness.com.au
> 
> > -----Original Message-----
> > From: jpschewe@workstation.mn.mtu.net
> > [mailto:jpschewe@workstation.mn.mtu.net]On Behalf Of Jon Schewe
> > Sent: Sunday, 26 November 2000 16:43
> > To: ant-user@jakarta.apache.org
> > Subject: Re: IllegalAccessError when using java task
> > 
> > 
> > Is there a way for the class called by the java task to be loaded by the
> > system class loader?  Would writing an actual Task class help the 
> > situation? 
> > 
> > "Conor MacNeill" <co...@m64.com> writes:
> > 
> > > Jon,
> > > 
> > > I assume you have specified a classpath and fork="no". For this
> > > classpath to be used and not the system classpath, ant must use a
> > > classloader. In this case, ant currently forces the class specified by
> > > the java task to be loaded by the ant class loader.
> > > 
> > > Conor
> > > 
> > > 
> > > > -----Original Message-----
> > > > From: jpschewe@workstation.mn.mtu.net
> > > > [mailto:jpschewe@workstation.mn.mtu.net]On Behalf Of Jon Schewe
> > > > Sent: Sunday, 26 November 2000 9:13
> > > > To: ant-user@jakarta.apache.org
> > > > Subject: Re: IllegalAccessError when using java task
> > > >
> > > >
> > > > I tried with -debug and got the following:
> > > >    [assert] Running in same VM
> > > > org.tcfreenet.schewe.assert.JonsAssert
> > > > /home/jpschewe/projects/java/foo/antTest "-d
> > > > /home/jpschewe/projects/java/instrumented"
> > > > force loading org.tcfreenet.schewe.assert.JonsAssert
> > > > Finding class org.tcfreenet.schewe.assert.JonsAssert
> > > >
> > > > Does this mean that the class JonsAssert is not being loaded
> > > > by the system
> > > > class loader?  If so, why would ant be using its own class
> > > > loader anyway?
> > > >
> > > >
> > > 
> > 
> > -- 
> > Jon Schewe | http://eggplant.mtu.net/~jpschewe
> > For I am convinced that neither death nor life, neither angels 
> > nor demons, neither the present nor the future, nor any 
> > powers, neither height nor depth, nor anything else in all 
> > creation, will be able to separate us from the love of God that 
> > is in Christ Jesus our Lord. - Romans 8:38-39
> > NOTE: My first name has no 'h' in it!  Please be observant.
> > 
> > 

-- 
Jon Schewe | http://eggplant.mtu.net/~jpschewe
For I am convinced that neither death nor life, neither angels 
nor demons, neither the present nor the future, nor any 
powers, neither height nor depth, nor anything else in all 
creation, will be able to separate us from the love of God that 
is in Christ Jesus our Lord. - Romans 8:38-39
NOTE: My first name has no 'h' in it!  Please be observant.


RE: IllegalAccessError when using java task

Posted by Conor MacNeill <co...@ebinteractive.com.au>.
Don't give it a classpath.

--
Conor MacNeill
conor@cortexebusiness.com.au
Cortex eBusiness 
http://www.cortexebusiness.com.au

> -----Original Message-----
> From: jpschewe@workstation.mn.mtu.net
> [mailto:jpschewe@workstation.mn.mtu.net]On Behalf Of Jon Schewe
> Sent: Sunday, 26 November 2000 16:43
> To: ant-user@jakarta.apache.org
> Subject: Re: IllegalAccessError when using java task
> 
> 
> Is there a way for the class called by the java task to be loaded by the
> system class loader?  Would writing an actual Task class help the 
> situation? 
> 
> "Conor MacNeill" <co...@m64.com> writes:
> 
> > Jon,
> > 
> > I assume you have specified a classpath and fork="no". For this
> > classpath to be used and not the system classpath, ant must use a
> > classloader. In this case, ant currently forces the class specified by
> > the java task to be loaded by the ant class loader.
> > 
> > Conor
> > 
> > 
> > > -----Original Message-----
> > > From: jpschewe@workstation.mn.mtu.net
> > > [mailto:jpschewe@workstation.mn.mtu.net]On Behalf Of Jon Schewe
> > > Sent: Sunday, 26 November 2000 9:13
> > > To: ant-user@jakarta.apache.org
> > > Subject: Re: IllegalAccessError when using java task
> > >
> > >
> > > I tried with -debug and got the following:
> > >    [assert] Running in same VM
> > > org.tcfreenet.schewe.assert.JonsAssert
> > > /home/jpschewe/projects/java/foo/antTest "-d
> > > /home/jpschewe/projects/java/instrumented"
> > > force loading org.tcfreenet.schewe.assert.JonsAssert
> > > Finding class org.tcfreenet.schewe.assert.JonsAssert
> > >
> > > Does this mean that the class JonsAssert is not being loaded
> > > by the system
> > > class loader?  If so, why would ant be using its own class
> > > loader anyway?
> > >
> > >
> > 
> 
> -- 
> Jon Schewe | http://eggplant.mtu.net/~jpschewe
> For I am convinced that neither death nor life, neither angels 
> nor demons, neither the present nor the future, nor any 
> powers, neither height nor depth, nor anything else in all 
> creation, will be able to separate us from the love of God that 
> is in Christ Jesus our Lord. - Romans 8:38-39
> NOTE: My first name has no 'h' in it!  Please be observant.
> 
> 

Re: IllegalAccessError when using java task

Posted by Jon Schewe <jp...@eggplant.mtu.net>.
Is there a way for the class called by the java task to be loaded by the
system class loader?  Would writing an actual Task class help the situation? 

"Conor MacNeill" <co...@m64.com> writes:

> Jon,
> 
> I assume you have specified a classpath and fork="no". For this
> classpath to be used and not the system classpath, ant must use a
> classloader. In this case, ant currently forces the class specified by
> the java task to be loaded by the ant class loader.
> 
> Conor
> 
> 
> > -----Original Message-----
> > From: jpschewe@workstation.mn.mtu.net
> > [mailto:jpschewe@workstation.mn.mtu.net]On Behalf Of Jon Schewe
> > Sent: Sunday, 26 November 2000 9:13
> > To: ant-user@jakarta.apache.org
> > Subject: Re: IllegalAccessError when using java task
> >
> >
> > I tried with -debug and got the following:
> >    [assert] Running in same VM
> > org.tcfreenet.schewe.assert.JonsAssert
> > /home/jpschewe/projects/java/foo/antTest "-d
> > /home/jpschewe/projects/java/instrumented"
> > force loading org.tcfreenet.schewe.assert.JonsAssert
> > Finding class org.tcfreenet.schewe.assert.JonsAssert
> >
> > Does this mean that the class JonsAssert is not being loaded
> > by the system
> > class loader?  If so, why would ant be using its own class
> > loader anyway?
> >
> >
> 

-- 
Jon Schewe | http://eggplant.mtu.net/~jpschewe
For I am convinced that neither death nor life, neither angels 
nor demons, neither the present nor the future, nor any 
powers, neither height nor depth, nor anything else in all 
creation, will be able to separate us from the love of God that 
is in Christ Jesus our Lord. - Romans 8:38-39
NOTE: My first name has no 'h' in it!  Please be observant.


RE: IllegalAccessError when using java task

Posted by Conor MacNeill <co...@m64.com>.
Jon,

I assume you have specified a classpath and fork="no". For this
classpath to be used and not the system classpath, ant must use a
classloader. In this case, ant currently forces the class specified by
the java task to be loaded by the ant class loader.

Conor


> -----Original Message-----
> From: jpschewe@workstation.mn.mtu.net
> [mailto:jpschewe@workstation.mn.mtu.net]On Behalf Of Jon Schewe
> Sent: Sunday, 26 November 2000 9:13
> To: ant-user@jakarta.apache.org
> Subject: Re: IllegalAccessError when using java task
>
>
> I tried with -debug and got the following:
>    [assert] Running in same VM
> org.tcfreenet.schewe.assert.JonsAssert
> /home/jpschewe/projects/java/foo/antTest "-d
> /home/jpschewe/projects/java/instrumented"
> force loading org.tcfreenet.schewe.assert.JonsAssert
> Finding class org.tcfreenet.schewe.assert.JonsAssert
>
> Does this mean that the class JonsAssert is not being loaded
> by the system
> class loader?  If so, why would ant be using its own class
> loader anyway?
>
>


Re: IllegalAccessError when using java task

Posted by Jon Schewe <jp...@eggplant.mtu.net>.
I tried with -debug and got the following:
   [assert] Running in same VM org.tcfreenet.schewe.assert.JonsAssert /home/jpschewe/projects/java/foo/antTest "-d /home/jpschewe/projects/java/instrumented"
force loading org.tcfreenet.schewe.assert.JonsAssert
Finding class org.tcfreenet.schewe.assert.JonsAssert

Does this mean that the class JonsAssert is not being loaded by the system
class loader?  If so, why would ant be using its own class loader anyway?

"Conor MacNeill" <co...@m64.com> writes:

> Hmm. If they are being loaded by different loaders, the package access
> won't help you, probably. If you run ant-debug, you may be able to see
> which class loader is being used for each class. It may then be a case
> of adjusting your classpaths.
> 
> Conor
> 
> 
> > -----Original Message-----
> > From: jpschewe@workstation.mn.mtu.net
> > [mailto:jpschewe@workstation.mn.mtu.net]On Behalf Of Jon Schewe
> > Sent: Sunday, 26 November 2000 5:05
> > To: ant-user@jakarta.apache.org
> > Subject: IllegalAccessError when using java task
> >
> >
> > I'm trying to call one of my own java programs from inside
> > Ant.  When I
> > specify fork="yes" everything works fine, if I don't specify
> > that I get this
> > IllegalAccessError:
> > /home/jpschewe/projects/java/foo/antTest/build.xml:47:
> > java.lang.IllegalAccessError: try to access class
> > org.tcfreenet.schewe.assert.ColumnTracker from class
> > org.tcfreenet.schewe.assert.JonsAssert
> > java.lang.IllegalAccessError: try to access class
> > org.tcfreenet.schewe.assert.ColumnTracker from class
> > org.tcfreenet.schewe.assert.JonsAssert
> > 	at
> > org.tcfreenet.schewe.assert.JonsAssert.parseFile(JonsAssert.java:162)
> > 	at
> > org.tcfreenet.schewe.assert.JonsAssert.doFile(JonsAssert.java:127)
> > 	at
> > org.tcfreenet.schewe.assert.JonsAssert.doFile(JonsAssert.java:121)
> > 	at
> > org.tcfreenet.schewe.assert.JonsAssert.doFile(JonsAssert.java:121)
> > 	at
> > org.tcfreenet.schewe.assert.JonsAssert.main(JonsAssert.java:93)
> > 	at java.lang.reflect.Method.invoke(Native Method)
> > 	at
> > org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.
> > java:107)
> > 	at org.apache.tools.ant.taskdefs.Java.run(Java.java:245)
> > 	at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:122)
> > 	at org.apache.tools.ant.taskdefs.Java.execute(Java.java:86)
> > 	at org.apache.tools.ant.Target.execute(Target.java:142)
> > 	at org.apache.tools.ant.Project.runTarget(Project.java:818)
> > 	at org.apache.tools.ant.Project.executeTarget(Project.java:532)
> > 	at org.apache.tools.ant.Project.executeTargets(Project.java:506)
> > 	at org.apache.tools.ant.Main.runBuild(Main.java:420)
> > 	at org.apache.tools.ant.Main.main(Main.java:149)
> >
> > The class ColumnTracker does indeed have package access, but
> > the class it's
> > being called from, JonsAssert, is in the same package, so I'm
> > not sure what
> > the problem is.  I'd rather not have the extra overhead of
> > starting up another
> > process.
> >
> > I'm using Ant 1.2 with JDK 1.3.0 and jikes 1.12 on Linux.
> >
> >
> > --
> > Jon Schewe | http://eggplant.mtu.net/~jpschewe
> > For I am convinced that neither death nor life, neither angels
> > nor demons, neither the present nor the future, nor any
> > powers, neither height nor depth, nor anything else in all
> > creation, will be able to separate us from the love of God that
> > is in Christ Jesus our Lord. - Romans 8:38-39
> > NOTE: My first name has no 'h' in it!  Please be observant.
> >
> >
> 

-- 
Jon Schewe | http://eggplant.mtu.net/~jpschewe
For I am convinced that neither death nor life, neither angels 
nor demons, neither the present nor the future, nor any 
powers, neither height nor depth, nor anything else in all 
creation, will be able to separate us from the love of God that 
is in Christ Jesus our Lord. - Romans 8:38-39
NOTE: My first name has no 'h' in it!  Please be observant.


RE: IllegalAccessError when using java task

Posted by Conor MacNeill <co...@m64.com>.
Hmm. If they are being loaded by different loaders, the package access
won't help you, probably. If you run ant-debug, you may be able to see
which class loader is being used for each class. It may then be a case
of adjusting your classpaths.

Conor


> -----Original Message-----
> From: jpschewe@workstation.mn.mtu.net
> [mailto:jpschewe@workstation.mn.mtu.net]On Behalf Of Jon Schewe
> Sent: Sunday, 26 November 2000 5:05
> To: ant-user@jakarta.apache.org
> Subject: IllegalAccessError when using java task
>
>
> I'm trying to call one of my own java programs from inside
> Ant.  When I
> specify fork="yes" everything works fine, if I don't specify
> that I get this
> IllegalAccessError:
> /home/jpschewe/projects/java/foo/antTest/build.xml:47:
> java.lang.IllegalAccessError: try to access class
> org.tcfreenet.schewe.assert.ColumnTracker from class
> org.tcfreenet.schewe.assert.JonsAssert
> java.lang.IllegalAccessError: try to access class
> org.tcfreenet.schewe.assert.ColumnTracker from class
> org.tcfreenet.schewe.assert.JonsAssert
> 	at
> org.tcfreenet.schewe.assert.JonsAssert.parseFile(JonsAssert.java:162)
> 	at
> org.tcfreenet.schewe.assert.JonsAssert.doFile(JonsAssert.java:127)
> 	at
> org.tcfreenet.schewe.assert.JonsAssert.doFile(JonsAssert.java:121)
> 	at
> org.tcfreenet.schewe.assert.JonsAssert.doFile(JonsAssert.java:121)
> 	at
> org.tcfreenet.schewe.assert.JonsAssert.main(JonsAssert.java:93)
> 	at java.lang.reflect.Method.invoke(Native Method)
> 	at
> org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.
> java:107)
> 	at org.apache.tools.ant.taskdefs.Java.run(Java.java:245)
> 	at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:122)
> 	at org.apache.tools.ant.taskdefs.Java.execute(Java.java:86)
> 	at org.apache.tools.ant.Target.execute(Target.java:142)
> 	at org.apache.tools.ant.Project.runTarget(Project.java:818)
> 	at org.apache.tools.ant.Project.executeTarget(Project.java:532)
> 	at org.apache.tools.ant.Project.executeTargets(Project.java:506)
> 	at org.apache.tools.ant.Main.runBuild(Main.java:420)
> 	at org.apache.tools.ant.Main.main(Main.java:149)
>
> The class ColumnTracker does indeed have package access, but
> the class it's
> being called from, JonsAssert, is in the same package, so I'm
> not sure what
> the problem is.  I'd rather not have the extra overhead of
> starting up another
> process.
>
> I'm using Ant 1.2 with JDK 1.3.0 and jikes 1.12 on Linux.
>
>
> --
> Jon Schewe | http://eggplant.mtu.net/~jpschewe
> For I am convinced that neither death nor life, neither angels
> nor demons, neither the present nor the future, nor any
> powers, neither height nor depth, nor anything else in all
> creation, will be able to separate us from the love of God that
> is in Christ Jesus our Lord. - Romans 8:38-39
> NOTE: My first name has no 'h' in it!  Please be observant.
>
>