I've written a plugin (in Java) that explicitly invokes the main method of a
Java class directly from within the jvm that maven is already running.  My
plugin is behaving/configured as I expect, but I have a classpath problem
when control switches from my plugin code to the main method of the Java
class it invokes.

I use the following method to print the classpath before I invoke the main
method on my target class:
project.getCompileClasspathElements();

(where project is MavenProject)

And I get the list of jars I expect, including:
/home/hedgert/.m2/repository/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar

which is the copy of javax.servlet that I have in my local maven repository. 
Great - so far so good.

I invoke the main method of my target class and the code runs and then falls
over with a:
java.lang.NoClassDefFoundError: javax/servlet/ServletException

If I check the contents of my servlet-api-2.4.jar:
: jar -tf
/home/hedgert/.m2/repository/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar
|grep ServletException
javax/servlet/ServletException.class

The missing class is indeed in the jar that is on the classpath.

So presumably the classpath I'm getting back from:
project.getCompileClasspathElements();

is not actually the classpath in operation when I invoke the main method on
my class from within a running JVM.

So my question is: maven has nicely worked out the classpath I need (using
the dependencies in my pom.xml file for my target project, rather than my
plugin), how do I get this classpath be active in the running JVM?
-- 
View this message in context: 
http://www.nabble.com/Build-time-classpath-using-my-java-plugin-tf1914923.html#a5242414
Sent from the Maven - Users forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to