Strange maven compilation error while building project.
Hi,
I'm facing a trivial but rather a very strange issue with respect to maven project build.
I'm using Intellij as the IDE.
I've a maven project A which has two maven modules B and C
A
|
|
|--B
|
|--C
The module C is a test module which has a dependency on module B.
Now, when I build the entire project using mvn clean install, it complains of "Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin error: cannot find symbol
However, there is no compilation error shown on intellij.
Additionally, to my surprise, my test runs without any issue.
I've tried to execute different intellij options viz. (re-import/sync/invalid caches and restart), but in vain.
I've also tried to play around with the version of maven-compiler-plugin.
Can someone please help me what can be the reason of the failure? Thanks.
the issue was occuring due to spring boot maven plugin's repackage goal.
The repackage goal replaces the original jar with the repackaged one.
The reason for the compilation issue is that application classes are packaged in BOOT-INF/classes so that's why the dependent module couldn't load a repackaged jar's classes.
More info here :
https://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/repackage-classifier.html
Related
I have been working on a Java Maven project and my way of using it in Eclipse was to build it on command line and then import in Eclipse. The problem that I was facing is even though the project built successfully, eclipse was not able to resolve dependencies correctly.
This problem would usually go by cleaning, Maven updating and deleting and importing. However, this time it did not get resolved by following these steps. I tried a lot of already existing answers but nothing worked for me. However, I observed that the classpath is not getting created correctly:
I'm seeing that one of the dependency jars is marked as missing
I tried to create the Eclipse .classpath file using:
mvn eclipse:clean
mvn eclipse:eclipse
But mvn eclipse:eclipse fails with the following message:
Failed to execute goal on project consultation: Could not resolve
dependencies for project
company.compliance:consultation:jar:1.0-SNAPSHOT: Failure to find
company.compliance:commons:jar:1.0-SNAPSHOT in
http://maven.ia55.net/company was cached in the local repository,
resolution will not be reattempted until the update interval of
company-mvn-repository has elapsed or updates are forced -> [Help 1]
I read in some of the answers that this can also happen if m2e is not configured properly (it should be pointing to the commandline maven and not embedded maven). When I checked I saw that I don't even have m2e so in installed it. I don't know how to configure it to point to my Maven.
However, I doubt that this problem is because of the plugin not working otherwise I would not have been able to work in Eclipse peacefully till now.
So my other question is, isn't the success of mvn clean package enough to warrant that eclipse should not have any compilation errors regarding dependencies or does scope of dependency also plays a role and that I should work on getting the jar in the repo.
Is there any other possible issue that I am missing?
The issue got resolved. Earlier i was only importing the project that i wanted to work on. After importing all the projects in the directory which contained the pom, eclipse resolved the dependencies. Have no clue how this worked but it did.
I'm trying to build a non-modular application (no module-info.java files) with JavaFX 11 using Maven.
As suggested on openjfx.io, I'm using JavaFX Maven plugin for that.
But in respond to mvn javafx:run I get the following error:
[INFO] --- javafx-maven-plugin:0.0.2:run (default-cli) # server ---
Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Modules lucene.core and
lucene.misc export package org.apache.lucene.store to module javassist
[ERROR] Command execution failed.
I'm using Hibernate Search 5.11.2 which depends on org.apache.lucene:lucene-core:5.5.5 and org.apache.lucene:lucene-misc:5.5.5.
As far as I understand from the API, these jars are simple pre-JDK9 jars. So they should be parts of the unnamed module and I should get no errors.
Or am I missing something?
Fixed in this PR.
So either build and install the snapshot or wait until version 0.0.3 will be released, if you are facing the similar issue.
Faced this in javafx-maven-plugin 0.0.5 with IntelliJ
Kept getting different errors like :
Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Modules plexus.archiver and plexus.io export package org.codehaus.plexus.components.io.resources to module j2objc.annotations
Had to clear all libraries (except org.javafx) from the Module Settings and rebuild the project, which finally fixed the issue.
I'm attempting to build two Maven projects from Eclipse. One project constitutes a set of dependencies and libraries to be used for the other project which contains all of my source code. Both are configured as Maven projects using Tycho 1.0.0 .
I have a parent POM file that contains three modules: a folder containing my target file, the plugin containing the dependencies and the plugin that contains the source code. When trying to maven build on the parent POM, I get the following error:
Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.0.0:compile (default-compile) on project com.ericsson.cd-editor.ui: Execution default-compile of goal org.eclipse.tycho:tycho-compiler-plugin:1.0.0:compile failed: A required class was missing while executing org.eclipse.tycho:tycho-compiler-plugin:1.0.0:compile: freemarker/template/Configuration
Gonna post the full error log in pastebin since it's diffcult to read in a Stack Overflow post:
http://pastebin.com/EYnsqvpJ
Here is my parent POM file:
http://pastebin.com/wSAtwspV
I've been told by a colleague of mine that the reason this might be happening is that this dependency might be used by Tycho and cannot be found. The freemarker package is however available in my .m2/repository/.
It's really hard to tell where the error might be.
First, make sure the jar you have in your m2 archive actually contains the class the compiler is looking for.
You could check whether you dependencies are in the central maven repository, instead of making a project containing them.
Does the project that needs all the dependencies state them explicitly, e.g., in feature.xml or Manifest.mf? Otherwise tycho will not load them, even if they are accessible to maven.
Posting the pom.xml files for the modules might be helpful. Hope you'll figure it out :)
Recently our project's dependencies artifact name has been changed so as the package names and some classes' names. Now we need to update our project dependencies for our next release. Problem is when invoking eclipse from play console it just doesn't do that if there's any compilation errors which of course is expected. I just want to update the eclipse project settings and fix compilation problems later.
It should generate the projects even if there are compilation problems. You might want to check your sbteclipse version.
There might be a chance that it will not even compile when generating the eclipse files. This could theoretically be triggered by a related sbt issue: compile is executed for discoveredSbtPlugins when the project is not a plugin
So if you are not creating an sbt plugin and have an updated sbteclipse version and still have problems, you could try setting: discoveredSbtPlugins := PluginDiscovery.emptyDiscoveredNames.
I would strongly advise you to first see if the compilation problems are causing the projects not to be created. In the past I have often created projects when I had compiler errors. It will for example not create the project if you have an unresolved dependency.
I'm having hard time to setup springframework code in Intellij.
I git-cloned springframework project from github, and ran ant task to get all the libraries into ivy-cache directory.
I found "spring-framework.ipr" file for intellij project, and opened it.
Unfortunately, some of the libraries are not correctly mapped to the jar files or missing. So I cannot compile the codebase in IDE.
I also tried importing as eclipse project into intellij. Jar file reference seems ok.
But there are compilation errors in OXM module. Some test classes have reference to auto generated classes such as "~.samples.flight.FlightDocument", "~.jaxb.test.FlightType", and they don't exist(ant test goal generates them in target dir).
It seems same problem happens in STS.
I referenced this blog post:
http://blog.springsource.org/2009/03/03/building-spring-3/
Any good idea to setup spring code in intellij?
I use intellij v11.
git branch: 3.1.x
git commit: e8fc90ce3e4554f14eaa86ce05591249d3fe62fa
Compilation error example:
.../org.springframework.oxm/src/test/java/org/springframework/oxm/xmlbeans/XmlBeansMarshaller Tests.java
Error:(29,42) package org.springframework.samples.flight does not exist
Error:(30,42) package org.springframework.samples.flight does not exist
Error:(44,9) cannot find symbol class FlightsDocument
Error:(44,58) package FlightsDocument does not exist
....
Thanks,
problem solved.
"spring-framework.ipr" is the one for intellij.
lesson learned:
simply wrong version of junit was referenced in spring-framework.ipr file.
when ant build failed middle of the test, subsequent module won't be built. so, required libraries won't be downloaded into ivy-cache/repository.
"ant jar" goal will not download test related libraries since the goal doesn't run tests
After all the tests passed and manually fixed junit reference, intellij finally has no errors.