Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven throws "Error injecting and NoClassDefFoundError",when i trying to build archive .sar inside .ear

Tags:

maven

jmx

sar

I have maven project. My ear archive consist from jar and war. And he builds without error. Problems began when i try to add .sar package to project. And he more not building. He throws exception. I need sar archive for using MBean, if you know other ways for using MBean, say me. Because i'm new with jmx.

Pom hierarchy:

pom.xml(super)
--pom.xml(ear)
--pom.xml(war)
--pom.xml(jar)
--pom.xml(sar)

Sar hierarchy:

src
--main
----java
------org.myproject
--------MyMBean.java
--------MyService.java
----resources
------META-INF
--------jboss-service.xml
pom.xml

super pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.myproject</groupId>
    <artifactId>logic</artifactId>
    <version>2.0</version>
    <packaging>pom</packaging>
    <properties>
        <logic.version>2.0</logic.version>
        <modul-jar.version>2.0</modul-jar.version>
        <logic-ear.version>2.0</logic-ear.version>
        <web-war.version>2.0</web-war.version>
    </properties>

    <modules>
        <module>modul-jar</module>
        <module>logic-ear</module>
        <module>web-war</module>
        <module>mbean-sar</module>
    </modules>

</project>

ear pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>logic</artifactId>
        <groupId>org.myproject</groupId>
        <version>2.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>logic-ear</artifactId>
    <groupId>org.myproject</groupId>
    <version>2.0</version>
    <packaging>ear</packaging>

    <dependencies>
        <!-- war ejb sar -->
        <dependency>
            <artifactId>web-war</artifactId>
            <groupId>org.myproject</groupId>
            <version>2.0</version>
            <type>war</type>
        </dependency>
        <dependency>
            <artifactId>modul-jar</artifactId>
            <groupId>org.myproject</groupId>
            <version>2.0</version>
            <type>ejb</type>
        </dependency>
        <dependency>
            <artifactId>mbean-sar</artifactId>
            <groupId>org.myproject</groupId>
            <version>1.0</version>
            <type>sar</type>
        </dependency>
        <!-- sar plugin -->
        <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jboss-packaging-maven-plugin</artifactId>
            <version>2.2</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-archiver</artifactId>
            <version>2.1.2</version>
        </dependency>
    </dependencies>

sar pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>logic</artifactId>
        <groupId>org.myproject</groupId>
        <version>2.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>mbean-sar</artifactId>
    <groupId>org.myproject</groupId>
    <version>1.0</version>
    <packaging>jboss-sar</packaging>

    <dependencies>
        <!-- mbean -->
        <dependency>
            <groupId>jboss</groupId>
            <artifactId>jboss-system</artifactId>
            <version>4.2.3.GA</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.mx</groupId>
            <artifactId>jboss-j2se</artifactId>
            <version>6.0.0.GA</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jboss-packaging-maven-plugin</artifactId>
                <version>2.2</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <id>jboss-sar</id>
                        <phase>package</phase>
                        <goals>
                            <goal>sar</goal>
                        </goals>
                        <configuration>
                            <primaryArtifact>false</primaryArtifact>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

Exception

[INFO] --- jboss-packaging-maven-plugin:2.2:sar (jboss-sar) @ mbean-sar ---
31.10.2012 16:39:14 org.sonatype.guice.bean.reflect.Logs$JULSink warn
WARNING: Error injecting: org.codehaus.mojo.jboss.packaging.SarMojo
java.lang.NoClassDefFoundError: Lorg/codehaus/plexus/archiver/jar/JarArchiver;
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
    at java.lang.Class.getDeclaredFields(Class.java:1743)
    at com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:651)
    at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:358)
    at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies(ConstructorBindingImpl.java:155)
    at com.google.inject.internal.InjectorImpl.getInternalDependencies(InjectorImpl.java:585)
    at com.google.inject.internal.InjectorImpl.cleanup(InjectorImpl.java:542)
    at com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:528)
    at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:833)
    at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:758)
    at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:255)
    at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:204)
    at com.google.inject.internal.InjectorImpl.getProviderOrThrow(InjectorImpl.java:954)
    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:987)
    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:950)
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1000)
    at org.sonatype.guice.bean.reflect.AbstractDeferredClass.get(AbstractDeferredClass.java:45)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:84)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:52)
    at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:70)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:100)
    at org.sonatype.guice.plexus.lifecycles.PlexusLifecycleManager.onProvision(PlexusLifecycleManager.java:138)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:108)
    at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:55)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
    at com.google.inject.internal.InjectorImpl$3$1.call(InjectorImpl.java:965)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1011)
    at com.google.inject.internal.InjectorImpl$3.get(InjectorImpl.java:961)
    at com.google.inject.Scopes$1$1.get(Scopes.java:59)
    at org.sonatype.guice.bean.locators.LazyBeanEntry.getValue(LazyBeanEntry.java:83)
    at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:49)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:253)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:245)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:455)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:92)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.archiver.jar.JarArchiver
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
    ... 63 more

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] logic ............................................. SUCCESS [0.159s]
[INFO] modul-jar ......................................... SUCCESS [0.469s]
[INFO] web-war ........................................... SUCCESS [0.259s]
[INFO] mbean-sar ......................................... FAILURE [0.282s]
[INFO] logic-ear ......................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.350s
[INFO] Finished at: Wed Oct 31 14:03:10 GMT+04:00 2012
[INFO] Final Memory: 7M/16M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:jboss-packaging-maven-plugin:2.2:sar (default-sar) on project mbean-sar
: Execution default-sar of goal org.codehaus.mojo:jboss-packaging-maven-plugin:2.2:sar failed: A required class was miss
ing while executing org.codehaus.mojo:jboss-packaging-maven-plugin:2.2:sar: Lorg/codehaus/plexus/archiver/jar/JarArchive
r;
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.codehaus.mojo:jboss-packaging-maven-plugin:2.2
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/birukov/.m2/repository/org/codehaus/mojo/jboss-packaging-maven-plugin/2.2/jboss-packagi
ng-maven-plugin-2.2.jar
[ERROR] urls[1] = file:/C:/Users/birukov/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[project>org.myproject:mbean-sar:1.0, parent: ClassRealm[maven.api, p
arent: null]]]
[ERROR]
[ERROR] -----------------------------------------------------: org.codehaus.plexus.archiver.jar.JarArchiver

I tryed to place jboss-packaging-maven-plugin plugin and dependency in super-pom, ear-pom and sar-pom. This has no effect. I many think about missing and duplicate artifacts. Where problems?

like image 388
Vladislav Biryukov Avatar asked Oct 31 '12 13:10

Vladislav Biryukov


1 Answers

Can you try two things:

  1. Delete everything under ~/.m2/repository/ [in case the local repo is corrupted the specific class]
  2. Try with another version of the plugin for instance:

<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jboss-packaging-maven-plugin</artifactId> <version>2.1.1</version> <!-- Enable packaging types and lifecycle bindings. --> <extensions>true</extensions> ... </plugin>

like image 147
Santanu Dey Avatar answered Oct 22 '22 01:10

Santanu Dey