Spark and MongoDB application in Scala 2.10 maven built error - java

I want to build a Scala application with maven dependencies for Spark and MongoDB. The Scala version I use is 2.10. My pom look like this (left out unrelevant parts):
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<encoding>UTF-8</encoding>
<scala.tools.version>2.10</scala.tools.version>
<!-- Put the Scala version of the cluster -->
<scala.version>2.10.5</scala.version>
</properties>
<!-- repository to add org.apache.spark -->
<repositories>
<repository>
<id>cloudera-repo-releases</id>
<url>https://repository.cloudera.com/artifactory/repo/</url>
</repository>
</repositories>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<!-- <pluginManagement> -->
<plugins>
<plugin>
<!-- see http://davidb.github.com/scala-maven-plugin -->
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.3</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<arg>-make:transitive</arg>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.13</version>
<configuration>
<useFile>false</useFile>
<disableXmlReport>true</disableXmlReport>
<!-- If you have classpath issue like NoDefClassError,... -->
<!-- useManifestOnlyJar>false</useManifestOnlyJar -->
<includes>
<include>**/*Test.*</include>
<include>**/*Suite.*</include>
</includes>
</configuration>
</plugin>
<!-- "package" command plugin -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<!-- </pluginManagement> -->
</build>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.mongodb.spark</groupId>
<artifactId>mongo-spark-connector_2.10</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.mongodb.scala</groupId>
<artifactId>mongo-scala-driver_2.11</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
When I run mvn clean assembly:assembly, the following error occurs:
C:\Develop\workspace\SparkApplication>mvn clean assembly:assembly
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SparkApplication 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # SparkApplication ---
[INFO] Deleting C:\Develop\workspace\SparkApplication\target
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SparkApplication 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-assembly-plugin:2.4.1:assembly (default-cli) > package # SparkA
pplication >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # SparkAppli
cation ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Develop\workspace\SparkApplication
\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # SparkApplicatio
n ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- scala-maven-plugin:3.1.3:compile (default) # SparkApplication ---
[WARNING] Expected all dependencies to require Scala version: 2.10.5
[WARNING] xx.xxx.xxx:SparkApplication:0.0.1-SNAPSHOT requires scala version:
2.10.5
[WARNING] com.twitter:chill_2.10:0.5.0 requires scala version: 2.10.4
[WARNING] Multiple versions of scala libraries detected!
[INFO] C:\Develop\workspace\SparkApplication\src\main\scala:-1: info: compiling
[INFO] Compiling 1 source files to C:\Develop\workspace\SparkApplication\target\
classes at 1477993255625
[INFO] No known dependencies. Compiling everything
[ERROR] error: bad symbolic reference. A signature in package.class refers to ty
pe compileTimeOnly
[INFO] in package scala.annotation which is not available.
[INFO] It may be completely missing from the current classpath, or the version o
n
[INFO] the classpath might be incompatible with the version used when compiling
package.class.
[ERROR] C:\Develop\workspace\SparkApplication\src\main\scala\com\examples\MainEx
ample.scala:33: error: Reference to method intWrapper in class LowPriorityImplic
its should not have survived past type checking,
[ERROR] it should have been processed and eliminated during expansion of an encl
osing macro.
[ERROR] val count = sc.parallelize(1 to NUM_SAMPLES).map{i =>
[ERROR] ^
[ERROR] two errors found
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.363 s
[INFO] Finished at: 2016-11-01T10:40:58+01:00
[INFO] Final Memory: 20M/353M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.1.3:compi
le (default) on project SparkApplication: wrap: org.apache.commons.exec.ExecuteE
xception: Process exited with an error: 1(Exit value: 1) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception
The error occurs only when adding the mongo-scala-driver_2.11 dependency. Without this dependency, the jar will be built. My code is currently the Pi-Estimation example from the Spark website:
val conf = new SparkConf()
.setAppName("Cluster Application")
//.set("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
val sc = new SparkContext(conf)
val count = sc.parallelize(1 to NUM_SAMPLES).map{i =>
val x = Math.random()
val y = Math.random()
if (x*x + y*y < 1) 1 else 0
}.reduce(_ + _)
println("Pi is roughly " + 4.0 * count / NUM_SAMPLES)
I also tried adding the following tags to each element as I found this in some github issue. Did not help though.
<exclusions>
<exclusion>
<!-- make sure wrong scala version is not pulled in -->
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
</exclusion>
</exclusions>
How to fix this? The MongoDB Scala Driver seems to be built against Scala 2.11 but Spark requires Scala 2.10.

Remove the Mongo Scala Driver dependency, its not compiled for Scala 2.10 and therefore not compatible.
The good news is MongoDB Spark Connector is a standalone connector. It utilises the synchronous Mongo Java Driver because Spark is designed for CPU intensive synchronous tasks. It has been designed to follow Spark idioms and is all that is needed to connect MongoDB to Spark.
On the other hand the Mongo Scala Driver is idiomatic to modern Scala conventions; all IO is fully asynchronous. This is great for web applications and improving the scalability of an individual machine.

Related

How should I edit my pom.xml file to import my maven project to sonarqube?

I am using JDK 1.8 and Maven using Eclipse IDE. I want to analyze my project on SonarQube 6.6. Here is my pom.xml file:
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ADDITION</groupId>
<artifactId>Addition</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId> <!-- NOT org.junit here -->
<artifactId>junit-dep</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.sonarsource.scanner.maven/sonar-maven-plugin -->
<dependency>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.1.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And this is the output with error:
(localhost:9000 is the default port for SonarQube and it is working fine. But the problem is I cannot import my maven project to sonar. If anyone finds the solution, please help.
Thank you.)
C:\eclipse-workspace\Addition>mvn sonar:sonar
[INFO] Scanning for projects...
[WARNING] The artifact org.codehaus.mojo:sonar-maven-plugin:jar:3.9.1.2184 has been relocated to org.sonarsource.scanner.maven:sonar-maven-plugin:jar:3.9.1.2184: SonarQube plugin was moved to SonarSource organisation
[INFO]
[INFO] -----------------< ADDITION:Addition >-----------------
[INFO] Building Addition 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:3.9.1.2184:sonar (default-cli) # Addition ---
[INFO] User cache: C:\Users\arghy\.sonar\cache
[ERROR] SonarQube server [http://localhost:9000] can not be reached
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.057 s
[INFO] Finished at: 2022-04-01T13:58:31+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project Addition: Unable to execute SonarScanner analysis: Fail to get bootstrap index from server: Failed to connect to localhost/0:0:0:0:0:0:0:1:9000: Connection refused: connect -> [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
Looks like localhost resolves to the ipv6 adress, maybe sonarqube doesn't support that. What happens if you change http://localhost:9000 to http://127.0.0.1:9000?

Not able to get dependency check report in Maven

I am trying to get dependency check report for one of my Maven project but every time I am running:
mvn verify
dependency in dependency report shows no vulnerable JARs.
I have added below plugin in my POM to generate dependency check report:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>apache.axis</groupId>
<artifactId>jaxrpc</artifactId>
<version>1.2beta</version>
<scope>provided</scope>
</dependency>
<dependencies>
<dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>3.3.2</version>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
What do I need to correct or is there any other way? commons-email-1.1.jar have some vulnerabilities but still its not getting detected.
These are the Maven logs:
[INFO] Scanning for projects...
[INFO] Inspecting build with total of 1 modules...
[INFO] Installing Nexus Staging features:
[INFO] ... total of 1 executions of maven-deploy-plugin replaced with
nexus-staging-maven-plugin
[INFO]
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) # version-mana -
--
[INFO]
[INFO] --- maven-source-plugin:2.4:jar-no-fork (attach-sources) # version-
mana ---
[INFO]
[INFO] --- maven-source-plugin:2.4:test-jar-no-fork (attach-sources) #
version-mana ---
[INFO]
[INFO] --- dependency-check-maven:3.3.2:check (default) # version-mana ---
[INFO] Central analyzer disabled
[INFO] Checking for updates
[INFO] Skipping NVD check since last check was within 4 hours.
[INFO] Skipping RetireJS update since last update was within 24 hours.
[INFO] Check for updates complete (31 ms)
[INFO] Analysis Started
[INFO] Finished File Name Analyzer (0 seconds)
[INFO] Finished Dependency Merging Analyzer (0 seconds)
[INFO] Finished Version Filter Analyzer (0 seconds)
[INFO] Finished Hint Analyzer (0 seconds)
[INFO] Created CPE Index (1 seconds)
[INFO] Skipping CPE Analysis for npm
[INFO] Finished CPE Analyzer (1 seconds)
[INFO] Finished False Positive Analyzer (0 seconds)
[INFO] Finished NVD CVE Analyzer (0 seconds)
[INFO] Finished Vulnerability Suppression Analyzer (0 seconds)
[INFO] Finished Dependency Bundling Analyzer (0 seconds)
[INFO] Analysis Complete (1 seconds)
Provided you have access to the maven repository (at the time of executing this command) and installed mvn/mvnw , from the command-line, you can execute this line.
mvn org.owasp:dependency-check-maven:5.2.2:check
The "dependency-check-report.html" report will be generated in the target folder.
Out of interest i tried it and for me it is working:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>3.3.3</version>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
dependency-check-maven tells me:
[INFO] Analysis Complete (1 seconds)
[WARNING]
One or more dependencies were identified with known vulnerabilities in test:
commons-email-1.1.jar (org.apache.commons:commons-email:1.1, cpe:/a:apache:commons_email:1.1) : CVE-2017-9801, CVE-2018-1294
See the dependency-check report for more details.
How does your dependencies section look like? For Example if you define the scope test for commons-email no warning is shown.

Aspectj class is not found by test class when running test with maven

I have created a test for my aspectj class.
When I execute my test it works fine to "Run as TestNG" from Eclipse.
Then when I execute it in maven:
mvn clean test
I get the following error:
[15:15] [eraonel/git/java-runtime-stats] -> mvn clean test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building java-runtime-stats 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # java-runtime-stats ---
[INFO] Deleting /repo/eraonel/git/java-runtime-stats/target
[INFO]
[INFO] --- maven-antrun-plugin:1.8:run (default) # java-runtime-stats ---
[INFO] Executing tasks
main:
[echo] BUILDING : /repo/eraonel/git/java-runtime-stats/src/main/java/com/company/commonlibrary/javaruntimestats/Version.java
[echo] BUILD 2018-10-24 13:18 UTC : /repo/eraonel/git/java-runtime-stats/src/main/java/com/company/commonlibrary/javaruntimestats/Version.java
[INFO] Executed tasks
[INFO]
[INFO] --- maven-java-formatter-plugin:0.6.1-threadsafe:format (default) # java-runtime-stats ---
[INFO] Using 'UTF-8' encoding to format source files.
[INFO] Number of files to be formatted: 21
[INFO] Successfully formatted: 1 file(s)
[INFO] Fail to format : 0 file(s)
[INFO] Skipped : 20 file(s)
[INFO] Approximate time taken: 0s
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # java-runtime-stats ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /repo/eraonel/git/java-runtime-stats/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # java-runtime-stats ---
[INFO] Compiling 15 source files to /repo/eraonel/git/java-runtime-stats/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # java-runtime-stats ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 11 resources
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) # java-runtime-stats ---
[INFO] Compiling 6 source files to /repo/eraonel/git/java-runtime-stats/target/test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /repo/eraonel/git/java-runtime-stats/src/test/java/com/company/commonlibrary/javaruntimestats/aspects/DeprecatedMethodsAspectTest.java:[17,13] cannot find symbol
symbol: class DeprecatedMethodsAspect
location: class com.company.commonlibrary.javaruntimestats.aspects.DeprecatedMethodsAspectTest
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.127 s
[INFO] Finished at: 2018-10-24T15:18:08+02:00
[INFO] Final Memory: 33M/730M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:testCompile (default-testCompile) on project java-runtime-stats: Compilation failure
[ERROR] /repo/eraonel/git/java-runtime-stats/src/test/java/com/company/commonlibrary/javaruntimestats/aspects/DeprecatedMethodsAspectTest.java:[17,13] cannot find symbol
[ERROR] symbol: class DeprecatedMethodsAspect
[ERROR] location: class com.company.commonlibrary.javaruntimestats.aspects.DeprecatedMethodsAspectTest
[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
What am I missing here?
Why is the aspectj not compiled before the test case?
Is there a way to change this?
I used this example ( for the library part) to follow since I am creating a lib that should be used for other applications:
AspectJ: How to weave an aspect library into a Java project
TestClass:
/**
* Unit test to see if pointcut works as expected in ${#link DeprecatedMethodsAspect}
*/
public class DeprecatedMethodsAspectTest {
private DeprecatedMethodsAspect aspect;
private DeprecatedMethods deprecatedMethodsMock;
private DeprecatedMethodsApp app;
#BeforeClass
public void setUp() throws Exception {
app = new DeprecatedMethodsApp();
deprecatedMethodsMock = mock(DeprecatedMethods.class);
when(deprecatedMethodsMock.isActive()).thenReturn(true);
aspect = Aspects.aspectOf(DeprecatedMethodsAspect.class);
aspect.setDeprecatedMethods(deprecatedMethodsMock);
}
#Test
public void testSumIsMatched() throws Throwable {
app.sum(1, 2);
verify(deprecatedMethodsMock, times(1)).collect(any(JoinPoint.class));
}
#Test(description = " we should not gather information from methods annotated #Beta.")
public void testSubIsNotMatched() throws Throwable {
app.sub(2, 1);
verify(deprecatedMethodsMock, times(0)).collect(any(JoinPoint.class));
}
}
This is excerpt from my pom.xml
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Compile scope dependencies -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<!-- IMPORTANT -->
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>${java.version}</version>
<configuration>
<showWeaveInfo>true</showWeaveInfo>
<source>${java.version}</source>
<target>${java.version}</target>
<Xlint>ignore</Xlint>
<complianceLevel>${java.version}</complianceLevel>
<encoding>${project.build.sourceEncoding}</encoding>
<!--<verbose>true</verbose> -->
<!--<warn>constructorName,packageDefaultMethod,deprecation,maskedCatchBlocks,unusedLocals,unusedArguments,unusedImport</warn> -->
</configuration>
<executions>
<execution>
<!-- IMPORTANT -->
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
You've included the aspectj-maven-plugin in <pluginManagement/> but you haven't included it in <plugins>
Try adding:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
</plugin>
</plugins>
under the <build/> element.
See also: Maven: What is pluginManagement?

Spring-boot-maven-plugin repackage goal error using nar-maven-plugin

I'm using nar-maven-plugin with my spring boot project, everything goes well when developing but when i run maven package the project the compilation goes well until the final step where throws me the error:
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-test (default-nar-test) # customertracker ---
[INFO] Preparing Nar dependencies
[INFO] Unpacking 0 dependencies to /home/diego/Development/Web/Spring/CustomerTracker/target/test-nar
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-prepare-package (default-nar-prepare-package) # customertracker ---
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-package (default-nar-package) # customertracker ---
[INFO] Building zip: /home/diego/Development/Web/Spring/CustomerTracker/target/customertracker-0.0.1-SNAPSHOT-amd64-Linux-gpp-jni.nar
[INFO]
[INFO] --- maven-jar-plugin:2.5:jar (default-jar) # customertracker ---
[INFO] Building jar: /home/diego/Development/Web/Spring/CustomerTracker/target/customertracker-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.2.3.RELEASE:repackage (default) # customertracker ---
[INFO] Attaching archive: /home/diego/Development/Web/Spring/CustomerTracker/target/customer-tracker-app.nar, with classifier: null
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26.190 s
[INFO] Finished at: 2015-05-20T09:41:16-05:00
[INFO] Final Memory: 32M/401M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.2.3.RELEASE:repackage (default) on project customertracker: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.2.3.RELEASE:repackage failed: For artifact {com.housingelectronics:customertracker:0.0.1-SNAPSHOT:nar}: An attached artifact must have a different ID than its corresponding main artifact. -> [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/PluginExecutionException
so i try to change the fileName property in spring-boot-maven-plugin and in my nar-maven-plugin output property, but not works
here is my maven simplified:
<?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.housingelectronics</groupId>
<artifactId>customertracker</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>nar</packaging> <-- changing this to jar works but the applications does not find the .so library on runtime -->
<name>CustomerTracker</name>
<description>Customer Tracker</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>customertracker.CustomerTrackerApplication</start-class>
<java.version>1.7</java.version>
</properties>
<dependencies>
...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.1.RELEASE</version>
</dependency>
</dependencies>
<configuration>
<finalName>customer-tracker-app</finalName>
</configuration>
</plugin>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<version>3.2.0</version>
<extensions>true</extensions>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<output>customer-tracker-nar-generated</output>
<cpp>
<sourceDirectory>src/main/c++/udevLaserScannerDriverJNI/</sourceDirectory>
<includes>
<include>laserscannerlistener.cpp</include>
<include>utils.cpp</include>
<include>netlink/**/*.cc</include>
</includes>
</cpp>
<c>
<excludes>
<exclude>**/node_modules/**/*.c</exclude>
</excludes>
</c>
<java>
<include>true</include>
</java>
<javah>
<jniDirectory>src/main/c++/udevLaserScannerDriverJNI/</jniDirectory>
</javah>
<libraries>
<library>
<type>jni</type>
<narSystemPackage>customertracker.devices.udev</narSystemPackage>
</library>
</libraries>
</configuration>
<!-- <phase>generate-sources</phase> -->
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Thanks for any help.
i found the solution, what i do is to use classifier option instead of fileName in the spring-boot-maven-plugin and it works, this produces to me two nar files, one with the spring-boot application and the other with the .so library, now the problem is use them for run the application but this problem is independent of this thread.

mvn hibernate3:hbm2ddl fails in a tutorial

I am trying to follow the tutorial in Chapter 7 in this online book: http://books.sonatype.com/mvnex-book/reference/index.html
This tutorial is intended to demonstrate a web application with Spring Framework with hibernate, and I am stuck hereļ¼š
mvn hibernate3:hbm2ddl
...
<build>
<finalName>simple-webapp</finalName>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<dependencies>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.7</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>annotationconfiguration</implementation>
</component>
</components>
</configuration>
<dependencies>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.7</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.7.Final</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
The error message is below. Any insight or pointer will be appreciated. Thanks.
#localhost simple-webapp]$ mvn hibernate3:hbm2ddl
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.sonatype.mavenbook.multispring:simple-webapp:war:1.0
[WARNING] 'build.plugins.plugin.version' for org.mortbay.jetty:maven-jetty-plugin is missing. # org.sonatype.mavenbook.multispring:simple-webapp:[unknown-version], /home/abigail/workspace/simple-parent/simple-webapp/pom.xml, line 46, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler- plugin is missing. # org.sonatype.mavenbook.multispring:simple-parent:1.0, /home/abigail/workspace/simple-parent/pom.xml, line 29, column 12
[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 Simple Web Application 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> hibernate3-maven-plugin:3.0:hbm2ddl (default-cli) > compile # simple-webapp >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # simple-webapp ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/abigail/workspace/simple-parent/simple- webapp/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # simple-webapp ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< hibernate3-maven-plugin:3.0:hbm2ddl (default-cli) < compile # simple-webapp <<<
[INFO]
[INFO] --- hibernate3-maven-plugin:3.0:hbm2ddl (default-cli) # simple-webapp ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.959 s
[INFO] Finished at: 2014-09-03T02:35:24-04:00
[INFO] Final Memory: 12M/208M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:3.0:hbm2ddl (default-cli) on project simple-webapp: There was an error creating the AntRun task. NullPointerException -> [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
Try adding version for your plugin for maven-jetty-plugin and see if that fixes the issue, as there is a warning that says:
[WARNING] 'build.plugins.plugin.version' for org.mortbay.jetty:maven-jetty-plugin is missing. # org.sonatype.mavenbook.multispring:simple-webapp:[unknown-version], /home/abigail/workspace/simple-parent/simple-webapp/pom.xml, line 46, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler- plugin is missing. # org.sonatype.mavenbook.multispring:simple-parent:1.0, /home/abigail/workspace/simple-parent/pom.xml, line 29, column 12
For example:
<version>4.2.14</version>
can you try with the below plugin.
<plugin>
<!-- Run "mvn hibernate3:hbm2ddl" to generate schema -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>${hibernate3.maven.plugin.version}</version>
<configuration>
<hibernatetool>
<annotationconfiguration propertyfile="src/main/resources/${hibernate.properties}" />
<hbm2ddl update="true" create="true" export="false"
outputfilename="${hibernate.hbm2ddl.sqlfile}" format="true"
console="true" />
</hibernatetool>
</configuration>
</plugin>
instead of
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>annotationconfiguration</implementation>
</component>
</components>
</configuration>
I had the same problem as you (using Java 8) and solved it by switching the version of the plugin to 2.2 from 2.0. If you try out newer version it appears to break again.
Wonder if there is a better way to solve such version issues than trial and error combined with extensive search engine usage.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>annotationconfiguration</implementation>
</component>
</components>
</configuration>
<dependencies>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.7</version>
</dependency>
</dependencies>
</plugin>

Categories