Class loader error from plugin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Class loader error from plugin

Gergely Nagy
In a plugin I'm developing I depend on nexus-maven-bridge-plugin-2.6.2-01. I make use of maven-model-3.0.5 (by transitive dependency from nexus-maven-bridge-plugin), but at runtime I get a class loader error:

java.lang.LinkageError: loader constraint violation: loader (instance of org/codehaus/plexus/classworlds/realm/ClassRealm) previously initiated loading for a different type with name "org/apache/maven/model/Repository"

Doing a search in my nexus app directory I get:

maci:nexus-current greg$ find . |grep maven-model-3
./nexus/WEB-INF/lib/maven-model-3.0.5.jar
./nexus/WEB-INF/plugin-repository/nexus-indexer-lucene-plugin-2.6.2-01/dependencies/maven-model-3.0.5.jar
./nexus/WEB-INF/plugin-repository/nexus-maven-bridge-plugin-2.6.2-01/dependencies/maven-model-3.0.5.jar
./nexus/WEB-INF/plugin-repository/nexus-restlet1x-plugin-2.6.2-01/dependencies/maven-model-3.0.5.jarexus/WEB-INF/plugin-repository/nexus-restlet1x-plugin-2.6.2-01/dependencies/maven-model-3.0.5.jar

So, a jar that is available from WEB-INF/lib is also included in several plugins. Is this correct behavior?

I could make the class loader exception go away by patching nexus-maven-bridge-plugin-2.6.2-01.jar and adding shared=true to its nexus plugin.xml as so:

<classpathDependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-model</artifactId>
      <version>3.0.5</version>
      <type>jar</type>
      <shared>true</shared>
</classpathDependency>

Is this a bug or am I doing something wrong?

cheers,
Greg
bitdive team
Reply | Threaded
Open this post in threaded view
|

Re: Class loader error from plugin

Tamás Cservenák
1) maven-model is sadly in core as long as maven support is in core, is needed there
2) the other copies of model (indexer and restlet1x) are strictly private uses of it, and having them in there is okay (they do not leak out, today they just "waste" some space)
3) yes, you patch is correct, the maven bridge plugin should be sharing model dependency, as the bridge API contains classes from it (similar problem as Indexer had)


Pull requests welcome!


HTH,
~t~


On Mon, Oct 7, 2013 at 4:17 PM, Gergely Nagy <[hidden email]> wrote:
In a plugin I'm developing I depend on nexus-maven-bridge-plugin-2.6.2-01. I
make use of maven-model-3.0.5 (by transitive dependency from
nexus-maven-bridge-plugin), but at runtime I get a class loader error:

java.lang.LinkageError: loader constraint violation: loader (instance of
org/codehaus/plexus/classworlds/realm/ClassRealm) previously initiated
loading for a different type with name "org/apache/maven/model/Repository"

Doing a search in my nexus app directory I get:

maci:nexus-current greg$ find . |grep maven-model-3
./nexus/WEB-INF/lib/maven-model-3.0.5.jar
./nexus/WEB-INF/plugin-repository/nexus-indexer-lucene-plugin-2.6.2-01/dependencies/maven-model-3.0.5.jar
./nexus/WEB-INF/plugin-repository/nexus-maven-bridge-plugin-2.6.2-01/dependencies/maven-model-3.0.5.jar
./nexus/WEB-INF/plugin-repository/nexus-restlet1x-plugin-2.6.2-01/dependencies/maven-model-3.0.5.jarexus/WEB-INF/plugin-repository/nexus-restlet1x-plugin-2.6.2-01/dependencies/maven-model-3.0.5.jar

So, a jar that is available from WEB-INF/lib is also included in several
plugins. Is this correct behavior?

I could make the class loader exception go away by patching
nexus-maven-bridge-plugin-2.6.2-01.jar and adding shared=true to its nexus
plugin.xml as so:

<classpathDependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-model</artifactId>
      <version>3.0.5</version>
      <type>jar</type>
      <shared>true</shared>
</classpathDependency>

Is this a bug or am I doing something wrong?

cheers,
Greg
bitdive team



--
View this message in context: http://maven.40175.n5.nabble.com/Class-loader-error-from-plugin-tp5772645.html
Sent from the Nexus Maven Repository Manager Dev List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Class loader error from plugin

Jason Dillon-3
BTW, this should no longer be the case on master, forget when this was changed but I think it must have been post 2.6.  The nexus-bundle-maven-plugin will now automatically _ban_ dependencies were are provided by nexus-plugin-api (ie. stuff in core).

--jason



On October 7, 2013 at 7:40:10 AM, Tamás Cservenák ([hidden email]) wrote:

1) maven-model is sadly in core as long as maven support is in core, is needed there
2) the other copies of model (indexer and restlet1x) are strictly private uses of it, and having them in there is okay (they do not leak out, today they just "waste" some space)
3) yes, you patch is correct, the maven bridge plugin should be sharing model dependency, as the bridge API contains classes from it (similar problem as Indexer had)


Pull requests welcome!


HTH,
~t~


On Mon, Oct 7, 2013 at 4:17 PM, Gergely Nagy <[hidden email]> wrote:
In a plugin I'm developing I depend on nexus-maven-bridge-plugin-2.6.2-01. I
make use of maven-model-3.0.5 (by transitive dependency from
nexus-maven-bridge-plugin), but at runtime I get a class loader error:

java.lang.LinkageError: loader constraint violation: loader (instance of
org/codehaus/plexus/classworlds/realm/ClassRealm) previously initiated
loading for a different type with name "org/apache/maven/model/Repository"

Doing a search in my nexus app directory I get:

maci:nexus-current greg$ find . |grep maven-model-3
./nexus/WEB-INF/lib/maven-model-3.0.5.jar
./nexus/WEB-INF/plugin-repository/nexus-indexer-lucene-plugin-2.6.2-01/dependencies/maven-model-3.0.5.jar
./nexus/WEB-INF/plugin-repository/nexus-maven-bridge-plugin-2.6.2-01/dependencies/maven-model-3.0.5.jar
./nexus/WEB-INF/plugin-repository/nexus-restlet1x-plugin-2.6.2-01/dependencies/maven-model-3.0.5.jarexus/WEB-INF/plugin-repository/nexus-restlet1x-plugin-2.6.2-01/dependencies/maven-model-3.0.5.jar

So, a jar that is available from WEB-INF/lib is also included in several
plugins. Is this correct behavior?

I could make the class loader exception go away by patching
nexus-maven-bridge-plugin-2.6.2-01.jar and adding shared=true to its nexus
plugin.xml as so:

<classpathDependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-model</artifactId>
      <version>3.0.5</version>
      <type>jar</type>
      <shared>true</shared>
</classpathDependency>

Is this a bug or am I doing something wrong?

cheers,
Greg
bitdive team



--
View this message in context: http://maven.40175.n5.nabble.com/Class-loader-error-from-plugin-tp5772645.html
Sent from the Nexus Maven Repository Manager Dev List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]