My problem is a similar to that at:
maven compilation failure
But no solutions there have worked.
I have two maven projects: A is a dependency of B. I can successfully compile, test, package, and install A on both Windows 7 (my development machine) and Linux (AWS EC2 instance). I can also compile, test, package, and install B on Windows 7. When I try to compile B on Linux, however, maven presents a "cannot find symbol" error:
# mvn clean package install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building xxxxx-api Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # xxxxx-api ---
[INFO] Deleting /secure-mnt/xxxxx-api/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # xxxxx-api ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) # xxxxx-api ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 20 source files to /secure-mnt/xxxxx-api/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /secure-mnt/xxxxx-api/src/main/java/com/company/util/Logging.java:[21,13] cannot find symbol
symbol: class CryptoLogging
[ERROR] /secure-mnt/xxxxx-api/src/main/java/com/company/util/Logging.java:[32,39] cannot find symbol
symbol: method getLogger(java.lang.String)
location: class com.company.util.Logging
[INFO] 2 errors
.....
I have identical versions of Java (1.7.0_25) and Maven (3.0.5) installed on both systems, and both are using the same source code versions from Git.
Running mvn dependency:list shows no warnings. The Project A jar is in the local m2 repository on the Linux server, and does have the classes and methods available.
It seems as though Maven is not making the Java compiler aware of the Project A jar on Linux, but I do not understand why. Could Maven be failing to specify the Java classpath correctly?
Does anyone have suggestions of things to try or test?
In case it is relevant:
# mvn -version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 13:51:28+0000)
Maven home: /usr/local/apache-maven/apache-maven-3.0.5
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: /usr/java/jdk1.7.0_25/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.4.48-45.46.amzn1.x86_64", arch: "i386", family: "unix"
Since I am sure someone will ask to see the POM, here is the relevant portion for Project B. There is nothing special about the dependencies at all:
<dependencies>
<!-- For Project A. -->
<dependency>
<groupId>com.company.projectA</groupId>
<artifactId>company-projectA</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- For RESTful services. -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2</version>
</dependency>
<!-- For testing. -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
Thanks greatly for any help.
After further research, this turned out not to be a maven problem at all. Some files had incorrect UNIX permissions, which somehow resulted in the misleading error. After making sure all the working directories had been chown'd and chmod'd properly, the build worked.
Related
I created a project with JHipster 6.0.0-beta.0 and java version "11.0.2" 2019-01-15 LTS
I get the following error.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project mx: Fatal error compiling: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException: javax.xml.bind.JAXBException -> [Help 1]
Any suggestions how to solve it?
The solution is:
Add the following under <!-- For JPA static metamodel generation -->
<path>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${jaxb-runtime.version}</version>
</path>
In your pom.xml what is the value of balise Java. Version
I red all other topics (maybe work for jdk 10) and still have problem to run javax.xml.bind on jdk 11.
My dependency:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.4.0-b180830.0359</version> <!-- 2.2.12, 2.3.1 -->
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.4.0-b180830.0438</version> <!-- 2.3.1 -->
<!--<scope>compile</scope>-->
<!--<scope>runtime</scope>-->
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
My IDE (newest intellij) still doesn't see import:
import javax.xml.bind.annotation.XmlAccessType;
Also my module-info.java doesnt see:
requires java.xml.bind;
And when i use maven i have an error:
[ERROR] ...ExceptionType.java:[6,22] package javax.xml.bind.annotation is not visible
(package javax.xml.bind.annotation is declared in the unnamed module, but module javax.xml.bind.annotation does not read it)
anybody run it on jdk 11 ?
edit:
1) App version with java module system:
i have similar problem to this:
https://youtrack.jetbrains.com/issue/IDEA-197956
but my error message is a little difrent
2) App version without java module system:
Maven compile correctly. Problem is that intellij dont see my imports:
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
and say: cannot resolve symbol.
Also at file > project structure > modules > dependencies intellij didnt add javax.xml.bind and org.glassfish.jaxb
Why?
I added this in pom:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.4.0-b180830.0359</version> <!-- 2.2.8, 2.4.0-b180830.0359 -->
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.4.0-b180830.0438</version> <!-- 2.3.0, 2.4.0-b180830.0438 -->
</dependency>
JDK: openjdk11
Intellij version: IntelliJ IDEA 2018.2.4 (Ultimate Edition), Build #IU-182.4505.22, built on September 18, 2018, JRE: 1.8.0_152-release-1248-b8 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Maven:3.5.4
It seems to be a intellij bug.
Switched back to JDK 1.8 and it fixed this issue for me. How to switch in ubuntu: https://askubuntu.com/questions/740757/switch-between-multiple-java-versions
We managed to find the cause of the problem. In ide intellij I have a modules maven project and I use JLupin Platform Development Tool, so in *.iml files i dont have line:
'<'module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule = "true" type = "JAVA_MODULE" version = "4">
but i have for example:
'<'module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule = "true" type = "JLP_NATIVE_MICROSERVICE_IMPLEMENTATION_MODULE_TYPE" version = "4">
During the development, the names of the modules were changed, then the idea asked whether to remove modules (because ide did not recognize:
type = "JLP_NATIVE_MICROSERVICE_IMPLEMENTATION_MODULE_TYPE").
Although the chosen option was not, then ide automatically performed:
selecting the maven module as ignored
replace in the iml file from:
'<'module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule = "true" type = "JLP_NATIVE_MICROSERVICE_IMPLEMENTATION_MODULE_TYPE" version = "4">
to:
'<'module type = "JLP_NATIVE_MICROSERVICE_IMPLEMENTATION_MODULE_TYPE" version = "4">
For the above reason, the project did not correctly read the maven artifacts. After unifying the names and marking the project as not ignored, it works correctly.
The problem is not related to java packages
EDIT: its resolved as above
I am trying to run a Mahout project which I wrote in Eclipse with the Mahout and Hadoop libraries. It loads in a dataset and runs the FPGrowth algorithm. I set up the following Run configuration to run the project:
mvn exec:java -Dexec.mainClass=com.patternmatching.RecommendApp.TopPatternMatches
After running the program, I get the following error message:
WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
I researched this issue, and realized that the Native hadoop libraries have to either be compiled, or downloaded from Apache (Hadoop "Unable to load native-hadoop library for your platform" warning) . I downloaded the libraries on a Cloudera Quickstart VM, on which I set up Mahout and Maven, along with my project package. After running it in cloudera, I get the same error. I also ran the Hadoop checknative -a command, which verifies that the Native libraries are available:
[root#quickstart /]# hadoop checknative -a
16/10/22 19:32:16 INFO bzip2.Bzip2Factory: Successfully loaded & initialized native-bzip2 library system-native
16/10/22 19:32:16 INFO zlib.ZlibFactory: Successfully loaded & initialized native-zlib library
Native library checking:
hadoop: true /usr/lib/hadoop/lib/native/libhadoop.so.1.0.0
zlib: true /lib64/libz.so.1
snappy: true /usr/lib/hadoop/lib/native/libsnappy.so.1
lz4: true revision:99
bzip2: true /lib64/libbz2.so.1
openssl: true /usr/lib64/libcrypto.so
The output of the command verifies that the libraries are available, but are not being correctly loaded into the program or classpath. I am not sure how to configure Maven so that it loads in the Hadoop native libraries when running the program. This is the dependencies section of the Maven pom.xml file:
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>3.0.0-alpha1</version>
</dependency>
<dependency>
<groupId>org.apache.mahout</groupId>
<artifactId>mahout-core</artifactId>
<version>0.9</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
and the command I run to execute my Mahout java program is
mvn exec:java -Dexec.mainClass=com.patternmatching.RecommendApp.TopPatternMatches
How can I configure Maven to see these libraries so they are used in the program?
Can somebody tell me how to build the Spark-Cassandra Connector assembly? I've tried following the instructions on the Github page https://github.com/datastax/spark-cassandra-connector but I just get hundreds of "deduplicate" errors.
I'm using Scala 2.11.7 with Spark 1.5.1 (which I built for Scala 2.11) and SBT 13.8.
I did the following:
git clone https://github.com/datastax/spark-cassandra-connector.git
cd spark-cassandra-connector/
sbt -Dscala-2.11=true assembly
The build process runs for a while, but then starts spitting out hundreds of "deduplicate" errors and fails. I have no idea where to start fixing this, but right now as far as I can tell the assembly build process for this project just doesn't work.
Any tips on how I can fix this?
It appears the build for 2.11 is broken and you should report it to the project. Dunno how to fix it right now.
➜ spark-cassandra-connector git:(master) sbt
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Loading project definition from /Users/jacek/dev/oss/spark-cassandra-connector/project
Using releases: https://oss.sonatype.org/service/local/staging/deploy/maven2 for releases
Using snapshots: https://oss.sonatype.org/content/repositories/snapshots for snapshots
Scala: 2.10.5 [To build against Scala 2.11 use '-Dscala-2.11=true']
Scala Binary: 2.10
Java: target=1.7 user=1.8.0_66
[info] Set current project to root (in build file:/Users/jacek/dev/oss/spark-cassandra-connector/)
[root]> update
...
[info] Done updating.
[info] Done updating.
[success] Total time: 314 s, completed Dec 2, 2015 10:26:01 AM
[root]>
➜ spark-cassandra-connector git:(master) sbt -Dscala-2.11=true
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Loading project definition from /Users/jacek/dev/oss/spark-cassandra-connector/project
Using releases: https://oss.sonatype.org/service/local/staging/deploy/maven2 for releases
Using snapshots: https://oss.sonatype.org/content/repositories/snapshots for snapshots
Scala: 2.11.7
Scala Binary: 2.11
Java: target=1.7 user=1.8.0_66
[info] Set current project to root (in build file:/Users/jacek/dev/oss/spark-cassandra-connector/)
[root]> update
...
[error] impossible to get artifacts when data has not been loaded. IvyNode = org.slf4j#slf4j-log4j12;1.7.6
...
[trace] Stack trace suppressed: run last spark-cassandra-connector-embedded/*:update for the full output.
[error] (spark-cassandra-connector-embedded/*:update) java.lang.IllegalStateException: impossible to get artifacts when data has not been loaded. IvyNode = org.slf4j#slf4j-log4j12;1.7.6
[error] Total time: 9 s, completed Dec 2, 2015 10:27:19 AM
I filed an issue https://datastax-oss.atlassian.net/browse/SPARKC-295.
Trying to use Spock via GMaven (Maven 3.1.1) with Groovy 2.3 support and I am having difficulty getting SNAPSHOT dependency. I seem to have same error even when I try to run Spock Example project that has similar dependency defined.
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>1.0-groovy-2.3-SNAPSHOT</version>
<scope>test</scope>
</dependency>
I have the SNAPSHOT repository specified like the Spock Example does:
<repositories>
<!-- Only required if a snapshot version of Spock is used -->
<repository>
<id>spock-snapshots</id>
<url>http://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
But even when I run mvn clean test for Spock Example I get:
ERROR] Failed to execute goal on project spock-example: Could not resolve dependencies for project org.spockframework:spock-example:jar:1.0-SNAPSHOT: Failure to find org.spockframework:spock-core:jar:1.0-groovy-2.3-SNAPSHOT in was cached in the local repository, resolution will not be reattempted until the update interval of nexus_sprn has elapsed or updates are forced -> [Help 1]
I succeed if I simply use 0.7-groovy-2.0 version but I want Groovy 2.3 since it appears #CompileStatic does not work properly for my project in Groovy 2.0.
EDIT:
Just notice a warning happening just before the build fails:
[WARNING] The POM for org.spockframework:spock-core:jar:1.0-groovy-2.3-SNAPSHOT is missing, no dependency information available
So based on Mr. Niederwiesser's comment I found that the settings.xml my current project requires uses a mirror that does not know about the Spock SNAPSHOT location. In addition to re-configuring my company's proxy setting I had to do the following in my global settings.xml to make it not use the mirror.
<mirrors>
<mirror>
<id>nexus_sprn</id>
<mirrorOf>*,!nexus_public,!project-lib-dir,!spock-snapshots</mirrorOf>
<url>MIRROR_URL_REMOVED</url>
</mirror>
</mirrors>
...
<repository>
<id>spock-snapshots</id>
<url>http://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
Not sure proper etiquette here but I will leave this answer here for future unless the general consensus is it is unnecessary.