Maven updating .project files, project can no longer successfully build - java

I am using Maven in Eclipse Kepler with JRE 1.7.09 for a large project at work. We have a few hundred plugins for our Maven project. Initially, after checking everything out from our Git/SVN repos, I am able to do a Maven Clean/Install without a single issue. But after some time, all of my projects update and I can no longer perform a successful build. I also get errors by almost every project (which is discouraging considering there are about 200 in my workspace).
Comparing my local copy and the HEAD version, the only differences are the .project files. In my workspace version, most of the information has been completely removed. Updating these files to the HEAD restores the content and resolves the errors...but updating 200+ .project files everytime it breaks isn't the most efficient.
If it helps, I am also a victim of the infinite SVN Status Cache Update error.
Any tips would be appreciated. I would really love to fix this shit so I can get back to actual work.
Thanks!
Edit:
The first error was nonsense, so I removed the Maven nature from the offending package. Now I am getting this --
[ERROR] QueryResult cannot be resolved to a type
[ERROR] <dir/file.java>:[152,0]
[ERROR] List<Status> tweets = result.getTweets();
[ERROR] ^^^^^^
[ERROR] Status cannot be resolved to a type
[ERROR] <dir/file.java>:[166,0]
[ERROR] private Table covertResultIntoTable(List<Status> statuses) {
[ERROR] ^^^^^^
[ERROR] Status cannot be resolved to a type
[ERROR] <dir/file.java>:[172,0]
[ERROR] for (Status status : statuses) {
[ERROR] ^^^^^^
[ERROR] Status cannot be resolved to a type
[ERROR] 30 problems (30 errors)
I can export this package without a single error and all of the types come from a .JAR that has been added to the build path.

Run on the console:
mvn clean eclipse:eclipse
or load it on eclipse after installing the m2 plugin
Please note I specified OR, do not do both :)

Related

Tycho can't resolve indirectly referenced SWT dependencies

The problem is probably the same as in this question, but the solution offered there has become inapplicable in the last 8 years.
I have an Eclipse RCP project which is in the process of being transformed to use Tycho (version 2.3.0) instead. The project can be run with Eclipse 2019-06 and the custom target platform built for this project.
Then I have set up Tycho with the same target platform (a separate Maven module referencing the same *.target file used by Eclipse).
But then when I run Maven (version 3.6.3) with the usual "clean install" goals, I get this error message:
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:2.3.0:compile (default-compile) on project my.project.module: Compilation failure: Compilation failure:
[ERROR] C:\path\to\a\source\file\in\a\module.java:
[ERROR] /*
[ERROR] ^
[ERROR] The type org.eclipse.swt.widgets.Event cannot be resolved. It is indirectly referenced from required .class files
The target platform specifies the same environment (win32.win32.x86_64) for both Eclipse and Tycho, and both SWT .jar files (org.eclipse.swt_3.111.0.v20190605-1801.jar and org.eclipse.swt.win32.win32.x86_64_3.111.0.v20190605-1801.jar) are in one of the directories making up the target platform.
After adding
jars.extra.classpath = platform:/plugin/org.eclipse.swt.win32.win32.x86_64
to the build.properties file (as recommended here) the problem is gone.

Compilation error/issues while executing maven install

I have a maven project and try to do a maven install.While performing the maven install, Im getting the below error.
[INFO] Compiling 403 source files to D:\\iTT_Backend\itt\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/iTT_Backend/itt/src/main/java/com/iowe/bean/Project.java:[5,27]
package com.cx.util does not exist
[ERROR]
/D:/iTT_Backend/itt/src/main/java/com/itt/controller/ScanController.java:
[21,39] package com.cx.business.to.scan does not exist
Above is the error Im getting while trying to do a clean install.The specified package in the above error message package com.cx.util is available as part of the itt.jar. That jar has been added as a dependency to this project. I dont see any errors in eclipse. Only while trying to do install, Im getting the above compilation error.
Analysis Done
Below are the analysis done
Checked for the dependency and the jar is available as part of dependency in pom.xml file.
The application does not show any dependency error in eclipse. Its able to navigate to the corresponding method in the jar file.The issue occurs while executing mvn install command.
Tried executing mvn install via command prompt. Still getting the same error as above.
Have renamed the .m2 repository folder to old repository and re executed the mvn install command. same issue exists.
Need help in getting the above issue resolved.
Any help on this is much appreciated. Thanks in Advance.
Remove from .m2 local repository and execute command mvn clean install
Try to remove and add again dependency in Pom.xml

Jspresso 4.1-SNAPSHOT ViewTester

I am doing the reference guide tutorial. When saving changes in view.groovy i can see the building workspace message of eclipse but these changes are not shown in ViewTester until i do a mvn compile in core directory.
Is this the right behavior? Is it possible to see the changes in ViewTester without that explicit mvn compile in core directory?
My setup: Win7, jdk1.7.0_55, Eclipse Luna Service Release 2 (4.4.2), Jspresso Developer Studio from www.jspresso.org/external/updates/e44/
UPDATE: When using refId id:'contact' instead of reference 'contact', ref:'ContactInfo' mvn compile shows the following error:
[INFO] Scanning for changes : C:\jspdev\wstutorial\quickhr\core\src\main\dsl
[INFO] Detected a change on source C:\jspdev\wstutorial\quickhr\core\src\main\dsl\view.groovy. Sun May 31 17:59:40 CEST 2015 > Sun May 31 17:57:14 CEST 2015
NBR ERROR : 1
UR-Unresolved reference : "Company.pane" ask for <Company.contact.address> of type field
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.038s
[INFO] Finished at: Sun May 31 17:59:51 CEST 2015
[INFO] Final Memory: 15M/37M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jspresso.maven:sjs-maven-plugin:4.1-SNAPSHOT:compile-sjs (generate-dsl-application) on project quickhr-core: SJS defined frontend / views is invalid.
[ERROR] NBR ERROR : 1
[ERROR] UR-Unresolved reference : "Company.pane" ask for <Company.contact.address> of type field
[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/MojoExecutionException
UPDATE2: As Vincent has told the refId 'contact', id:'contact' fixed the compilation error when using refid.
Cleaning project workspace does not help with the ViewTester problem. I have discovered that dsl-view.xml is updated in directory C:\jspdev\wstutorial\quickhr\core\target\generated-resources\dsl\de\aboware\quickhr\view when view.groovy is saved but not in directory C:\jspdev\wstutorial\quickhr\core\target\classes\de\aboware\quickhr\view and it seems that ViewTester is reading it from there. Running mvn compile updates the file in this directory (or copying by hand) then ViewTester finds the changes. Any idea why this not happens automatically?
UPDATE3: Maybe it is a eclipse/maven sourced problem. When i do a build clean after saving changes in view.groovy (with autobuild enabled) ViewTester gets the changes without explicit mvn compile on th console. It seems that not all required parts of the project are recompiled automatically after saving changes to view.groovy. Any hints for me?
UPDATE4: For every changes in groovy files i have to do a build clean to see that changes in ViewTester and in SwingStartup. I think it is more a problem of my eclipse version/setup than a problem of jspresso. I have bind a shortcut to build clean what helps somewhat to handle this.
UPDATE5: I have started from scratch 2 times (Kepler/Luna) both times with Jspresso 4.2-SNAPSHOT and checked that the resource directories are there - no success. When saving changes to groovy files the compile-sjs goal ist triggered and the spring xml files are updated in the target/generated-resources/dsl directory. But in the default output directory target/classes nothing happens. When i change a generated spring xml file by hand (from inside eclipse), the target/classes directory gets updated. I think eclipse does not recognise the generation of the spring xml files as a workspace change which has to be answered by an auto build. Maybe there has been something changed in M2E with newer eclipse versions. Should i give it another try with Juno? But i don't know if it makes much sence to use such an old release while Mars is RC2 already.
There was an error in the doc regarding the refId use. This has been fixed by now. The correct statement is :
refId 'contact', id:'contact'
Regarding the main problem, simply relaunching the ViewTester after saving the view.groovy file should be enough to reflect the change. No need to go through CLI. Reading you question, I can see that the Eclipse build is triggered so I presume that automatic build is on which is necessary for the change to appear.
Can you do a complete clean of the workspace (Project > Clean... > Clean all projects) and try again ? There are times when changes in the groovy dsl sources are not correctly detected by the incremental build.
UPDATE: Please make sure that target/generated-resources/dsl is correctly installed as a resource directory in the project. This should be achieved automatically by the JDS plugin registering build hooks in ME2.

Maven MojoExecutionException

I am facing this issue , when i am deploying my application using Maven, please suggest some solution.
Error log,
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.790s
[INFO] Finished at: Wed Apr 23 10:44:13 IST 2014
[INFO] Final Memory: 54M/131M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project clustering.services: Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre7\..\lib\tools.jar -> [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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :clustering.services
Thanks in advance.
set JAVA_HOME to jdk not to JDK_DIR/jre, See this question for how to set the value
If you're using Eclipse, go to Windows->Preferences.
Under Java->Installed JREs, double click on the item in the list and make sure the JRE home points to a JDK (for example, set it to "C:\Program Files\Java\jdk1.7.0_60"), and leave everything else the same.
Most of the time that i get this "Mojo" error. It is just because, i may have forgotten to do "Maven generate-sources" then "Maven Clean" prior to do the "Maven Install" or "Maven Build". The MojoExecutionException should not appear after that. Some Eclipse versions have this problem to refresh the target folder. In this case, Refresh the project just after the "Maven Install".
If not resolved yet, it could be a lot of things (failed to copy a file(s), missing file(s), etc). I would suggest that you run the Maven Install in debug mode by adding -X to get more details on what may have happened then check your log: Right click on project> Run As> Maven Build as the following screenshot:
Verify that the name of the main class to execute in the application is specified in the pom.xml.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mainClass>com.enterprise.mainPacket.MainApp</mainClass>
</properties>
Also check if the .fxml file has been relocated, so that it correctly addresses the controller associated with it. fx:controller="com.enterprise.mainPacket.FXMLController"
<VBox fx:id="vBMasterContainer" prefHeight="698.0" prefWidth="800.0" styleClass="theme" stylesheets="#/styles/style.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.enterprise.mainPacket.FXMLController">
I had the same error. I fixed the path to Java, and was missing the tools jar. I copied it from another place. After that, everything worked.
Check that there are no conflict on the port (another service already running) !
Make sure that you don't have any empty packages within your source code folder. If there aren't any classes, the same error will occur.
After I changed the version in pom.xml to 1.2.1, the error was resolved.

Java EE 7 First Cup Tutorial errors in Maven: Could not find artifact org.glassfish.javaeetutorial.firstcup:firstcup:pom:7.0.1-SNAPSHOT

I'm following along with the Java EE 7 updated version of FirstCup. I have glassfish 4 installed and am using NetBeans 7.3. I'm working on the very first example and I'm getting maven issues.
I generated the archetypes and am able to create the dukes-age project. However it has non-resolvable maven issues:
Could not find artifact org.glassfish.javaeetutorial.firstcup:firstcup:pom:7.0.1-SNAPSHOT
Here is the full error:
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.mycompany:dukes-age:1.0-SNAPSHOT (/Users/koblentz/NetBeansProjects/dukes-age/pom.xml) has 1 error
[ERROR] Non-resolvable parent POM: Could not find artifact org.glassfish.javaeetutorial.firstcup:firstcup:pom:7.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM # line 5, column 13 -> [Help 2]
[ERROR]
I'm not really sure what to do/how to fix this. I deleted my local cache in the .m2 repo and tried building from the commandline instead of using NB to run the maven commands.
Any ideas?
Filed this issue as:
https://java.net/jira/browse/FIRSTCUP-14
The workaround is to replace the parent definition:
<parent>
<artifactId>firstcup</artifactId>
<groupId>org.glassfish.javaeetutorial.firstcup</groupId>
<version>7.0.1</version>
I'm working on getting an updated package in the Update Center.
Fixed it. The pom generated by the archetype is looking for 7.0.1-SNAPSHOT and the actual version in m2 repo is 7.0.1 without the SNAPSHOT on the end.
To get it to resolve the parent pom, you also need to install the examples application tutorial at NetBeans/glassfish-4.0/docs/firstcup/example/pom.xml.
I had the same error, in my case it was because I copied the glassfish folder with the example in to the C:\programs folder and Netbeans, after i copied it in Documents all works fine.

Categories