when I do a maven clean install, the compilation fails and maven reports a compilation error occurred. It does not however show the class where this happened when using groovy-eclipse-compiler. The plugin config is as below:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<!-- 2.8.0-01 and later require maven-compiler-plugin 3.0 or higher -->
<version>3.1</version>
<configuration>
<!-- Using the groovy-eclipse-compiler plugin because the gmaven plugin doesn't support compilation -->
<compilerId>groovy-eclipse-compiler</compilerId>
<!-- set verbose to be true if you want lots of uninteresting messages -->
<verbose>true</verbose>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<encoding>ISO-8859-1</encoding>
</configuration>
<dependencies>
<dependency>
<artifactId>maven-compiler-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.8.0-01</version>
</dependency>
<!-- for 2.8.0-01 and later you must have an explicit dependency on
groovy-eclipse-batch -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<!-- <version>1.8.6-01</version> -->
<!-- or choose a different compiler version -->
<version>2.1.5-03</version>
<!-- <version>1.7.10-06</version> -->
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovy.version}</version>
</dependency>
</dependencies>
</plugin>
And the output from maven is as below:
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # myproject ---
[INFO] Changes detected - recompiling the module!
[INFO] Using Groovy-Eclipse compiler to compile both Java and Groovy files
[INFO] Classpath:
[INFO] All args: []
[INFO] 17 files left.
[INFO] 16 files left.
[INFO] 15 files left.
[INFO] 14 files left.
[INFO] 13 files left.
[INFO] 12 files left.
[INFO] 11 files left.
[INFO] 10 files left.
[INFO] 9 files left.
[INFO] 8 files left.
[INFO] 7 files left.
[INFO] 6 files left.
[INFO] 5 files left.
[INFO] 4 files left.
[INFO] 3 files left.
[INFO] 2 files left.
[INFO] 1 file left.
[INFO] 0 files left.
[INFO] Compilation complete. Compiled 18 files.
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Found 1 error and 0 warnings.
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.337 s
[INFO] Finished at: 2015-08-20T17:43:11-07:00
[INFO] Final Memory: 21M/221M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project myproject: Compilation failure
[ERROR] Found 1 error and 0 warnings.
[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
Adding <showWarnings>true</showWarnings> did show up the class with the compiler error along with a bunch of other compiler warnings such as unchecked conversion etc., however an error should have shown up without having to put this.
Related
I have a project in Java + Maven. I can compile and run the code with IntelliJ just fine: each modification I do in the code gets compiled in the program. However, when I try compiling from the command line (using mvn compile), Maven doesn't recognize the changes in the code, and simply says "Nothing to compile - all classes are up to date". I can force rebuilding using mvn clean, but that invalidates the purpose of having a build system. Why is it so, and how can it detect changes in the code?
For example, say I have a working code.
I do mvn compile. It works fine and I can run the program.
I change the code and introduce a syntax error. I save the file and do mvn compile. The output is Nothing to compile, together with a BUILD SUCCESS. However, when I try to run the program, I get a Exception in thread "main" java.lang.Error: Unresolved compilation problems, along with a series of error (due to the erroneous parsing)
If I change the code to a different code, but syntactically valid, I get the same behavior.
In fact, after this, even returning to my original code compiles, but then throws a java.lang.Error exception!
Why does it work like this, and why does it work in IntelliJ, but not in terminal?
EDIT:
IntelliJ is not open. However, Emacs does start the language server (jdtls).
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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>it.polimi.middlewareB</groupId>
<artifactId>akka_actors</artifactId>
<packaging>jar</packaging>
<version>0.1 </version>
<properties>
<akka.version>2.6.19</akka.version>
<scala.binary.version>2.13</scala.binary.version>
</properties>
<name>akka_actors</name>
<url>http://maven.apache.org</url>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-bom_${scala.binary.version}</artifactId>
<version>2.6.19</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor-typed_2.13</artifactId>
<version>${akka.version}</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_${scala.binary.version}</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor-testkit-typed_2.13</artifactId>
<version>${akka.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.17.2</version>
<scope>test</scope>
</dependency>
<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.12.6.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<!-- <plugin> -->
<!-- <groupId>org.codehaus.mojo</groupId> -->
<!-- <artifactId>exec-maven-plugin</artifactId> -->
<!-- <version>1.6.0</version> -->
<!-- <configuration> -->
<!-- <executable>java</executable> -->
<!-- <arguments> -->
<!-- <argument>-classpath</argument> -->
<!-- <classpath /> -->
<!-- <argument>com.example.AkkaQuickstart</argument> -->
<!-- </arguments> -->
<!-- </configuration> -->
<!-- </plugin> -->
<!-- <plugin> -->
<!-- <groupId>org.codehaus.mojo</groupId> -->
<!-- <artifactId>exec-maven-plugin</artifactId> -->
<!-- <version>1.6.0</version> -->
<!-- <executions> -->
<!-- <execution> -->
<!-- <id>default-cli</id> -->
<!-- <configuration> -->
<!-- <mainClass>com.example.AkkaQuickstart</mainClass> -->
<!-- </configuration> -->
<!-- </execution> -->
<!-- </executions> -->
<!-- </plugin> -->
</plugins>
</build>
</project>
After mvn clean, this is the output of mvn compile:
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< it.polimi.middlewareB:akka_actors >------------------
[INFO] Building akka_actors 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # akka_actors ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) # akka_actors ---
[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 15 source files to /home/alessandro/middleware/middleware_projectB/akka_actors/target/classes
[INFO] /home/alessandro/middleware/middleware_projectB/akka_actors/src/main/java/it/polimi/middlewareB/AlwaysSeekToBeginningListener.java: /home/alessandro/middleware/middleware_projectB/akka_actors/src/main/java/it/polimi/middlewareB/AlwaysSeekToBeginningListener.java uses unchecked or unsafe operations.
[INFO] /home/alessandro/middleware/middleware_projectB/akka_actors/src/main/java/it/polimi/middlewareB/AlwaysSeekToBeginningListener.java: Recompile with -Xlint:unchecked for details.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.471 s
[INFO] Finished at: 2022-07-13T10:36:08+02:00
[INFO] ------------------------------------------------------------------------
Adding in the main .java file a line like this
public class ClusterStarter {
private static final String kafkaDefaultArgument = "localhost:9092";
private static final int actorPoolDefaultDimension = 3;
apinaosncla aifasi; //NOTE HERE
public static void main(String[] args) {
/* ... */
}
}
launching mvn compile gives:
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< it.polimi.middlewareB:akka_actors >------------------
[INFO] Building akka_actors 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # akka_actors ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) # akka_actors ---
[INFO] Nothing to compile - all classes are up to date
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.970 s
[INFO] Finished at: 2022-07-13T10:43:07+02:00
[INFO] ------------------------------------------------------------------------
However, giving first mvn clean and then mvn compile:
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< it.polimi.middlewareB:akka_actors >------------------
[INFO] Building akka_actors 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # akka_actors ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) # akka_actors ---
[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 15 source files to /home/alessandro/middleware/middleware_projectB/akka_actors/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/alessandro/middleware/middleware_projectB/akka_actors/src/main/java/it/polimi/middlewareB/ClusterStarter.java:[36,5] cannot find symbol
symbol: class apinaosncla
location: class it.polimi.middlewareB.ClusterStarter
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.966 s
[INFO] Finished at: 2022-07-13T10:43:46+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project akka_actors: Compilation failure
[ERROR] /home/alessandro/middleware/middleware_projectB/akka_actors/src/main/java/it/polimi/middlewareB/ClusterStarter.java:[36,5] cannot find symbol
[ERROR] symbol: class apinaosncla
[ERROR] location: class it.polimi.middlewareB.ClusterStarter
[ERROR]
[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
Now, returning to a working code, mvn compile still gives Nothing to compile, and launching the program gives:
/path/to/project $ /usr/lib/jvm/java-11-openjdk/bin/java -Dfile.encoding=UTF-8 -classpath /home/alessandro/middleware/middleware_projectB/akka_actors/target/classes:/home/alessandro/.m2/repository/com/typesafe/akka/akka-actor-typed_2.13/2.6.19/akka-actor-typed_2.13-2.6.19.jar:/home/alessandro/.m2/repository/org/scala-lang/scala-library/2.13.8/scala-library-2.13.8.jar:/home/alessandro/.m2/repository/com/typesafe/akka/akka-slf4j_2.13/2.6.19/akka-slf4j_2.13-2.6.19.jar:/home/alessandro/.m2/repository/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar:/home/alessandro/.m2/repository/com/typesafe/akka/akka-actor_2.13/2.6.19/akka-actor_2.13-2.6.19.jar:/home/alessandro/.m2/repository/com/typesafe/config/1.4.2/config-1.4.2.jar:/home/alessandro/.m2/repository/org/scala-lang/modules/scala-java8-compat_2.13/1.0.0/scala-java8-compat_2.13-1.0.0.jar:/home/alessandro/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/home/alessandro/.m2/repository/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/home/alessandro/.m2/repository/com/typesafe/akka/akka-actor-testkit-typed_2.13/2.6.19/akka-actor-testkit-typed_2.13-2.6.19.jar:/home/alessandro/.m2/repository/com/typesafe/akka/akka-testkit_2.13/2.6.19/akka-testkit_2.13-2.6.19.jar:/home/alessandro/.m2/repository/org/apache/kafka/kafka-clients/3.2.0/kafka-clients-3.2.0.jar:/home/alessandro/.m2/repository/com/github/luben/zstd-jni/1.5.2-1/zstd-jni-1.5.2-1.jar:/home/alessandro/.m2/repository/org/lz4/lz4-java/1.8.0/lz4-java-1.8.0.jar:/home/alessandro/.m2/repository/org/xerial/snappy/snappy-java/1.1.8.4/snappy-java-1.1.8.4.jar:/home/alessandro/.m2/repository/org/apache/logging/log4j/log4j-api/2.17.2/log4j-api-2.17.2.jar:/home/alessandro/.m2/repository/org/apache/logging/log4j/log4j-core/2.17.2/log4j-core-2.17.2.jar:/home/alessandro/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.17.2/log4j-slf4j-impl-2.17.2.jar:/home/alessandro/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar:/home/alessandro/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.12.6.1/jackson-databind-2.12.6.1.jar:/home/alessandro/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.12.6/jackson-annotations-2.12.6.jar:/home/alessandro/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.12.6/jackson-core-2.12.6.jar it.polimi.middlewareB.ClusterStarter
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
RetriesAnalysisActor cannot be resolved
JobSupervisorActor cannot be resolved
CompletedAnalysisThread cannot be resolved to a type
PendingAnalysisThread cannot be resolved to a type
at it.polimi.middlewareB.ClusterStarter.main(ClusterStarter.java:55)
(those are classes of my project)
i am running scala project .I woudld like to use maven project but , it seems doesn't recognize scala .Because before i used add scala nature now i would ike to add scala through maven , but i can't get it doesnt .i used scala 2.11.8
here is the 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>SynchData</groupId>
<artifactId>SynchData</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-catalyst_2.11</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.1.3</version>
</dependency>
<!-- <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId>
<version>9.2-1002-jdbc4</version> </dependency> -->
<!-- https://mvnrepository.com/artifact/oracle/ojdbc6 -->
<dependency>
<groupId>oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Once i make maven clean install i got this
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for SynchData:SynchData:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.apache.spark:spark-sql_2.11:jar -> duplicate declaration of version 2.2.0 # line 31, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SynchData 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # SynchData ---
[INFO] Deleting C:\Users\MHT\eclipse-workspace\test.iptech\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # SynchData ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) # SynchData ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\Users\MHT\eclipse-workspace\test.iptech\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/MHT/eclipse-workspace/test.iptech/src/main/java/LauncherPack/SynchronizeData.java:[2,1] package SynchronizePackage does not exist
[ERROR] /C:/Users/MHT/eclipse-workspace/test.iptech/src/main/java/LauncherPack/SynchronizeData.java:[10,17] cannot find symbol
symbol: variable MainFunction
location: class LauncherPack.SynchronizeData
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.277 s
[INFO] Finished at: 2017-09-26T14:29:59+01:00
[INFO] Final Memory: 36M/281M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project SynchData: Compilation failure: Compilation failure:
[ERROR] /C:/Users/MHT/eclipse-workspace/test.iptech/src/main/java/LauncherPack/SynchronizeData.java:[2,1] package SynchronizePackage does not exist
[ERROR] /C:/Users/MHT/eclipse-workspace/test.iptech/src/main/java/LauncherPack/SynchronizeData.java:[10,17] cannot find symbol
[ERROR] symbol: variable MainFunction
[ERROR] location: class LauncherPack.SynchronizeData
[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
Please any help to get it work without using add scala nature through eclipse .
Thanks a lot
I've created a bare-bone Maven project, completely empty except the pom.xml.
With this pom (note that parent element is commented-out):
<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>springboot-test</groupId>
<artifactId>springboot-test</artifactId>
<version>1.0.0-SNAPSHOT</version>
<!-- <parent> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-parent</artifactId> -->
<!-- <version>1.1.9.RELEASE</version> -->
<!-- </parent> -->
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Sample run:
$ mvn exec:java -Dexec.mainClass=test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building springboot-test 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.3.2:java (default-cli) # springboot-test ---
[WARNING] Warning: killAfter is now deprecated. Do you need it ? Please comment on MEXEC-6.
[WARNING]
java.lang.ClassNotFoundException: test
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
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.480 s
[INFO] Finished at: 2014-12-05T13:45:34-05:00
[INFO] Final Memory: 8M/176M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3.2:java (default-cli) on project springboot-test: An exception occured while executing the Java class. test -> [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 is expected (there's no clas test in this project).
Using this pom (i.e. just un-commenting parent):
<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>springboot-test</groupId>
<artifactId>springboot-test</artifactId>
<version>1.0.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.9.RELEASE</version>
</parent>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Sample run:
$ mvn exec:java -Dexec.mainClass=test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building springboot-test 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) > validate # springboot-test >>>
[INFO]
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) < validate # springboot-test <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) # springboot-test ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.550 s
[INFO] Finished at: 2014-12-05T13:45:27-05:00
[INFO] Final Memory: 12M/178M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project springboot-test: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java are missing or invalid -> [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/PluginParameterException
Same thing happens with exec-maven-plugin:1.3.2:
$ mvn org.codehaus.mojo:exec-maven-plugin:1.3.2:java -Dexec.mainClass=test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building springboot-test 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.3.2:java (default-cli) # springboot-test ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.400 s
[INFO] Finished at: 2014-12-05T13:52:46-05:00
[INFO] Final Memory: 6M/157M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3.2:java (default-cli) on project springboot-test: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.3.2:java are missing or invalid -> [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/PluginParameterException
Additional information:
$ java -version
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
$ mvn -v
Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T09:51:42-04:00)
Maven home: C:\dev\bin\apache-maven-3.2.2
Java version: 1.8.0_11, vendor: Oracle Corporation
Java home: C:\progra~1\java\jdk1.8.0_11\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"
Questions:
Why is this failing / how to fix?
Why is this failing when parent is added? How is exec-maven-plugin influenced by this?
(As a side note, I love the fact that Windows 7 belongs to faimly: "dos", I'm waiting for family: "cp/m" to be implemented for Windows 8.1)
Its because Spring-Boot is adding some extra maven configuration to your project.
If you are using eclipse, there's a Tab called: 'Effective POM'.
From this tab you can see that it adds this snippet below:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>${start-class}</mainClass>
</configuration>
</plugin>
So when you run it with spring-boot as parent, it looks for the value of ${start-class}, which resolves to empty unless you defined it, that's when you see the error about not having a value for the mainClass parameter.
Add this to your project:
<properties>
<start-class>com.Test</start-class>
</properties>
Then run it: clean compile exec:java
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) # springboot-test ---
**********test**************
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.388 s
[INFO] Finished at: 2014-12-05T15:25:05-06:00
[INFO] Final Memory: 17M/231M
[INFO] ------------------------------------------------------------------------
You can also provide the value for the start-class property on the command line, this works even if you didn't define it inside your pom file:
mvn exec:java -Dstart-class=com.Test
I am trying to execute below sparkSQL example,
https://github.com/apache/spark/blob/master/examples/src/main/java/org/apache/spark/examples/sql/JavaSparkSQL.java
my pom.xml (i have added sql dependency as well, i am stuck please help)
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>edu.berkeley</groupId>
<artifactId>simple-project</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>Simple Project</name>
<repositories>
<repository>
<id>Akka repository</id>
<url>http://repo.akka.io/releases</url>
</repository>
</repositories>
<dependencies>
<dependency> <!-- Spark dependency -->
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>1.0.2</version>
</dependency>
<dependency> <!-- Spark dependency -->
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.10</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
</project>
i have just renamed the file as SimpleApp.java
I get this following error when compiling.. kindly advice
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Simple Project 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # simple-project ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Volumes/Official/spark-1.0.2-bin-hadoop2/try/simple-project/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # simple-project ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /Volumes/Official/spark-1.0.2-bin-hadoop2/try/simple-project/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Volumes/Official/spark-1.0.2-bin-hadoop2/try/simple-project/src/main/java/SimpleApp.java:[61,16] error: cannot find symbol
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.801 s
[INFO] Finished at: 2014-08-19T10:30:31+05:30
[INFO] Final Memory: 21M/232M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project simple-project: Compilation failure
[ERROR] /Volumes/Official/spark-1.0.2-bin-hadoop2/try/simple-project/src/main/java/SimpleApp.java:[61,16] 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.
[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
I found out the issue:
In the example
https://github.com/apache/spark/blob/master/examples/src/main/java/org/apache/spark/examples/sql/JavaSparkSQL.java
replace the line schemaPeople.registerTempTable("people");
with schemaPeople.registerAsTable("people");
compile and package with mvn compile and mvn package and run with
bin/spark-submit --class "org.apache.spark.examples.sql.SimpleApp" --master local[4] try/simple-project/target/simple-project-1.0.jar
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>