MrJustMax
MrJustMax

Reputation: 1

MAVEN, Netbeans Platform : Could not find the main class

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.

Upvotes: 0

Views: 975

Answers (1)

MrJustMax
MrJustMax

Reputation: 1

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.

Upvotes: 0

Related Questions