Maven classpath question
Hi, I'm using an older version of Maven (1.1), but hopefully this question is still relevant. I have a test module that includes this dependency in its project.xml file ... dependency groupIdcom.caucho/groupId artifactIdresin/artifactId version3.0.9/version /dependency However, when I run my JUnit test, I get the ClassNotFoundException below. The reason it is strange is because that class exists within the dependency above. Can you think of some ways I can troubleshoot this problem further? Thanks, - Dave javax.naming.NoInitialContextException: Cannot instantiate class: com.caucho.naming.InitialContextFactoryImpl [Root exception is java.lang.ClassNotFoundException: com.caucho.naming.InitialContextFactoryImpl] at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247) at javax.naming.InitialContext.init(InitialContext.java:223) at javax.naming.InitialContext.init(InitialContext.java:175) at com.caucho.naming.Jndi.bindDeep(Jndi.java:57) at com.caucho.loader.EnvironmentClassLoader.initializeEnvironment(EnvironmentClassLoader.java:435) at com.caucho.loader.EnvironmentClassLoader.init(EnvironmentClassLoader.java:107) at com.caucho.java.InternalCompiler.executeInt(InternalCompiler.java:138) at com.caucho.java.InternalCompiler.compileInt(InternalCompiler.java:78) at com.caucho.java.AbstractJavaCompiler.run(AbstractJavaCompiler.java:101) at java.lang.Thread.run(Thread.java:613) Caused by: java.lang.ClassNotFoundException: com.caucho.naming.InitialContextFactoryImpl at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:316) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:242) at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654) ... 10 more -- View this message in context: http://old.nabble.com/Maven-classpath-question-tp27066744p27066744.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Maven classpath question
However, when I run my JUnit test, I get the ClassNotFoundException below. The reason it is strange is because that class exists within the dependency above. Can you think of some ways I can troubleshoot this problem further? Download the jar and verify this file is inside the Jar before doing anything else. I've seen similar things posted on this list more than once, and several times it turned out the Jar simply did not contain the class file(s) they thought it did... Wayne - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: classpath question
Hi, I have not tried additional classpath feature in maven2. I am not sure whether you load your xml file as following? InputStream inputStream = YourClass.class. getResourceAsStream(The relative PATH of your XML file); Thanks. Linghua 2008/12/28 Neo Anderson javadeveloper...@yahoo.co.uk I am build a project and that looks ok at the moment. However I encounter a problem when running test. My problem is that I have a customized xml. So I build a test located in the test/project/name/to/xmlTest.java, in which it will load an xml file to have a small test. The xml file is located at reousrces/project/name/to/file.xml. Unfortunately, when executing the test (via mvn package), it seems the default classpath would be the place where pom.xml exists. Therefore, if in the xmlTest.java I specify xml path like parser.parse(project/name/to/file.xml); The maven throws Running project.name.xmlTest java.io.FileNotFoundException: $HOME/path/to/pom.xml/project/name/to/file.xml (No such file or directory) I read the doc - http://maven.apache.org/plugins/maven-surefire-plugin/examples/additional-classpath.html; seemingly I can add additional classpath whilst running test. But no luck, it still looks up the default one. I am able to specify the exactly path to solve the problem. For instance, parser.parse(src/parent_name/project/name/to/file.xml); where src/parent_name is the structure folder that will only be used when writing programme. But this is not what I want because I think that classpath should be configurable. Is any way I can configure to specify the classpath in pom.xml? Thanks in advice, - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
classpath question
I am build a project and that looks ok at the moment. However I encounter a problem when running test. My problem is that I have a customized xml. So I build a test located in the test/project/name/to/xmlTest.java, in which it will load an xml file to have a small test. The xml file is located at reousrces/project/name/to/file.xml. Unfortunately, when executing the test (via mvn package), it seems the default classpath would be the place where pom.xml exists. Therefore, if in the xmlTest.java I specify xml path like parser.parse(project/name/to/file.xml); The maven throws Running project.name.xmlTest java.io.FileNotFoundException: $HOME/path/to/pom.xml/project/name/to/file.xml (No such file or directory) I read the doc - http://maven.apache.org/plugins/maven-surefire-plugin/examples/additional-classpath.html; seemingly I can add additional classpath whilst running test. But no luck, it still looks up the default one. I am able to specify the exactly path to solve the problem. For instance, parser.parse(src/parent_name/project/name/to/file.xml); where src/parent_name is the structure folder that will only be used when writing programme. But this is not what I want because I think that classpath should be configurable. Is any way I can configure to specify the classpath in pom.xml? Thanks in advice, - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
plugin classpath question
Hi all, I have questions about he classpath of maven2 plugin: 1. How the classpath of a plugin is constructed ? 2. Is it possible to change it ? 3. Is it possible to have the generated classes of a project in the classpath of a plugin ? Thanks -- CletteBou clettebou.miniville.fr
Re: plugin classpath question
I only know the answer for 2.: StringBuilder classpath = new StringBuilder(System.getProperty(java.class.path, )); classpath.append(What-ever-you-want); System.setProperty(java.class.path, classpath.toString()); -Gisbert Guillaume Boucherie wrote: Hi all, I have questions about he classpath of maven2 plugin: 1. How the classpath of a plugin is constructed ? 2. Is it possible to change it ? 3. Is it possible to have the generated classes of a project in the classpath of a plugin ? Thanks -- Gisbert Amm Softwareentwickler Infrastruktur Telefon: (0721) 91374 - 4224 Telefax: (0721) 91374 - 2740 E-Mail: [EMAIL PROTECTED] Internet: www.1und1.de 11 Internet AG Elgendorfer Strasse 57 56410 Montabaur Amtsgericht Montabaur HRB 6484 Vorstand: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Andreas Gauger, Thomas Gottschlich, Matthias Greve, Robert Hoffmann, Norbert Lang, Achim Weiss Aufsichtsratsvorsitzender: Michael Scheeren - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Java Mojo Classpath Question
My need: To invoke a new java process from within execute(), passing new jvm parameters. But I need to pass a classpath consisting of the JDK and all the dependencies of the plugin (not of the project). Is there a way to access the current context's classpath from an invocation, or generate one from inside a mojo? I've used BCEL's classpath parser, but that just gives the things from the invoked command line. Is there another way to get a list of the path elements that comprise a particular mojo's working classpath? -- Never wear anything that panics the cat. -- P. J. O'Rourke
Re: Java Mojo Classpath Question
This is no longer critical, although I would like to know the answer if someone knows. On 7/7/06, Mykel Alvis [EMAIL PROTECTED] wrote: My need: To invoke a new java process from within execute(), passing new jvm parameters. But I need to pass a classpath consisting of the JDK and all the dependencies of the plugin (not of the project). Is there a way to access the current context's classpath from an invocation, or generate one from inside a mojo? I've used BCEL's classpath parser, but that just gives the things from the invoked command line. Is there another way to get a list of the path elements that comprise a particular mojo's working classpath? -- Never wear anything that panics the cat. -- P. J. O'Rourke -- Never wear anything that panics the cat. -- P. J. O'Rourke
RE: Another CLASSPATH question
Hi Sandeep, I don't think you have compile time dependencies on all 50 of them, or do you? For instance, in our company repository we have 6 jars that are connected to CICS ECI. We don't have compilation dependencies on them, but we need them to run our unit tests. So I ended up installing 6 jars and I think that's doable. Marcel --- Dixit, Sandeep (ProSource Solutions) [EMAIL PROTECTED] wrote: There are about 50 jars in WAS. Do I need to install each one of them - one at a time - in my local directory? Is there a tool that can do this or why can't we have systemPath dependency accept a directory? Thanks, Sandeep -Original Message- From: Lee Meador [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 18, 2006 3:27 PM To: Maven Users List Subject: Re: Another CLASSPATH question You can load the websphere jars into your local repository. The way to do that is here: http://maven.apache.org/guides/mini/guide-installing-3rd-party-jars.html There is also the issue of getting a pom.xml to accompany it. Perhaps someone else will clarify or you can search the email archives here: http://www.nabble.com/Maven---Users-f178.html The problem is that I don't really know what to do about it. For a while you had to make your own dummy ones and then there was/is a command line option for the mvn install:install-file command that creates the dummy pom, and then there was a bug in that code and then it may/or may not have gotten into whatever build of maven. So ... you see why I hope someone more knowledgable will answer. thanks. -- Lee On 1/18/06, Dixit, Sandeep (ProSource Solutions) [EMAIL PROTECTED] wrote: I am still struggling with this. Any pointers would be highly appreciated... Thanks, Sandeep -Original Message- From: Dixit, Sandeep (ProSource Solutions) [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 18, 2006 12:57 PM To: Maven Users List Subject: Another CLASSPATH question My Maven project has a WebSphere 6 runtime library dependency. How do I provide this path during the compile time (I mean mvn install)? Thanks, Sandeep --- ***National City made the following annotations --- This communication is a confidential and proprietary business communication. It is intended solely for the use of the designated recipient(s). If this communication is received in error, please contact the sender and delete this communication. === - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- -- Lee Meador Sent from gmail. My real email address is [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Another CLASSPATH question
My Maven project has a WebSphere 6 runtime library dependency. How do I provide this path during the compile time (I mean mvn install)? Thanks, Sandeep --- ***National City made the following annotations --- This communication is a confidential and proprietary business communication. It is intended solely for the use of the designated recipient(s). If this communication is received in error, please contact the sender and delete this communication. === - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Another CLASSPATH question
I am still struggling with this. Any pointers would be highly appreciated... Thanks, Sandeep -Original Message- From: Dixit, Sandeep (ProSource Solutions) [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 18, 2006 12:57 PM To: Maven Users List Subject: Another CLASSPATH question My Maven project has a WebSphere 6 runtime library dependency. How do I provide this path during the compile time (I mean mvn install)? Thanks, Sandeep --- ***National City made the following annotations --- This communication is a confidential and proprietary business communication. It is intended solely for the use of the designated recipient(s). If this communication is received in error, please contact the sender and delete this communication. === - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Another CLASSPATH question
You can load the websphere jars into your local repository. The way to do that is here: http://maven.apache.org/guides/mini/guide-installing-3rd-party-jars.html There is also the issue of getting a pom.xml to accompany it. Perhaps someone else will clarify or you can search the email archives here: http://www.nabble.com/Maven---Users-f178.html The problem is that I don't really know what to do about it. For a while you had to make your own dummy ones and then there was/is a command line option for the mvn install:install-file command that creates the dummy pom, and then there was a bug in that code and then it may/or may not have gotten into whatever build of maven. So ... you see why I hope someone more knowledgable will answer. thanks. -- Lee On 1/18/06, Dixit, Sandeep (ProSource Solutions) [EMAIL PROTECTED] wrote: I am still struggling with this. Any pointers would be highly appreciated... Thanks, Sandeep -Original Message- From: Dixit, Sandeep (ProSource Solutions) [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 18, 2006 12:57 PM To: Maven Users List Subject: Another CLASSPATH question My Maven project has a WebSphere 6 runtime library dependency. How do I provide this path during the compile time (I mean mvn install)? Thanks, Sandeep --- ***National City made the following annotations --- This communication is a confidential and proprietary business communication. It is intended solely for the use of the designated recipient(s). If this communication is received in error, please contact the sender and delete this communication. === - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- -- Lee Meador Sent from gmail. My real email address is [EMAIL PROTECTED]
RE: Another CLASSPATH question
There are about 50 jars in WAS. Do I need to install each one of them - one at a time - in my local directory? Is there a tool that can do this or why can't we have systemPath dependency accept a directory? Thanks, Sandeep -Original Message- From: Lee Meador [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 18, 2006 3:27 PM To: Maven Users List Subject: Re: Another CLASSPATH question You can load the websphere jars into your local repository. The way to do that is here: http://maven.apache.org/guides/mini/guide-installing-3rd-party-jars.html There is also the issue of getting a pom.xml to accompany it. Perhaps someone else will clarify or you can search the email archives here: http://www.nabble.com/Maven---Users-f178.html The problem is that I don't really know what to do about it. For a while you had to make your own dummy ones and then there was/is a command line option for the mvn install:install-file command that creates the dummy pom, and then there was a bug in that code and then it may/or may not have gotten into whatever build of maven. So ... you see why I hope someone more knowledgable will answer. thanks. -- Lee On 1/18/06, Dixit, Sandeep (ProSource Solutions) [EMAIL PROTECTED] wrote: I am still struggling with this. Any pointers would be highly appreciated... Thanks, Sandeep -Original Message- From: Dixit, Sandeep (ProSource Solutions) [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 18, 2006 12:57 PM To: Maven Users List Subject: Another CLASSPATH question My Maven project has a WebSphere 6 runtime library dependency. How do I provide this path during the compile time (I mean mvn install)? Thanks, Sandeep --- ***National City made the following annotations --- This communication is a confidential and proprietary business communication. It is intended solely for the use of the designated recipient(s). If this communication is received in error, please contact the sender and delete this communication. === - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- -- Lee Meador Sent from gmail. My real email address is [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[m2] plugin classpath question
Hello, Is there anyone who knows how the classpath is defined when a maven2 plug-in is run ? I expected that all the dependent jars, defined in my POM should be on the classpath, but when I print out the classpath inside my plug-in, I get: /** * @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale) */ public void executeReport(final Locale locale) throws MavenReportException { ... getLog().info( - classpath : + System.getProperty(java.class.path)); ... } output: - classpath : /opt/maven2-SNAPSHOT/core/boot/classworlds-1.1-alpha-2.jar Thanks, Mario.
RE: [m2] plugin classpath question
Thanks. In fact my plugin calls a library that loads some resources inside these libraries, so I had to switch the context classloader as follows: public void executeReport(final Locale locale) throws MavenReportException { final Thread current = Thread.currentThread(); final ClassLoader oldLoader = current.getContextClassLoader(); try { current.setContextClassLoader(BeanDocClient.class.getClassLoader()); // ... call library code here ... } catch (Exception e) { throw new MavenReportException(Unable to generate beandoc: + e.getMessage(), e); } finally { current.setContextClassLoader(oldLoader); } } Regards, Mario. -Original Message- From: Brett Porter [mailto:[EMAIL PROTECTED] Sent: Fri 8/19/2005 11:01 AM To: Maven Users List Subject: Re: [m2] plugin classpath question The plugin gets the plugin's dependencies, not the project's. Also, it uses a separate class loader, so the system classpath only reflects what was used to bootstrap Maven (classworlds). You can get the JARs for the project's artifacts using the ${project.artifacts} expression. - Brett On 8/19/05, Van Steenberghe Mario (GFDI) [EMAIL PROTECTED] wrote: Hello, Is there anyone who knows how the classpath is defined when a maven2 plug-in is run ? I expected that all the dependent jars, defined in my POM should be on the classpath, but when I print out the classpath inside my plug-in, I get: /** * @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale) */ public void executeReport(final Locale locale) throws MavenReportException { ... getLog().info( - classpath : + System.getProperty(java.class.path)); ... } output: - classpath : /opt/maven2-SNAPSHOT/core/boot/classworlds-1.1-alpha-2.jar Thanks, Mario. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [m2] plugin classpath question
Was that necessary? I assume you now have BeanDocClient as a dep on your plugin, which should make the classloader current anyway, without switching the context class loader. - Brett On 8/19/05, Van Steenberghe Mario (GFDI) [EMAIL PROTECTED] wrote: Thanks. In fact my plugin calls a library that loads some resources inside these libraries, so I had to switch the context classloader as follows: public void executeReport(final Locale locale) throws MavenReportException { final Thread current = Thread.currentThread(); final ClassLoader oldLoader = current.getContextClassLoader(); try { current.setContextClassLoader(BeanDocClient.class.getClassLoader()); // ... call library code here ... } catch (Exception e) { throw new MavenReportException(Unable to generate beandoc: + e.getMessage(), e); } finally { current.setContextClassLoader(oldLoader); } } Regards, Mario. -Original Message- From: Brett Porter [mailto:[EMAIL PROTECTED] Sent: Fri 8/19/2005 11:01 AM To: Maven Users List Subject: Re: [m2] plugin classpath question The plugin gets the plugin's dependencies, not the project's. Also, it uses a separate class loader, so the system classpath only reflects what was used to bootstrap Maven (classworlds). You can get the JARs for the project's artifacts using the ${project.artifacts} expression. - Brett On 8/19/05, Van Steenberghe Mario (GFDI) [EMAIL PROTECTED] wrote: Hello, Is there anyone who knows how the classpath is defined when a maven2 plug-in is run ? I expected that all the dependent jars, defined in my POM should be on the classpath, but when I print out the classpath inside my plug-in, I get: /** * @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale) */ public void executeReport(final Locale locale) throws MavenReportException { ... getLog().info( - classpath : + System.getProperty(java.class.path)); ... } output: - classpath : /opt/maven2-SNAPSHOT/core/boot/classworlds-1.1-alpha-2.jar Thanks, Mario. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [m2] plugin classpath question
Yes, in fact the library I'm using (Spring-beandoc) defaults to the context classloader for looking up the mapping files. Since the context classloader is by default set to the application classloader, the plug-in is responsible for switching the classloader at runtime before calling the library. This holds also true when calling other third-party libraries such as JDBC, Xerces, etc... I don't know how maven2 works internally, but wouldn't it be a good idea to let maven2 internally switch the context classloader to the plugin classloader before the plug-in is called ? Mojo mojo = final Thread current = Thread.currentThread(); final ClassLoader oldLoader = current.getContextClassLoader(); try { current.setContextClassLoader(mojo.getClass().getClassLoader()); mojo.execute(); } catch (Exception e) { throw new MavenReportException(Unable to execute mojo: + e.getMessage(), e); } finally { current.setContextClassLoader(oldLoader); } Regards, Mario. -Original Message- From: Brett Porter [mailto:[EMAIL PROTECTED] Sent: Fri 8/19/2005 12:41 PM To: Maven Users List Subject: Re: [m2] plugin classpath question Was that necessary? I assume you now have BeanDocClient as a dep on your plugin, which should make the classloader current anyway, without switching the context class loader. - Brett On 8/19/05, Van Steenberghe Mario (GFDI) [EMAIL PROTECTED] wrote: Thanks. In fact my plugin calls a library that loads some resources inside these libraries, so I had to switch the context classloader as follows: public void executeReport(final Locale locale) throws MavenReportException { final Thread current = Thread.currentThread(); final ClassLoader oldLoader = current.getContextClassLoader(); try { current.setContextClassLoader(BeanDocClient.class.getClassLoader()); // ... call library code here ... } catch (Exception e) { throw new MavenReportException(Unable to generate beandoc: + e.getMessage(), e); } finally { current.setContextClassLoader(oldLoader); } } Regards, Mario. -Original Message- From: Brett Porter [mailto:[EMAIL PROTECTED] Sent: Fri 8/19/2005 11:01 AM To: Maven Users List Subject: Re: [m2] plugin classpath question The plugin gets the plugin's dependencies, not the project's. Also, it uses a separate class loader, so the system classpath only reflects what was used to bootstrap Maven (classworlds). You can get the JARs for the project's artifacts using the ${project.artifacts} expression. - Brett On 8/19/05, Van Steenberghe Mario (GFDI) [EMAIL PROTECTED] wrote: Hello, Is there anyone who knows how the classpath is defined when a maven2 plug-in is run ? I expected that all the dependent jars, defined in my POM should be on the classpath, but when I print out the classpath inside my plug-in, I get: /** * @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale) */ public void executeReport(final Locale locale) throws MavenReportException { ... getLog().info( - classpath : + System.getProperty(java.class.path)); ... } output: - classpath : /opt/maven2-SNAPSHOT/core/boot/classworlds-1.1-alpha-2.jar Thanks, Mario. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [m2] plugin classpath question
there are a number of ways around this though, so if you have a legitimate need to have access it can be done with a minimum of hassle. care should be taken to avoid it if you don't need it, but there are certainly circumstances where it is unavoidable. maven-jdbc-plugin and maven-execute-plugin in the mojo-sandbox are examples where you need to muck around with the classpath. the jdbc one uses the extensions/ system to bring in the db driver code it needs at plugin execution time, and the execute plugin uses its own classloader to load in the dependencies and the compiled classpath so it can instantiate the object and exec a method on it. if you need to go down that path and need some help just yell, a few of us have had to do it a lot, I have 3 custom plugins for our system that needed to do it. :) cheers, Jesse On 8/19/05, Brett Porter [EMAIL PROTECTED] wrote: Was that necessary? I assume you now have BeanDocClient as a dep on your plugin, which should make the classloader current anyway, without switching the context class loader. - Brett On 8/19/05, Van Steenberghe Mario (GFDI) [EMAIL PROTECTED] wrote: Thanks. In fact my plugin calls a library that loads some resources inside these libraries, so I had to switch the context classloader as follows: public void executeReport(final Locale locale) throws MavenReportException { final Thread current = Thread.currentThread(); final ClassLoader oldLoader = current.getContextClassLoader(); try { current.setContextClassLoader(BeanDocClient.class.getClassLoader()); // ... call library code here ... } catch (Exception e) { throw new MavenReportException(Unable to generate beandoc: + e.getMessage(), e); } finally { current.setContextClassLoader(oldLoader); } } Regards, Mario. -Original Message- From: Brett Porter [mailto:[EMAIL PROTECTED] Sent: Fri 8/19/2005 11:01 AM To: Maven Users List Subject: Re: [m2] plugin classpath question The plugin gets the plugin's dependencies, not the project's. Also, it uses a separate class loader, so the system classpath only reflects what was used to bootstrap Maven (classworlds). You can get the JARs for the project's artifacts using the ${project.artifacts} expression. - Brett On 8/19/05, Van Steenberghe Mario (GFDI) [EMAIL PROTECTED] wrote: Hello, Is there anyone who knows how the classpath is defined when a maven2 plug-in is run ? I expected that all the dependent jars, defined in my POM should be on the classpath, but when I print out the classpath inside my plug-in, I get: /** * @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale) */ public void executeReport(final Locale locale) throws MavenReportException { ... getLog().info( - classpath : + System.getProperty(java.class.path)); ... } output: - classpath : /opt/maven2-SNAPSHOT/core/boot/classworlds-1.1-alpha-2.jar Thanks, Mario. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- -- jesse mcconnell - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]