I have a Maven project mjbean which has only one dependency: TestA. Here is the pom.xml for mjbean:
<groupId>com.mbean</groupId>
<artifactId>mjbean</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Main-Class>com.mbean.Main</Main-Class>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Import-Package>*</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<name>mjbean</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.testa</groupId>
<artifactId>TestA</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
The main class is very easy:
package com.mbean;
import com.testa.Testcl;
public class Main {
public static void main(String[] args) {
Testcl tcl = new Testcl();
tcl.testmethod();
}
}
I have specified the main class <Main-Class>com.mbean.Main</Main-Class>
in maven-bundle-plugin. It runs good with Eclipse. Then I use Eclipse to generate the target bundle in the target folder. When I try to run it in command line: java -jar mjbean-0.0.1-SNAPSHOT.jar
, I got this error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/testa/Testcl
at com.mbean.Main.main(Main.java:12)
Caused by: java.lang.ClassNotFoundException: com.testa.Testcl
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
Can anyone help me with this?