Fail to start by maven in version 4.1.1.171 and 4.1.1.171.0.1

289 views
Skip to first unread message

Harry Chan

unread,
Mar 3, 2017, 10:30:42 AM3/3/17
to Payara Forum
Please get the test case here https://github.com/hei1233212000/payara-micro-cannot-startup

I found that after updating from 164 to 171
Caused by: java.lang.ClassNotFoundException: fish.payara.micro.boot.PayaraMicroBoot
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 22 more

will be thrown during start the swarm-micro by maven
mvn clean pakcage

Anyone has idea about it?

Steve Millidge

unread,
Mar 3, 2017, 11:34:42 AM3/3/17
to Payara Forum
I suspect this is because the Payara Micro Jar is now a nested jar and needs to have a specific boot classloader as the Thread Context Classloader. Have you tried exec:exec instead and run via java -jar?

Harry Chan

unread,
Mar 3, 2017, 9:41:32 PM3/3/17
to Payara Forum
When I run exec:exec, I encounter
Caused by: org.apache.maven.plugin.PluginParameterException: The parameters 'executable' for goal org.codehaus.mojo:exec-maven-plugin:1.5.0:exec are missing or invalid
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:641)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:594)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:121)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 26 more
Besides, I tried to NOT run the app but build an uber jar by the following pom.xml configuration
<executions>
  <execution>
      <id>payara-run</id>
      <phase>package</phase>
      <goals>
          <goal>java</goal>
      </goals>
      <configuration>
          <mainClass>fish.payara.micro.PayaraMicro</mainClass>
          <arguments>
              <argument>--deploy</argument>
              <argument>${basedir}/target/${project.build.finalName}.war</argument>
              <argument>--outputUberJar</argument>
              <argument>${basedir}/target/${project.build.finalName}.jar</argument>
          </arguments>
          <includeProjectDependencies>false</includeProjectDependencies>
          <includePluginDependencies>true</includePluginDependencies>
          <executableDependency>
              <groupId>fish.payara.extras</groupId>
              <artifactId>payara-micro</artifactId>
          </executableDependency>
      </configuration>
  </execution>
</executions>

However, it also encounter the same error as run the app by maven with clean package
Caused by: java.lang.ClassNotFoundException: fish.payara.micro.boot.PayaraMicroBoot
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 22 more

Any advice?
Thanks.


Ondrej Mihályi

unread,
Mar 4, 2017, 4:17:42 PM3/4/17
to Payara Forum
Hi, according to Steve's reply, using exec:exec is probably the only way to go (instead of exec:java), either when you run an app or build a standalone JAR.

When you tried exec:exec, how did you specify the "executable" parameter? It should point to the "java" executable. See http://www.mojohaus.org/exec-maven-plugin/examples/example-exec-for-java-programs.html.

If you want to run with exec:exec with the payara-micro.jar provided as a maven dependency, I recommend using the dependency plugin to copy the payara-micro artifact into the target directory before exec:exec is called, and then specify the parameters of exec:exec to point to that JAR, with "-jar" argument to the java command.

Here is an example of pom.xml config:

<plugin>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.6</version>
    <executions>
        <execution>
            <id>copy-payara-micro</id>
            <goals>
<goal>copy</goal>
            </goals>
            <configuration>
<outputDirectory>target</outputDirectory>
<stripVersion>true</stripVersion>
<silent>true</silent>
<artifactItems>
    <artifactItem>
        <groupId>fish.payara.extras</groupId>
        <artifactId>payara-micro</artifactId>
        <type>jar</type>
    </artifactItem>
</artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>


<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
          <execution>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
        </executions>
<configuration>
          <executable>java</executable>
          <arguments>
            <argument>-jar</argument>
            <argument>target/payara-micro.jar</argument>
            <argument>--deploy</argument>
            <argument>target/application.war</argument>
          </arguments>
        </configuration>      
</plugin>

Harry Chan

unread,
Mar 5, 2017, 10:44:54 AM3/5/17
to Payara Forum
Thanks Ondrej! I can now run the application by maven and package the uber jar.
$mvn clean package exec:exec

Besides, I think it would be better to update the GiBook User guide https://payara.gitbooks.io/payara-server/content/documentation/payara-micro/maven/maven.html.

Thank you.
Reply all
Reply to author
Forward
0 new messages