Used Bitnami Tomcat Stack to create a instance in EC2 . Everything works perfect in matter of few mins. But at final stage to deploy application maven is failing to compile the source code. Eventhoug JAVA_HOME is perfectly set it is failing to compile with below error log.
root#ip-172-31-18-89:/mnt/apps/stutzen-backend# echo $JAVA_HOME
/opt/bitnami/java
root#ip-172-31-18-89:/mnt/webapps/stutzen-backend# mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ware27 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) # ware27 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # ware27 ---
[INFO] Compiling 34 source files to /mnt/webapps/stutzen-backend/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
/opt/bitnami/java/../lib/tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.245s
[INFO] Finished at: Sun Jul 13 10:37:54 UTC 2014
[INFO] Final Memory: 6M/25M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project ware27: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] /opt/bitnami/java/../lib/tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
[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.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
How to deal with it ?
The issue is that the maven compiler plugin is configured by default to use the a Java 1.5 compiler (see the source and target options in the official documentation) while Bitnami Tomcat Stack is includes Java 1.7. You will need to configure your projects to use Java 1.7 instead. For this you can define a different value for the maven.compiler.source and maven.compiler.target properties or define the maven.compiler.compilerVersion instead which will work as well. In both cases you need to set maven.compiler.fork to true. The example below shows how to configure this per project:
pom.xml:
<project>
(...)
<properties>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
<maven.compiler.fork>true</maven.compiler.fork>
</properties>
(...)
</project>
However you will likely want to define these settings as global settings for all your projects. In that case you can edit the settings.xml in ($M2_HOME/conf/settings.xml) and define a profile which will be always actived:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" ...>
(...)
<profiles>
<profile>
<id>env-dev</id>
<properties>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
<maven.compiler.fork>true</maven.compiler.fork>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>env-dev</activeProfile>
</activeProfiles>
</settings>
kaysa's answer is correct. The solution, however, can be achieved a little easier by adding a maven-compiler-plugin to your pom as shown below:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
I'm not sure if this helps you or not. add a profile to your pom.xml :)
<profiles>
<profile>
<id>default-tools.jar</id>
<activation>
<property>
<name>java.vendor</name>
<value>Oracle Corporation</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.4.2</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
</profiles>
give your true tools.jar address and run maven with this profile
if it's not working forget that and change your java home to something like : /opt/bitnami/jdk1.7.0_51/jre:)
Related
I am working on a JavaFX project using Maven which requires the JavaFX on screen keyboard enabled. I am trying to achieve this by using the following JVM options.
-Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard=javafx
The corresponding POM sections are as fololows.
<!-- Property Definitions -->
<properties>
<jvm.options>-Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard=javafx</jvm.options>
</properties>
<!-- Compiler Plugin -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgs>
<compilerArg>${jvm.options}</compilerArg>
</compilerArgs>
</configuration>
</plugin>
The source results in a maven build failure with the following error.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.633 s
[INFO] Finished at: 2018-01-12T20:58:27+05:30
[INFO] Final Memory: 9M/153M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project pos: Fatal error compiling: invalid flag: -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard=javafx -> [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.
The flags work with the eclipse build tool (Run as -> Java Application). What have I been doing wrong? Is there any documentation on how to to set those two flags using Maven? Any help is much appreciated.
EDIT5 Updated /
I'm using Maven 3.3.3.
I just create new project and added compile and exec plugin, as examples on web.
I tried to execute, but I got error
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project QNAProject: An exception occured while executing the Java class. com.jadex.qna.QNAProject.App -> [Help 1]<br>
[ERROR] <br>
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.<br>
[ERROR] Re-run Maven using the -X switch to enable full debug logging.<br>
[ERROR] <br>
[ERROR] For more information about the errors and possible solutions, please read the following articles:<br>
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException<br>
I tried exec-maven-plugin version 1.2.1 and 1.4.0, but got same error. Here is my 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jadex.qna</groupId>
<artifactId>QNAProject</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>QNAProject</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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>maven</executable>
<mainClass>com.jadex.qna.QNAProject.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
I even tried a working example project from several sites,
such as
http://examples.javacodegeeks.com/enterprise-java/maven/create-java-project-with-maven-example/
http://www.mkyong.com/maven/how-to-create-a-java-project-with-maven/
but I got same error.
I unzipped maven at C:\apache-maven-3.3.3 and created environment variable MAVEN_HOME as same path.
What is the problem?
====================================
EDIT: Here is the result
Well.. I set MAVEN_HOME, not M2_HOME because tutorial what I found said to set it only...
Of course, echo %MAVEN_HOME% shows
C:\apache-maven-3.3.3
is it wrong?
I added %MAVEN_HOME%\bin to PATH variable, but it did not work too.
And, I'm using eclipse
=====================================
EDIT2: Here is full log. I used goal 'clean exec:java -e -X'
It was too long, so I uploaded to my blog here.
And note that I changed repository folder from C:\Users.....m2 to new local repository folder C:\apache-maven-localrepository
https://arincblossom.wordpress.com/2015/06/15/error-logs/
=======================================
EDIT3: I changed maven-compiler-plugin setting like this
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable>${env.JAVA_HOME}/bin/javac</executable>
<compilerVersion>1.5</compilerVersion>
<!-- <source>1.8</source>
<target>1.8</target> -->
</configuration>
</plugin>
It prevented me from having error from mvn -e compile exec:java but I can't run with mvn exec:java -Dexec.mainClass="com.jadex.qna.QNAProject.App"
=================================
EDIT4: OK, I'll try from the bottom, and post again. Thanks for your sincere helps.
======================================
EDIT5
I reset all the sequences... re-installed eclipse, maven.. and re-created projects... but nothing worked...
I changed eclipse settings to fix JDK path to installed jdk path, not JRE path. then I found that 'mvn -e clean compile exec:java' is working, but I want to just 'mvn clean exec:java' work. It does not work at all.
You can check full source here
https://github.com/arincblossom/MavenTestProject
This is current console message for 'mvn -e clean exec:java'
[WARNING]
[WARNING] Some problems were encountered while building the effective settings
[WARNING] expected START_TAG or END_TAG not TEXT (position: TEXT seen ...ore artifacts.\n |\n | Default: ${user.home}/.m2/repository\n <l... #53:5) # C:\apache-maven-3.3.3\conf\settings.xml, line 53, column 5
[WARNING] expected START_TAG or END_TAG not TEXT (position: TEXT seen ...ore artifacts.\n |\n | Default: ${user.home}/.m2/repository\n <l... #53:5) # C:\apache-maven-3.3.3\conf\settings.xml, line 53, column 5
[WARNING]
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenTestProject 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # MavenTestProject ---
[INFO] Deleting C:\Users\bonavision_laptop\Desktop\Project\JadeX\MavenTestProject\MavenTestProject\target
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) # MavenTestProject ---
[WARNING]
java.lang.ClassNotFoundException: com.jadex.qna.MavenTestProject.App
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:281)
at java.lang.Thread.run(Thread.java:745)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.900 s
[INFO] Finished at: 2015-06-15T17:42:19+09:00
[INFO] Final Memory: 8M/153M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java (default-cli) on project MavenTestProject: An exception occured while executing the Java class. com.jadex.qna.MavenTestProject.App -> [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.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
This issue happens, when it is not compatible with eclipse too.
Try this
mvn clean install eclipse:eclipse
Vote up, if it works to help fellow members
The error log which you posted says the following:
java.lang.ClassNotFoundException com.jadex.qna.QNAProject.App
So it clear what the root source of the error is. You are trying to execute the main() method of a class whose class file Maven cannot find. As this SO article discusses, you can try explicitly compiling first, then executing after the class file has been generated:
mvn -e compile exec:java
mvn exec:java -Dexec.mainClass="com.jadex.qna.QNAProject.App"
I ran into this same problem, it was caused by a port conflict.
my tomcat server tried to start on port 8080 but i already had a binding for it.
netstat -anto will show you port bindings 0.0.0.0:8080 or similar and it's PID this will help you determin what process is already running the port bidning, either change it in your timcat server or whatever process is using the bidning. Could be caused by an IIS, SKype or similar.
I normally build/generate the java classes file within the eclipse. However, now I need to have the project working on a machine without eclipse, so I build it directly from command line using maven. Then I got the following errors, did I miss anything here? Thanks!
Edamame$ mvn java:compile
[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (13 KB at 23.9 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (20 KB at 36.1 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.023 s
[INFO] Finished at: 2015-07-09T07:23:05-07:00
[INFO] Final Memory: 9M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'java' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/Edamame/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [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.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException
And here is the 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edamame.hadoop</groupId>
<artifactId>myProject</artifactId>
<version>1.1</version>
<packaging>pom</packaging>
<name>EdamameProject</name>
<url>http://myEdamame.com</url>
<properties>
<jdkLevel>1.7</jdkLevel>
<requiredMavenVersion>[2.1,)</requiredMavenVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.outputEncoding>UTF-8</project.build.outputEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>${jdkLevel}</source>
<target>${jdkLevel}</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
:
</repositories>
<dependencies>
:
</dependencies>
</project>
Also, here is the output of "mvn compile", it succeeded, just doesn't create target/classes folder and its classes.
Edamame$ mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myProject 1.1
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.073 s
[INFO] Finished at: 2015-07-09T08:26:12-07:00
[INFO] Final Memory: 6M/245M
[INFO] ------------------------------------------------------------------------
First you need to change the <packaging> value in your pom.xml to something other than "pom" to make Maven run the compile plugin at all. Try "jar".
Then, if you just want to compile the sources, use
mvn compile
If you want a packaged JAR, call
mvn package
See Maven Build Lifecycle and Maven POM Reference for details.
You should just go: mvn compile (or even mvn install or something like that to test it and make everything).
I wanted to add a test to my small project (please note I removed some bits from the code & changed package names, so if there's any error you see regarding this it might be not this ;)):
package my.pckg;
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class SignedRequestCallbackTest {
#Before
public void setUp() throws Exception {
}
#After
public void tearDown() throws Exception {
}
#Test
public void testCorrectSignedRequest() {
assertTrue(false);
}
}
(I also tried to extend from TestCase in order to remove the static import but it didn't help)
After running mvn test it shows me an error that it couldn't find org.junit:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Test Server 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) # server ---
[WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # server ---
[WARNING] File encoding has not been set, using platform encoding MacRoman, i.e. build is platform dependent!
[INFO] Compiling 9 source files to /Users/michael/Projects/fbmuc/server/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[4,27] package org.junit does not exist
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[6,16] package org.junit does not exist
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[7,16] package org.junit does not exist
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[8,16] package org.junit does not exist
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[14,9] cannot find symbol
symbol : class Before
location: class my.pckgSignedRequestCallbackTest
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[18,9] cannot find symbol
symbol : class After
location: class my.pckgSignedRequestCallbackTest
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[22,9] cannot find symbol
symbol : class Test
location: class my.pckgSignedRequestCallbackTest
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[24,12] cannot find symbol
symbol : method assertTrue(boolean)
location: class my.pckgSignedRequestCallbackTest
[INFO] 9 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.161s
[INFO] Finished at: Fri Feb 22 18:02:37 CET 2013
[INFO] Final Memory: 8M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project server: Compilation failure: Compilation failure:
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[4,27] package org.junit does not exist
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[4,4] static import only from classes and interfaces
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[6,16] package org.junit does not exist
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[7,16] package org.junit does not exist
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[8,16] package org.junit does not exist
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[14,9] cannot find symbol
[ERROR] symbol : class Before
[ERROR] location: class my.pckgSignedRequestCallbackTest
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[18,9] cannot find symbol
[ERROR] symbol : class After
[ERROR] location: class my.pckgSignedRequestCallbackTest
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[22,9] cannot find symbol
[ERROR] symbol : class Test
[ERROR] location: class my.pckgSignedRequestCallbackTest
[ERROR] ~/code/src/test/java/my/pckg/SignedRequestCallbackTest.java:[24,12] cannot find symbol
[ERROR] symbol : method assertTrue(boolean)
[ERROR] location: class my.pckgSignedRequestCallbackTest
[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.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
My pom.xml looks like this:
<?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>com.example</groupId>
<artifactId>server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>TestServer</name>
<description>Test</description>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Facebook library -->
<dependency>
<groupId>com.restfb</groupId>
<artifactId>restfb</artifactId>
<version>1.6.11</version>
</dependency>
<!-- Gson: Java to Json conversion -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2</version>
<scope>compile</scope>
</dependency>
<!-- Tigase server snapshot -->
<dependency>
<groupId>tigase</groupId>
<artifactId>tigase-server</artifactId>
<version>5.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>tigase</id>
<name>Tigase repository</name>
<url>http://maven.tigase.org</url>
</repository>
<repository>
<id>tigase-snapshot</id>
<name>Tigase repository</name>
<url>http://build.xmpp-test.net/maven/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>
mvn dependency:tree:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Test Server 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) # server ---
[INFO] my.pckg:server:jar:0.0.1-SNAPSHOT
[INFO] +- com.restfb:restfb:jar:1.6.11:compile
[INFO] +- com.google.code.gson:gson:jar:2.2.2:compile
[INFO] +- tigase:tigase-server:jar:5.2.0-SNAPSHOT:compile
[INFO] | +- tigase:tigase-utils:jar:3.4.1-SNAPSHOT:compile
[INFO] | \- tigase:tigase-xmltools:jar:3.4.3-SNAPSHOT:compile
[INFO] +- commons-codec:commons-codec:jar:1.7:compile
[INFO] \- junit:junit:jar:4.11:test
[INFO] \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.240s
[INFO] Finished at: Fri Feb 22 18:07:55 CET 2013
[INFO] Final Memory: 5M/81M
[INFO] ------------------------------------------------------------------------
mvn version:
Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
Maven home: /usr/share/maven
Java version: 1.6.0_41, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: de_CH, platform encoding: MacRoman
OS name: "mac os x", version: "10.8.2", arch: "x86_64", family: "mac"
Please note that I'm not an expert in java nor in maven, just getting started (especially with maven).
From what I've seen from other articles and questions, I should have my tests within src/test/java and my "real" code within src/main/java - I have done it like this.
Also I removed once the whole ~/.m2/ folder and it still didn't work.
I also did run mvn test -X but it didn't help me. If I should post it please tell me so.
You shouldn't override your <sourceDirectory> setting in the POM's <build> element unless you have a good reason to. This attribute determines where Maven looks for non-test code. The default value for this attribute is src/main/java. The <testSourceDirectory> attribute sets the path to test code (this defaults to src/test/java. By setting the <sourceDirectory> to simply src, Maven considers that entire directory to contain main application code. Since the src directory contains src/test/java, Maven then tries to compile your test code as part of the main application.
This is significant because when compiling the main application (during the compile phase), Maven omits dependencies with test scope. Test code is compiled in a separate phase (the test-compile phase) after the main compile.
So since Maven tried to compile your test code as part of the main application, it omitted the junit dependency, and they weren't available on the classpath. The solution here is to simply not specify the <sourceDirectory> element in the POM.
By default , maven looks at these folders for java and test classes respectively - src/main/java and src/test/java
When the src is specified with the test classes under source and the scope for junit dependency in pom.xml is mentioned as test - org.unit will not be found by maven.
Just putting image to #matts Answer, so its easy for other to correct the problems.
<sourceDirectory>src</sourceDirectory>
just delete or comment this line present in pom.xml
<!-- <sourceDirectory>src</sourceDirectory> !-->
For explanation please go through #matt's answer
I am trying to use hbm2java maven plugins for hibernate. For mvn hibernate3:hbm2cfgxml goal I am facing following error.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building my-app-hadoop 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> hibernate3-maven-plugin:2.2:hbm2cfgxml (default-cli) # my-app-hadoop >>>
[INFO]
[INFO] <<< hibernate3-maven-plugin:2.2:hbm2cfgxml (default-cli) # my-app-hadoop <<<
[INFO]
[INFO] --- hibernate3-maven-plugin:2.2:hbm2cfgxml (default-cli) # my-app-hadoop ---
[WARNING] The POM for jdbc.artifact.groupid:jdbc-driver:jar:1.0 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.454s
[INFO] Finished at: Tue Aug 28 11:14:20 IST 2012
[INFO] Final Memory: 3M/6M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:hibernate3-maven- plugin:2.2:hbm2cfgxml (default-cli) on project my-app-hadoop: Ex
ecution default-cli of goal org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2cfgxml failed: Plugin org.codehaus.mojo:hibernate3-m
aven-plugin:2.2 or one of its dependencies could not be resolved: Failure to find jdbc.artifact.groupid:jdbc-driver:jar:1.0 in htt
p://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval
of central has elapsed or updates are forced -> [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.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
I have added following plugin configuration in POM.xml to use hbm2java capabilities.
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>jdbcconfiguration</implementation>
</component>
<component>
<name>hbm2hbmxml</name>
<outputDirectory>src/main/resources</outputDirectory>
</component>
</components>
<componentProperties>
<drop>true</drop>
<configurationfile>/src/main/resources/hibernate.cfg.xml</configurationfile>
</componentProperties>
</configuration>
<dependencies>
<dependency>
<groupId>jdbc.artifact.groupid</groupId>
<artifactId>jdbc-driver</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
Where would I find jdbc.artifact.groupid and what is missing in my pom.xml?
You must replace jdbc.artifact.groupid:jdbc-driver:1.0 by a real vendor artifact. For instance
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.2.8</version>
</dependency>
if you use hsqldb.
EDIT
As you mention you use Oracle in your comment... The jdbc jar for Oracle db is provided with your Oracle distribution. You can also download it here.Once downloaded you will have to put it manually in your local maven repo (you can also store it in the thirparty repo of you Maven Repo Manager if you have one (Nexus, Archiva...). An other way is to add the dependency by using the systemPath declaration :
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc6_g</artifactId>
<version>11.2.0.2.0</version>
<systemPath>"C:/ThirpartyJars/Oracle/ojdbc6_g.jar"</systemPath>
</dependency>
Replace your dependency
<dependency>
<groupId>jdbc.artifact.groupid</groupId>
<artifactId>jdbc-driver</artifactId>
<version>1.0</version>
</dependency>
to
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
</dependency>