As a polyglot maven user, I have maven configuration snippet written in xml
For example
Listing 1. Using maven-jar-plugin to modify MANIFEST.MF
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.mypackage.MyClass</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
taken from http://www.ibm.com/developerworks/library/j-5things13/
How can I use it in ,say, my pom.yaml ?
straightforward translation fails
$ mvn io.takari.polyglot:polyglot-translate-plugin:translate -Dinput=maven-jar-plugin.xml -Doutput=maven-jar-plugin.yaml
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-translating-snippets 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- polyglot-translate-plugin:0.1.15:translate (default-cli) # maven-translating-snippets ---
[INFO] Translating D:\Workspaces\STS-373\maven-translating-snippets\maven-jar-plugin.xml -> D:\Workspaces\STS-373\maven-translating-snippets\maven-jar-plugin.yaml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.466 s
[INFO] Finished at: 2016-04-19T10:00:29+08:00
[INFO] Final Memory: 6M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.takari.polyglot:polyglot-translate-plugin:0.1.15:translate (default-cli) on project maven-translating-snippets: Error translating maven-jar-plugin.xml -> maven-jar-plugin.yaml: Expected root element 'project' but found 'plugin' (position: START_TAG seen \t\t\t<plugin>... #1:11) -> [Help 1]
[ERROR]
I was able to migrate my pom.xml using the official doc
I wrote something about how I did it and the problems I encountered here
Related
I'm trying to make my Discord bot to work on Heroku but I keep getting an error. The build process works fine but the bot doesn't go online. I went to Resources --> More --> View Logs and saw an error. I understood the error as some methods not getting recognized and I removed the error one. But another one would just pop up. The code and bot works on local using IntelliJ. Anyone can help me with this please?
The error/Resource logs:
2021-04-18T23:58:17.202220+00:00 app[Worker.1]: location: class Main
2021-04-18T23:58:17.226725+00:00 app[Worker.1]: src/main/java/Main.java:9: error: cannot find symbol
2021-04-18T23:58:17.226770+00:00 app[Worker.1]: jda.setActivity(Activity.listening("!help"));
2021-04-18T23:58:17.226835+00:00 app[Worker.1]: ^
2021-04-18T23:58:17.226906+00:00 app[Worker.1]: symbol: variable Activity
2021-04-18T23:58:17.226942+00:00 app[Worker.1]: location: class Main
2021-04-18T23:58:17.228071+00:00 app[Worker.1]: 5 errors
2021-04-18T23:58:17.230942+00:00 app[Worker.1]: error: compilation failed
2021-04-18T23:58:17.336252+00:00 heroku[Worker.1]: Process exited with status 1
2021-04-18T23:58:17.440163+00:00 heroku[Worker.1]: State changed from up to crashed
Build/Deploy logs:
-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/java
-----> Java app detected
-----> Installing JDK 15... done
-----> Installing Maven 3.6.2... done
-----> Executing Maven
$ mvn -DskipTests clean dependency:list install
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< org.example:CalciteDiscordBot >--------------------
[INFO] Building CalciteDiscordBot 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # CalciteDiscordBot ---
[INFO] Deleting /tmp/build_6a1072dc/target
[INFO]
[INFO] --- maven-dependency-plugin:2.8:list (default-cli) # CalciteDiscordBot ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # CalciteDiscordBot ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /tmp/build_6a1072dc/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # CalciteDiscordBot ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 21 source files to /tmp/build_6a1072dc/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # CalciteDiscordBot ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /tmp/build_6a1072dc/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # CalciteDiscordBot ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # CalciteDiscordBot ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # CalciteDiscordBot ---
[INFO] Building jar: /tmp/build_6a1072dc/target/CalciteDiscordBot-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # CalciteDiscordBot ---
[INFO] Installing /tmp/build_6a1072dc/target/CalciteDiscordBot-1.0-SNAPSHOT.jar to /tmp/codon/tmp/cache/.m2/repository/org/example/CalciteDiscordBot/1.0-SNAPSHOT/CalciteDiscordBot-1.0-SNAPSHOT.jar
[INFO] Installing /tmp/build_6a1072dc/pom.xml to /tmp/codon/tmp/cache/.m2/repository/org/example/CalciteDiscordBot/1.0-SNAPSHOT/CalciteDiscordBot-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.854 s
[INFO] Finished at: 2021-04-18T23:57:57Z
[INFO] ------------------------------------------------------------------------
-----> Discovering process types
Procfile declares types -> Worker
-----> Compressing...
Done: 76.7M
-----> Launching...
Released v23
https://calcitediscordbot.herokuapp.com/ deployed to Heroku
Main.java
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.entities.Activity;
import javax.security.auth.login.LoginException;
public class Main {
public static void main(String[] args) throws LoginException {
JDABuilder jda = JDABuilder.createDefault("I inserted token here");
jda.setActivity(Activity.listening("!help"));
jda.build();
}
}
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>CalciteDiscordBot</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.target>15</maven.compiler.target>
<maven.compiler.source>15</maven.compiler.source>
</properties>
<dependencies>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.2.0_246</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jcenter</id>
<name>jcenter-bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories>
</project>
Procfile:
Worker: java src/main/java/Main.java
If you run locally with an IDE like IntelliJ, it will handle things like this to you, but you need add a plugin to create a jar with dependencies before deploying it.
<?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>CalciteDiscordBot</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>...</properties>
<dependencies>...</dependencies>
<repositories>...</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>
Main
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
To fix this problem, you'd have to change the pom.xml and Procfile.
Add this line to the pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>2.1.0</version>
<configuration>
<assembleDirectory>target</assembleDirectory>
<programs>
<program>
<mainClass>MAIN_CLASS_PATH</mainClass>
<name>BOT_NAME</name>
</program>
</programs>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin>
Add this inside of your plugins tag in your build tag. Change MAIN_CLASS_PATH to your own main class and change BOT_NAME to your project's/bot's name.
Change the Worker for the Procfile to this:
worker: sh target/bin/BOT_NAME
Same thing here ^, change BOT_NAME to your project's/bot's name.
Most credit goes to BooleanCube's Discord. And thank you #Kaneda for the help!
I am trying to run following command on following project:
mvn clean package nbm:cluster nbm:run-ide
Project URL: https://github.com/mulesoft-labs/mule-netbeans (Netbeans Support for Mule)
I tried it on Apanche Maven 3.0.4 and 3.0.5 but unable to run it.
I tried it with Java 6, Java 7 and Java 8.
With Java 7 and Java 8 i am getting following issues:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Mule Netbeans XML
[INFO] Mule Support Plugin
[INFO] Mule Tools for NetBeans
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Mule Netbeans XML 0.5
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # mule-netbeans-xml ---
[INFO] Deleting D:\mule-netbeans-master\mule-netbeans-xml\target
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # mule-netbeans-xml ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\mule-netbeans-master\mule-netbeans-xml\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # mule-netbeans-xml ---
[INFO] Compiling 2 source files to D:\mule-netbeans-master\mule-netbeans-xml\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] D:\mule-netbeans-master\mule-netbeans-xml\src\main\java\org\mule\tooling\netbeans\xml\UserCatalogProcessor.java:[38,37] error: cannot find symbol
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Skipping Mule Tools for NetBeans
[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Mule Netbeans XML ................................. FAILURE [1.471s]
[INFO] Mule Support Plugin ............................... SKIPPED
[INFO] Mule Tools for NetBeans ........................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.154s
[INFO] Finished at: Thu May 04 08:53:45 IST 2017
[INFO] Final Memory: 15M/220M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project mule-netbeans-xml: Compilation failure
[ERROR] D:\mule-netbeans-master\mule-netbeans-xml\src\main\java\org\mule\tooling\netbeans\xml\UserCatalogProcessor.java:[38,37] error: cannot find symbol
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
With Java 6, i am getting following:
Failure executing javac, but could not parse the error:
javac: invalid target release: 1.7
Usage: javac <options> <source files>
use -help for a list of possible options
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.mule.tooling.netbeans</groupId>
<artifactId>mule-netbeans</artifactId>
<name>Mule Tools for NetBeans</name>
<description>NetBeans Support for Mule</description>
<version>1.1</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<netbeans-version>RELEASE82</netbeans-version>
</properties>
<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://opensource.org/licenses/Apache-2.0</url>
</license>
</licenses>
<build>
<pluginManagement>
<plugins>
<plugin>
<!-- NetBeans 6.9+ requires JDK 6, starting NetBeans 7.4 source 1.7 is required -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<modules>
<!--<module>mule-netbeans-runtime</module>-->
<!--<module>mule-netbeans-api</module>-->
<!--<module>mule-netbeans-config</module>-->
<module>mule-netbeans-xml</module>
<module>mule-netbeans-plugin</module>
</modules>
<repositories>
<repository>
<id>netbeans</id>
<name>Repository hosting NetBeans modules</name>
<url>http://bits.netbeans.org/nexus/content/groups/netbeans</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
Could anyone assist where i am doing wrong?
try to change to maven2 and you have to add this additional info in the pom:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerVersion>1.5</compilerVersion>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
Done following Changes to execute it perfectly.
Java 8, Apache Maven 3.0.5
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
Output:
Scanning for projects...
------------------------------------------------------------------------
Reactor Build Order:
Mule Netbeans XML
Mule Support Plugin
Mule Tools for NetBeans
------------------------------------------------------------------------
Building Mule Netbeans XML 0.5
------------------------------------------------------------------------
--- maven-clean-plugin:2.4.1:clean (default-clean) # mule-netbeans-xml ---
Deleting D:\mule-netbeans-master\mule-netbeans-xml\target
--- maven-resources-plugin:2.5:resources (default-resources) # mule-netbeans-xml ---
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory D:\mule-netbeans-master\mule-netbeans-xml\src\main\resources
--- maven-compiler-plugin:2.5.1:compile (default-compile) # mule-netbeans-xml ---
Compiling 2 source files to D:\mule-netbeans-master\mule-netbeans-xml\target\classes
--- maven-resources-plugin:2.5:testResources (default-testResources) # mule-netbeans-xml ---
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory D:\mule-netbeans-master\mule-netbeans-xml\src\test\resources
--- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) # mule-netbeans-xml ---
No sources to compile
--- maven-surefire-plugin:2.15:test (default-test) # mule-netbeans-xml ---
Tests are skipped.
--- maven-jar-plugin:2.4:jar (default-jar) # mule-netbeans-xml ---
Building jar: D:\mule-netbeans-master\mule-netbeans-xml\target\mule-netbeans-xml-0.5.jar
--- maven-install-plugin:2.3.1:install (default-install) # mule-netbeans-xml ---
Installing D:\mule-netbeans-master\mule-netbeans-xml\target\mule-netbeans-xml-0.5.jar to C:\Users\harpreetsi\.m2\repository\org\mule\tooling\netbeans\mule-netbeans-xml\0.5\mule-netbeans-xml-0.5.jar
Installing D:\mule-netbeans-master\mule-netbeans-xml\pom.xml to C:\Users\harpreetsi\.m2\repository\org\mule\tooling\netbeans\mule-netbeans-xml\0.5\mule-netbeans-xml-0.5.pom
------------------------------------------------------------------------
Building Mule Support Plugin 0.8-SNAPSHOT
------------------------------------------------------------------------
--- maven-clean-plugin:2.4.1:clean (default-clean) # mule-netbeans-plugin ---
Deleting D:\mule-netbeans-master\mule-netbeans-plugin\target
--- maven-resources-plugin:2.6:resources (default-resources) # mule-netbeans-plugin ---
Using 'UTF-8' encoding to copy filtered resources.
Copying 39 resources
--- maven-compiler-plugin:2.5.1:compile (default-compile) # mule-netbeans-plugin ---
Compiling 63 source files to D:\mule-netbeans-master\mule-netbeans-plugin\target\classes
--- nbm-maven-plugin:4.0.1:manifest (default-manifest) # mule-netbeans-plugin ---
NBM Plugin generates manifest
Adding on module's Class-Path:
org.mule.tooling.netbeans:mule-netbeans-xml:jar:0.5
org.jdesktop:beansbinding:jar:1.2.1
--- maven-resources-plugin:2.6:testResources (default-testResources) # mule-netbeans-plugin ---
Using 'UTF-8' encoding to copy filtered resources.
Copying 12 resources
--- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) # mule-netbeans-plugin ---
Compiling 2 source files to D:\mule-netbeans-master\mule-netbeans-plugin\target\test-classes
--- maven-surefire-plugin:2.15:test (default-test) # mule-netbeans-plugin ---
Tests are skipped.
--- maven-jar-plugin:2.4:jar (default-jar) # mule-netbeans-plugin ---
Adding existing MANIFEST to archive. Found under: D:\mule-netbeans-master\mule-netbeans-plugin\target\classes\META-INF\MANIFEST.MF
Building jar: D:\mule-netbeans-master\mule-netbeans-plugin\target\mule-netbeans-plugin-0.8-SNAPSHOT.jar
--- nbm-maven-plugin:4.0.1:branding (default-branding) # mule-netbeans-plugin ---
No branding to process.
--- nbm-maven-plugin:4.0.1:nbm (default-nbm) # mule-netbeans-plugin ---
Copying module JAR to D:\mule-netbeans-master\mule-netbeans-plugin\target\nbm\netbeans\mule\modules with manifest updates
Generating Auto Update information for org.mule.tooling.netbeans
No updater.jar specified, cannot validate Info.xml against DTD
Building jar: D:\mule-netbeans-master\mule-netbeans-plugin\target\nbm\mule-netbeans-plugin-0.8-SNAPSHOT.nbm
--- maven-install-plugin:2.5:install (default-install) # mule-netbeans-plugin ---
Installing D:\mule-netbeans-master\mule-netbeans-plugin\target\mule-netbeans-plugin-0.8-SNAPSHOT.jar to C:\Users\harpreetsi\.m2\repository\org\mule\tooling\netbeans\mule-netbeans-plugin\0.8-SNAPSHOT\mule-netbeans-plugin-0.8-SNAPSHOT.jar
Installing D:\mule-netbeans-master\mule-netbeans-plugin\pom.xml to C:\Users\harpreetsi\.m2\repository\org\mule\tooling\netbeans\mule-netbeans-plugin\0.8-SNAPSHOT\mule-netbeans-plugin-0.8-SNAPSHOT.pom
Installing D:\mule-netbeans-master\mule-netbeans-plugin\target\mule-netbeans-plugin-0.8-SNAPSHOT.nbm to C:\Users\harpreetsi\.m2\repository\org\mule\tooling\netbeans\mule-netbeans-plugin\0.8-SNAPSHOT\mule-netbeans-plugin-0.8-SNAPSHOT.nbm
------------------------------------------------------------------------
Building Mule Tools for NetBeans 1.1
------------------------------------------------------------------------
--- maven-clean-plugin:2.4.1:clean (default-clean) # mule-netbeans ---
--- maven-install-plugin:2.3.1:install (default-install) # mule-netbeans ---
Installing D:\mule-netbeans-master\pom.xml to C:\Users\harpreetsi\.m2\repository\org\mule\tooling\netbeans\mule-netbeans\1.1\mule-netbeans-1.1.pom
------------------------------------------------------------------------
Reactor Summary:
Mule Netbeans XML ................................. SUCCESS [5.716s]
Mule Support Plugin ............................... SUCCESS [23.561s]
Mule Tools for NetBeans ........................... SUCCESS [0.069s]
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 33.336s
Finished at: Thu May 04 09:30:43 IST 2017
Final Memory: 30M/394M
------------------------------------------------------------------------
You need to set JAVA_HOME to your jdk7 home directory, for example on Microsoft Windows:
"C:\Program Files\Java\jdk1.7.0_40"
or on OS X:
/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home
When i try to run my .jar the classes cannot be found?
Its a basic app, contains 2 custom classes and commons-lang
The .jar contains classes for commons-lang but not for my java classes.
rob#work:~/git/ProjectName/target$ java -jar uber-ProjectName-1.0-SNAPSHOT.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/test/server/Main
Caused by: java.lang.ClassNotFoundException: com.test.server.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: com.test.server.Main. Program will exit.
This is pom.xml
<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>com.test.server</groupId>
<artifactId>ProjectName</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>thisisatest</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>com.test.server.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<finalName>uber-${artifactId}-${version}</finalName>
</configuration>
</plugin>
</plugins>
</build>
</project>
build output ..
rob#work:~/git/ProjectName$ mvn package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building thisisatest
[INFO] task-segment: [package]
[INFO] ------------------------------------------------------------------------
[INFO] Ignoring available plugin update: 2.3 as it requires Maven version 3.0
[INFO] Ignoring available plugin update: 2.2 as it requires Maven version 3.0
[INFO] Ignoring available plugin update: 2.1 as it requires Maven version 3.0
[INFO] Ignoring available plugin update: 2.0 as it requires Maven version 3.0
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/rob/git/ProjectName/src/main/resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] No sources to compile
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/rob/git/ProjectName/src/test/resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] No sources to compile
[INFO] [surefire:test {execution: default-test}]
[INFO] No tests to run.
[INFO] Surefire report directory: /home/rob/git/ProjectName/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] [jar:jar {execution: default-jar}]
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: /home/rob/git/ProjectName/target/ProjectName-1.0-SNAPSHOT.jar
[INFO] [shade:shade {execution: default}]
[INFO] Including commons-lang:commons-lang:jar:2.3 in the shaded jar.
[INFO] Replacing /home/rob/git/ProjectName/target/uber-ProjectName-1.0-SNAPSHOT.jar with /home/rob/git/ProjectName/target/ProjectName-1.0-SNAPSHOT-shaded.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue May 06 22:23:33 IST 2014
[INFO] Final Memory: 17M/179M
[INFO] ------------------------------------------------------------------------
[INFO] [compiler:compile {execution: default-compile}]
[INFO] No sources to compile
Maven can't find any code to compile. This looks very suspicious. Perhaps your maven project is not configured like a maven project should be and it can't find the source. See the project structure diagram from maven.
[INFO] [compiler:compile {execution: default-compile}]
[INFO] No sources to compile
Maven isn't finding your sources, you may not have the directory structure correct. Take a read through http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
I encountered this issue when I had an extra space before the "main" folder. You can check your folder structure and see if it's correct.
i try to generate wsdl file using jaxws maven plugin
finaly:"successfully building" but my wsdl file is not generate, it is normaly in the folder \target\surefire-reports
but i don't have it after the building
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building BSCSwebservices Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.sun.xml.stream.buffer:streambuffer:jar:0.4 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.jvnet.staxex:stax-ex:jar:1.0 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # BSCSwebservices ---
[debug] execute contextualize
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 6 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # BSCSwebservices ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) # BSCSwebservices ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\sayed\workspace\BSCSwebservices\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) # BSCSwebservices ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) # BSCSwebservices ---
[INFO] Surefire report directory: C:\Users\sayed\workspace\BSCSwebservices\target\surefire-reports
T E S T S
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-war-plugin:2.1.1:war (default-war) # BSCSwebservices ---
[INFO] Packaging webapp
[INFO] Assembling webapp [BSCSwebservices] in [C:\Users\sayed\workspace\BSCSwebservices\target\BSCSwebservices]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\Users\sayed\workspace\BSCSwebservices\src\main\webapp]
[INFO] Webapp assembled in [1042 msecs]
[INFO] Building war: C:\Users\sayed\workspace\BSCSwebservices\target\BSCSwebservices.war
[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored
(webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true')
[INFO]
[INFO] --- jaxws-maven-plugin:1.11:wsgen (default) # BSCSwebservices ---
warning: The apt tool and its associated API are planned to be
removed in the next major JDK release. These features have been
superseded by javac and the standardized annotation processing API,
javax.annotation.processing and javax.lang.model. Users are
recommended to migrate to the annotation processing features of
javac; see the javac man page for more information.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:30.437s
[INFO] Finished at: Fri Aug 02 23:00:03 WAT 2013
[INFO] Final Memory: 16M/40M
[INFO] ------------------------------------------------------------------------
this a part of pom.xml
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.11</version>
<executions>
<execution>
<configuration>
<sei>com.ws.BillingAccountRead</sei>
<genwsdl>true</genwsdl>
<keep>true</keep>
</configuration>
<phase>package</phase>
<goals>
<goal>wsgen</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
when i use mvn clean package -X
<configuration>
<destDir default-value="${project.build.outputDirectory}"/>
<extension default-value="false"/>
<genWsdl default-value="false"/>
<keep default-value="false">true</keep>
<pluginArtifactMap>${plugin.artifactMap}</pluginArtifactMap>
<pluginArtifacts>${plugin.artifacts}</pluginArtifacts>
<project>${project}</project>
<resourceDestDir default-value="${project.build.directory}/jaxws/wsgen/wsdl"/>
<sei>com.ws.BillingAccountRead</sei>
<verbose default-value="false">true</verbose>
</configuration>
I would think you would want to build the wsdl in the 'generate-sources' phase or maybe 'generate-resources' instead of 'package'
It is supposed to generate the wsdl in ${resourceDestDir}
Configure it like below with verbose = true, and execute the mvn command with -X flag, then look the maven log carefully.
<executions>
<execution>
<configuration>
<sei>com.ws.BillingAccountRead</sei>
<genwsdl>true</genwsdl>
<keep>true</keep>
<verbose>true</verbose>
</configuration>
<phase>package</phase>
<goals>
<goal>wsgen</goal>
</goals>
</execution>
</executions>
Try to build using -X or -e to get more info from the log
We have the following config in our POM file:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>surefire-it</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
This ensures that the tests are not executed during test phase. Tests are executed only during integration-test phase.
However, when we prepare for release (release:prepare), maven executes the tests during test phase. This causes our build to fail because our tests can be run only during Integration test phase (we use tomcat-maven plugin to deploy the packaged war before the tests can be executed).
I know that we can skip the tests by passing the parameter (-DskipTests etc.). We do not want to skip any tests, we just want release:prepare to execute just like any other maven goal.
Any suggestion/help is highly appreciated.
Try with the more general approach to disable the maven-surefire-plugin completely during test phase.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>default-test</id>
<!-- Disable the default-test by putting it in phase none -->
<phase>none</phase>
</execution>
<execution>
<!-- Enable the test during integration-test phase -->
<id>surefire-it</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
Edit
This is the output from my dry run of mvn release:prepare with the above configured surefire plugin:
C:\Users\maba\Development\svn\local\stackoverflow\Q12840869>mvn release:prepare -DdryRun
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Q12840869-1.0-SNAPSHOT 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-release-plugin:2.0:prepare (default-cli) # Q12840869 ---
[INFO] Resuming release from phase 'scm-check-modifications'
[INFO] Verifying that there are no local modifications...
[INFO] Executing: cmd.exe /X /C "svn --non-interactive status"
[INFO] Working directory: C:\Users\maba\Development\svn\local\stackoverflow\Q12840869
[INFO] Checking dependencies and plugins for snapshots ...
What is the release version for "Q12840869-1.0-SNAPSHOT"? (com.stackoverflow:Q12840869) 1.0: :
What is SCM release tag or label for "Q12840869-1.0-SNAPSHOT"? (com.stackoverflow:Q12840869) Q12840869-1.0: :
What is the new development version for "Q12840869-1.0-SNAPSHOT"? (com.stackoverflow:Q12840869) 1.1-SNAPSHOT: :
[INFO] Transforming 'Q12840869-1.0-SNAPSHOT'...
[INFO] Not generating release POMs
[INFO] Executing preparation goals - since this is simulation mode it is running against the original project, not the rewritten ones
[INFO] Executing goals 'clean verify'...
[WARNING] Maven will be executed in interactive mode, but no input stream has been configured for this MavenInvoker instance.
[INFO] [INFO] Scanning for projects...
[INFO] [INFO]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building Q12840869-1.0-SNAPSHOT 1.0-SNAPSHOT
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO]
[INFO] [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # Q12840869 ---
[INFO] [INFO] Deleting C:\Users\maba\Development\svn\local\stackoverflow\Q12840869\target
[INFO] [INFO]
[INFO] [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) # Q12840869 ---
[INFO] [INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] [INFO] Copying 0 resource
[INFO] [INFO]
[INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # Q12840869 ---
[INFO] [INFO] Compiling 1 source file to C:\Users\maba\Development\svn\local\stackoverflow\Q12840869\target\classes
[INFO] [INFO]
[INFO] [INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) # Q12840869 ---
[INFO] [INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] [INFO] skip non existing resourceDirectory C:\Users\maba\Development\svn\local\stackoverflow\Q12840869\src\test\resources
[INFO] [INFO]
[INFO] [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) # Q12840869 ---
[INFO] [INFO] Compiling 1 source file to C:\Users\maba\Development\svn\local\stackoverflow\Q12840869\target\test-classes
[INFO] [INFO]
[INFO] [INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) # Q12840869 ---
[INFO] [INFO] Building jar: C:\Users\maba\Development\svn\local\stackoverflow\Q12840869\target\Q12840869-1.0-SNAPSHOT.jar
[INFO] [INFO]
[INFO] [INFO] --- maven-surefire-plugin:2.7.2:test (surefire-it) # Q12840869 ---
[INFO] [INFO] Surefire report directory: C:\Users\maba\Development\svn\local\stackoverflow\Q12840869\target\surefire
-reports
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.stackoverflow.MainTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.041 sec
[INFO]
[INFO] Results :
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESS
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 5.102s
[INFO] [INFO] Finished at: Thu Oct 11 17:10:29 CEST 2012
[INFO] [INFO] Final Memory: 13M/147M
[INFO] [INFO] ------------------------------------------------------------------------
Add your integration tests in a separate profile which isn't active by default. Add a triggerring rule or something. Then invoke the builds with the integration tests on a need by need basis. For example, on your CI (Jenkins/Hudson, TeamCity, Bamboo, etc) triggered the profile.
The problem you are currently facing is that you haven't made a separation between the two types of tests and when they should run. You have simply defined the phases you would like them to execute in. This isn't sufficient knowledge of the execution context for Maven to figure out what you would like to do and it invokes them during the release as well.
I would try an alternate approach, and try to configure the release plugin to always use -DskipTests as an argument so you don't need to specify it each time:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin<artifactId>
<configuration>
<arguments>-DskipTests</arguments>
</configuration>
</plugin>
In theory this should append -DskipTests to the arguments that the prepare and release goals pass to the sub-executions of Maven that they execute.
Use the maven-failsafe-plugin for the integration tests, and keep maven-surefire-plugin for the unit tests.
This will guarantee that the unit tests are completely segregated from the integration tests (and can therefore be turned off separately), and the integration tests are run during the "integration-test and verify phases of the build lifecycle".