You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Le, Vu (EDS)" <Vu...@med.va.gov> on 2006/03/14 21:59:12 UTC

Checkstyle and junit classloader problem - help

Could someone provide me a pointer on this ? Thanks.  I can get
checkstyle and junit working just fine by putting their jar files in
ANT_HOME/lib but I don't want to do that and that is when my problems
come.

I want to use junit, and checkstyle with Ant (1.6.5) but I don't want to
put my junit.jar in ANT_HOME/lib directory but rather I would like keep
my junit, checkstyle-all-3.4.jar in one central place.  Here is the
problem I have

For JUnit:  I was able to declare junit target as following

	<!--
		Provides classes needed to define junit ant task
	-->	
	<path id="typedef.junit.classpath">
		<fileset dir="${ant.lib.dir}"
includes="**/ant-junit.jar"/>
		<fileset dir="${junit.lib.dir}" includes="**/*.jar"/>
	</path>
	
	<!--
		Provides classes needed to define junitreport ant task
	-->	
	<path id="typedef.junitreport.classpath">
		<fileset dir="${ant.lib.dir}" includes="**/ant-trax.jar,
**/ant-junit.jar"/>
		<fileset dir="${junit.lib.dir}" includes="**/*.jar"/>
	</path>

	<taskdef name="junit"
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
		<classpath refid="typedef.junit.classpath"/>
	</taskdef>	

	<taskdef name="junitreport"
classname="org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggrega
tor">
		<classpath refid="typedef.junitreport.classpath"/>
	</taskdef>

To make this work, I need to move ant-junit, and ant-trax.jar out of
ANT_HOME/lib.  The problem I face now is that my checkstyle target
doesn't work.  I follow the tip on apache web site in the FAQ section
about ant 1.6.* classloader and move the offending ant-xalan1.jar out of
ANT_HOME/lib and declare my checkstyle target as follow:

	<!--
		Provides classes needed to define checkstyle ant task
	-->	
	<path id="typedef.checkstyle.classpath">
		<fileset dir="${ant.lib.dir}"
includes="**/ant-trax.jar"/>
		<fileset dir="${ant.lib.dir}"
includes="**/ant-xalan1.jar"/>
		<fileset dir="${check-style.lib.dir}"
includes="**/*.jar"/>  
	</path>

	<taskdef name="checkstyle"
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
        <classpath refid="typedef.checkstyle.classpath"/>          
    </taskdef>

The exception I am getting is the following.

    [style] DEPRECATED - xalan processor is deprecated. Use trax
instead.
    [style] DEPRECATED - xslp processor is deprecated. Use trax instead.
    [style] java.lang.NoClassDefFoundError: com/kvisco/xsl/XSLProcessor
    [style] 	at
org.apache.tools.ant.taskdefs.optional.XslpLiaison.<init>(XslpLiaison.ja
va:39)
    [style] 	at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    [style] 	at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorA
ccessorImpl.java:39)
    [style] 	at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCons
tructorAccessorImpl.java:27)
    [style] 	at
java.lang.reflect.Constructor.newInstance(Constructor.java:274)
    [style] 	at java.lang.Class.newInstance0(Class.java:308)
    [style] 	at java.lang.Class.newInstance(Class.java:261)
    [style] 	at
org.apache.tools.ant.taskdefs.XSLTProcess.resolveProcessor(XSLTProcess.j
ava:398)
    [style] 	at
org.apache.tools.ant.taskdefs.XSLTProcess.getLiaison(XSLTProcess.java:61
9)
    [style] 	at
org.apache.tools.ant.taskdefs.XSLTProcess.execute(XSLTProcess.java:212)
    [style] 	at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    [style] 	at org.apache.tools.ant.Task.perform(Task.java:364)
    [style] 	at org.apache.tools.ant.Target.execute(Target.java:341)
    [style] 	at
org.apache.tools.ant.Target.performTasks(Target.java:369)
    [style] 	at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
    [style] 	at
org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleChe
ckExecutor.java:37)
    [style] 	at
org.apache.tools.ant.Project.executeTargets(Project.java:1068)
    [style] 	at
org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382)
    [style] 	at
org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:107)
    [style] 	at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    [style] 	at org.apache.tools.ant.Task.perform(Task.java:364)
    [style] 	at org.apache.tools.ant.Target.execute(Target.java:341)
    [style] 	at
org.apache.tools.ant.Target.performTasks(Target.java:369)
    [style] 	at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
    [style] 	at
org.apache.tools.ant.Project.executeTarget(Project.java:1185)
    [style] 	at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecut
or.java:40)
    [style] 	at
org.apache.tools.ant.Project.executeTargets(Project.java:1068)
    [style] 	at org.apache.tools.ant.Main.runBuild(Main.java:668)
    [style] 	at org.apache.tools.ant.Main.startAnt(Main.java:187)
    [style] 	at
org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
    [style] 	at
org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
    [style] java.lang.NoClassDefFoundError:
org/apache/xalan/xslt/XSLTInputSource
    [style] 	at java.lang.Class.forName0(Native Method)
    [style] 	at java.lang.Class.forName(Class.java:141)
    [style] 	at
org.apache.tools.ant.taskdefs.XSLTProcess.loadClass(XSLTProcess.java:419
)
    [style] 	at
org.apache.tools.ant.taskdefs.XSLTProcess.resolveProcessor(XSLTProcess.j
ava:402)
    [style] 	at
org.apache.tools.ant.taskdefs.XSLTProcess.getLiaison(XSLTProcess.java:61
6)
    [style] 	at
org.apache.tools.ant.taskdefs.XSLTProcess.execute(XSLTProcess.java:212)
    [style] 	at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    [style] 	at org.apache.tools.ant.Task.perform(Task.java:364)
    [style] 	at org.apache.tools.ant.Target.execute(Target.java:341)
    [style] 	at
org.apache.tools.ant.Target.performTasks(Target.java:369)
    [style] 	at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
    [style] 	at
org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleChe
ckExecutor.java:37)
    [style] 	at
org.apache.tools.ant.Project.executeTargets(Project.java:1068)
    [style] 	at
org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382)
    [style] 	at
org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:107)
    [style] 	at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    [style] 	at org.apache.tools.ant.Task.perform(Task.java:364)
    [style] 	at org.apache.tools.ant.Target.execute(Target.java:341)
    [style] 	at
org.apache.tools.ant.Target.performTasks(Target.java:369)
    [style] 	at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
    [style] 	at
org.apache.tools.ant.Project.executeTarget(Project.java:1185)
    [style] 	at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecut
or.java:40)
    [style] 	at
org.apache.tools.ant.Project.executeTargets(Project.java:1068)
    [style] 	at org.apache.tools.ant.Main.runBuild(Main.java:668)
    [style] 	at org.apache.tools.ant.Main.startAnt(Main.java:187)
    [style] 	at
org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
    [style] 	at
org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)


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


Re: Checkstyle and junit classloader problem - help

Posted by Dominique Devienne <dd...@gmail.com>.
On 3/14/06, Le, Vu (EDS) <Vu...@med.va.gov> wrote:
> Could someone provide me a pointer on this ? Thanks.  I can get
> checkstyle and junit working just fine by putting their jar files in
> ANT_HOME/lib but I don't want to do that and that is when my problems
> come.

You like it the hard way I see ;-)

> I want to use junit, and checkstyle with Ant (1.6.5) but I don't want to
> put my junit.jar in ANT_HOME/lib directory but rather I would like keep
> my junit, checkstyle-all-3.4.jar in one central place.  Here is the
> problem I have

The easiest might be to use the -lib command line arg to adds these
Jars to Ant's classpath. Could be wrapped in a custom startup script.

> To make this work, I need to move ant-junit, and ant-trax.jar out of
> ANT_HOME/lib.

Right. You've done your home work. Thanks for that.

> The problem I face now is that my checkstyle target
> doesn't work.  I follow the tip on apache web site in the FAQ section
> about ant 1.6.* classloader and move the offending ant-xalan1.jar out of
> ANT_HOME/lib and declare my checkstyle target as follow:

Sorry, don't know how to help here. Consider -lib or setting the
CLASSPATH for Ant manually, or consider your "central" place for Jars
to be ANT_HOME/lib ;-)

As an FYI, the latest SVN code (to be released eventually as Ant 1.7)
contains a fix for <junit>, but it's a <junit> specific solution, not
applicable to <checkstyle>.

Sorry for not being more helpful. --DD

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