I have a multi-module maven project where module A/B/C depends on module D.
Plugin maven-surefire-plugin is used for test phrase.
However,
mvn clean package
doesn't generate surefire-reports under **/target/
And
mvn clean; mvn package
could generate surefire-reports as expected.
This confused me a lot. Although the workaround for me is simply splitting to two mvn commands but I would like to know why?
Versions:
maven 3.3.3
jdk 1.7.0
maven-surefire-plugin 2.14
Root 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jzako.test</groupId>
<artifactId>FeedbackSystem</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>FeedbackSystem</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.21</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-testng</artifactId>
<version>1.6.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<modules>
<module>ModuleA</module>
<module>ModuleB</module>
<module>ModuleC</module>
<module>Utility</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14</version>
<configuration>
<forkMode>never</forkMode>
</configuration>
</plugin>
</plugins>
</build>
</project>
Module A Pom:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jzako.test</groupId>
<artifactId>FeedbackSystem</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>org.jzako.test</groupId>
<artifactId>ModuleA</artifactId>
<version>1.0-SNAPSHOT</version>
<name>ModuleA</name>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>org.jzako.test.main.LightweightFeedbackStatisticsMain</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>assembly</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>${basedir}/../conf/dev</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>${basedir}/../conf/dev</directory>
</testResource>
</testResources>
</build>
<dependencies>
<dependency>
<groupId>org.jzako.test</groupId>
<artifactId>Utility</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Multi-module Relationship
Module A/B/C depends on Utility Module and no dependencies among Module A/B/C.
Update:
It seems everything's fine for a single maven module projects. Something related to the multi-modules?
Related
I have a spring boot project (Project A) created which do contains commonly used methods and I have hosted this project in GitHub deployed artifacts and used it as a dependency in other projects (Project B, C ..) to reuse those methods. I have one common method created in Project A which does read the value from the application properties file which works fine locally but when I deploy the artifacts to GitHub and use it as a dependency it is not able to read the value from an application properties file and read as null. Maybe I am not including the properties files while deploying artifacts for Project A correctly.
pom.xml (Project A)
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.abc</groupId>
<artifactId>api-authenticator</artifactId>
<version>1.0.2</version>
<name>API Authenticator</name>
<description>Project to authenticate API usage</description>
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Staging Repository</name>
<url>file://${project.build.directory}/${version}</url>
</repository>
</distributionManagement>
<properties>
<github.global.server>github</github.global.server>
<java.version>11</java.version>
<java-jwt.version>3.16.0</java-jwt.version>
<jwks-rsa.version>0.18.0</jwks-rsa.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>${java-jwt.version}</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>jwks-rsa</artifactId>
<version>${jwks-rsa.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>resources</directory>
<targetPath>src/main/resources</targetPath>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.12</version>
<configuration>
<message>Maven artifacts for ${project.version}</message>
<noJekyll>true</noJekyll>
<outputDirectory>${project.build.directory}</outputDirectory>
<branch>refs/heads/${version}</branch>
<includes>
<include>**/*</include>
</includes>
<merge>true</merge>
<repositoryName>api-authenticator</repositoryName>
<repositoryOwner>me</repositoryOwner>
<server>github</server>
</configuration>
<executions>
<execution>
<goals>
<goal>site</goal>
</goals>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<files>
<file>
${project.basedir}/src/main/resources/application.properties
</file>
</files>
<altDeploymentRepository>
internal.repo::default::file://${project.build.directory}/${version}
</altDeploymentRepository>
</configuration>
</plugin>
</plugins>
</build>
</project>
I'm a computer science student and I'm currently making my first steps in using JEE. To retry an example of my study material, I tried to build a web-application using IntelliJ Community. As there is no offical possibility to do so with the community version, I tried to use maven following this tutorial: https://www.shortn0tes.com/2017/01/tutorial-intellij-idea-community.html
Now I get an error about the dependency injection of javax in the pom.xml:
Dependency 'javax:javaee-api:6.0' not found
Is there anything that I need to add/configure in my IntelliJ IDE? I know that the tutorial is maybe not super modern anymore, but I'd just like to follow the example of my university material.
Thank you very much!
Here my pom.xml:
<?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.example</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>test Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>test</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8888</port>
<path>/</path>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
I am learning to use Maven. So, I have created a simple program, which just parses some JSON text. For that purpose, I have used an external library "jackson", and included it as a dependency in the pom.xml file along with dependencies required by "jackson" itself, as you can see below.
<?xml version="1.0"?>
<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>alex</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>test</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jackson.version>2.9.5</jackson.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<!-- Note: core-annotations version x.y.0 is generally compatible with
(identical to) version x.y.1, x.y.2, etc. -->
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>alex.test.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
The program compiles fine when I type mvn clean package, and I can see the jar file created inside the target folder. But when I try to run that jar file by typing java -jar test-0.0.1-SNAPSHOT.jar from there, it complains that it can't find the dependencies. It gives me an error like this.
Exception in thread "main" java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapper
at alex.test.App.main(App.java:20)
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ObjectMapper
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 1 more
So, my question is, what changes I need to make, to make sure all dependencies end up inside the target folder, and I don't get this error anymore.
<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>sample</groupId>
<artifactId>com.sample.project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>com.sample.project</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.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>alex.test.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
try this as an answer change the group id it will work , the problem with your pom is you are not specifying the version of the jars that you are building
simply you can change ${jackson.version} to any version that you require and your existing pom will work
Try to add this to your pom.xml:
<project>
...
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.yourpackage.MainClass</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
It will generate a runnable jar file inside your target with all dependencies included. Be sure to set the path to your main class.
Try Maven shade plugin
<?xml version="1.0"?>
<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>alex</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>test</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jackson.version>2.9.5</jackson.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<!-- Note: core-annotations version x.y.0 is generally compatible with
(identical to) version x.y.1, x.y.2, etc. -->
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass><!-- Path to main class --></mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
This plugin will be helpful in resolving the clashes in class names with same name in multiple dependencies.
I am developing an eclipse plugin, Where i need to use the tools.jar as an dependency.As we know eclipse does not take normal jar as dependencies. so i tried to change the jar as osgi bundle. But the generated osgi bundle does not contain the com.sun packages inside.
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.7.0</version>
<scope>system</scope>
<systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>
I tried to bundle all the dependencies given in the pom.
<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>com.nuwaza.aqua</groupId>
<artifactId>osgi-tool-bundle</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.7.0</version>
<scope>system</scope>
<systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<manifestLocation>META-INF</manifestLocation>
<instructions>
<Bundle-SymbolicName>osgi-tool-bundle</Bundle-SymbolicName>
<Bundle-Name>osgi-tool-bundle</Bundle-Name>
<Bundle-Version>1.0.0</Bundle-Version>
<Export-Package>*</Export-Package>
<Private-Package>com.nuwaza.aqua.bundle</Private-Package>
<Bundle-Activator>com.nuwaza.aqua.bundle.Activator</Bundle-Activator>
<Import-Package>*;resolution:=optional</Import-Package>
<Embed-Dependency>*;scope=compile|runtime|system</Embed-Dependency>
<Embed-Directory>target/dependency</Embed-Directory>
<Embed-StripGroup>true</Embed-StripGroup>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
<profiles>
<profile>
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<properties>
<osgi-version-qualifier>qualifier</osgi-version-qualifier>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<!-- PDE does not honour custom manifest location -->
<manifestLocation>META-INF</manifestLocation>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
The generated bundle only contains org.osgi packages not com.sun packages. I even included system scope in <Embed-Dependency>*;scope=compile|runtime|system</Embed-Dependency>.
What am i missing ?
I follow this tutorial :https://platform.netbeans.org/tutorials/nbm-maven-crud.html and I have an issue.
I tried to create the sample "maven crud sample application" and my "maven netbeans application" and I get always the same error. When I run the project, I get the following exception:
--- nbm-maven-plugin:3.3:run-platform (default-cli) # application ---
Executing: /bin/sh -c "/home/pea-rep/NetBeansProjects/JDK6/test maven//MavenCRUDSample/application/target/foo/bin/foo" --userdir '"/home/pea-rep/NetBeansProjects/JDK6/test maven//MavenCRUDSample/application/target/userdir"' -J-Dnetbeans.logger.console=true -J-ea --branding foo --jdkhome /usr/local/java/jdk1.6.0_45
Exception in thread "main" java.lang.NoClassDefFoundError: maven//MavenCRUDSample/application/target/userdir/var/log/heapdump/hprof
Caused by: java.lang.ClassNotFoundException: maven.MavenCRUDSample.application.target.userdir.var.log.heapdump.hprof
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: maven/MavenCRUDSample/application/target/userdir/var/log/heapdump.hprof. Program will exit.
In this tutorial, I don't see any modification to make at the main class
I did the same tutorial without MAVEN and it works : https://platform.netbeans.org/tutorials/nbm-crud.html
With this error, I can't run my application and have my netbeans platform window. Someone knows why I have this?
I'm on Netbeans 6.9.1 with jdk1.6.0_45 and maven-3.2.1
OS : Ubuntu 64bit
edit :
I've got 4 pom.xml :
Parent : crud-sample-application – netbeans Platform Application
crud-sample-application – Netbeans Platform based application
crud-sample-application – Platform application branding ressources
crud-sample-application – sample Netbeans Module
Sorry I wasn't able to split it.
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.netbeans</groupId>
<artifactId>crud-sample-application</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>crud-sample-application - NetBeans Platform Application</name>
<repositories>
<!-- this is a remote repository hosting the netbeans api artifacts.
the versions of the artifacts are netbeans IDE release based, eg. RELEASE65
You might want to use your own repository. To create one, use the nbm:populate-repository goal.
-->
<repository>
<id>netbeans</id>
<name>repository hosting netbeans.org api artifacts</name>
<url>http://bits.netbeans.org/maven2</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-actions</artifactId>
<version>RELEASE68</version>
</dependency>
</dependencies>
<build>
<plugins>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<version>3.1</version>
<extensions>true</extensions>
<configuration>
<descriptor>src/main/nbm/module.xml</descriptor>
<brandingToken>${brandingToken}</brandingToken>
<cluster>foobar</cluster>
</configuration>
</plugin>
<!-- netbeans modules in 5.5+ are 1.5 compatible -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<modules>
<module>crudsample</module>
<module>branding</module>
<module>application</module>
</modules>
<properties>
<netbeans.version>RELEASE68</netbeans.version>
<brandingToken>foo</brandingToken>
</properties>
</project>
<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/maven-v4_0_0.xsd">
<parent>
<groupId>org.netbeans</groupId>
<artifactId>crud-sample-application</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>application</artifactId>
<packaging>nbm-application</packaging>
<version>1.0-SNAPSHOT</version>
<name>crud-sample-application - NetBeans Platform based application</name>
<dependencies>
<dependency>
<groupId>org.netbeans.cluster</groupId>
<artifactId>platform11</artifactId>
<version>${netbeans.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.netbeans</groupId>
<artifactId>crudsample</artifactId>
<version>1.0-SNAPSHOT</version>
<type>nbm</type>
</dependency>
<dependency>
<groupId>org.netbeans</groupId>
<artifactId>branding</artifactId>
<version>1.0-SNAPSHOT</version>
<type>nbm</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<version>3.3</version>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>deployment</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<executions>
<execution>
<id>updatesite</id>
<phase>package</phase>
<goals>
<goal>autoupdate</goal>
</goals>
<configuration>
<!--distBase>central::default::http://repo1.maven.org/maven2</distBase-->
</configuration>
</execution>
<execution>
<id>webstart</id>
<phase>package</phase>
<goals>
<goal>webstart-app</goal>
</goals>
<configuration>
<codebase>${project.build.directory}/webstart/${brandingToken}</codebase>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
<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/maven-v4_0_0.xsd">
<parent>
<groupId>org.netbeans</groupId>
<artifactId>crud-sample-application</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>branding</artifactId>
<packaging>nbm</packaging>
<version>1.0-SNAPSHOT</version>
<name>crud-sample-application - Platform application branding resources</name>
<dependencies>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util</artifactId>
<version>${netbeans.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<executions>
<execution>
<id>branding</id>
<phase>process-resources</phase>
<goals>
<goal>branding</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<configuration>
<!-- to have the jar plugin pickup the nbm generated manifest -->
<useDefaultManifestFile>true</useDefaultManifestFile>
</configuration>
</plugin>
</plugins>
</build>
</project>
<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/maven-v4_0_0.xsd">
<parent>
<groupId>org.netbeans</groupId>
<artifactId>crud-sample-application</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>nbm</packaging>
<version>1.0-SNAPSHOT</version>
<name>crud-sample-application - sample NetBeans Module</name>
<dependencies>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util</artifactId>
<version>RELEASE68</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-windows</artifactId>
<version>RELEASE68</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-awt</artifactId>
<version>RELEASE68</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-explorer</artifactId>
<version>RELEASE68</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-nodes</artifactId>
<version>RELEASE68</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-dialogs</artifactId>
<version>RELEASE68</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-execution</artifactId>
<version>RELEASE68</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.5.3.0_1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>nbm-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<configuration>
<!-- to have the jar plugin pickup the nbm generated manifest -->
<useDefaultManifestFile>true</useDefaultManifestFile>
</configuration>
</plugin>
</plugins>
</build>
<groupId>org.netbeans</groupId>
<artifactId>crudsample</artifactId>
<repositories>
<repository>
<url>http://ftp.ing.umu.se/mirror/eclipse/rt/eclipselink/maven.repo</url>
<id>eclipselink</id>
<layout>default</layout>
<name>Repository for library Library[eclipselink]</name>
</repository>
</repositories>
</project>
I use netbeans for run my application ==> run project :
install nbm:run-platform
run project via main() :
process-classes org.codehaus.mojo:exec-maven-plugin:1.1.1:exec
avec les arguments :
exec.classpathScope=${classPathScope}
exec.args=-classpath %classpath ${packageClassName}
exec.executable=java "
Thanks,
M.
Problem solve, When netbeans execute :
/bin/sh -c "/home/pea-rep/NetBeansProjects/JDK6/test maven//MavenCRUDSample/application/target/foo/bin/foo" --userdir '"/home/pea-rep/NetBeansProjects/JDK6/test maven//MavenCRUDSample/application/target/userdir"' -J-Dnetbeans.logger.console=true -J-ea --branding foo --jdkhome /usr/local/java/jdk1.6.0_45
It doesn't like the space between maven and test. I rename my folder and it works.