I am working on a GWT 2.4/Maven/Spring project that uses a JAR from another project. I have added a GWT module file (.gwt.xml) to the referenced JAR to make its classes translatable by GWT. Things worked fine for a while, then all of a sudden (i.e. after one of the many code changes) I am now getting this error in Eclipse:
Failed to read module XML file
sun.net.www.protocol.jar.JarURLConnection$JarURLInputStream#68e72c
(org.codehaus.mojo:gwt-maven-plugin:2.4.0:compile:default:prepare-package)
pom.xml /PivotReportsWeb line 118 Maven Build Problem
PivotReportsWeb is the name of my GWT application. The error refers to execution inside the gwt-maven-plugin declaration in my pom.xml. However, Maven happily builds the project from command line with no errors or warnings whatsoever.
Forcing Maven to update project dependencies didn't work, nor did any of the many other tricks I've tried.
Any thoughts, anybody?
UPDATE
As it turned out, it was a Windows permissions issue! I noticed that I could no longer delete the referenced project's target folder or modify my user permissions on it (even though I am a local admin). So I rebooted and -- VOILA! Everything works again.
Reminds me of a geeky slogan I saw once on a friend's T-shirt: REBOOT IS SEXY
Related
What are the possible causes of a "java.lang.Error: Unresolved compilation problem"?
Additional information:
I have seen this after copying a set of updated JAR files from a build on top of the existing JARs and restarting the application. The JARs are built using a Maven build process.
I would expect to see LinkageErrors or ClassNotFound errors if interfaces changed. The above error hints at some lower level problem.
A clean rebuild and redeployment fixed the problem. Could this error indicate a corrupted JAR?
(rewritten 2015-07-28)
Summary: Eclipse had compiled some or all of the classes, and its compiler is more tolerant of errors.
Long explanation:
The default behavior of Eclipse when compiling code with errors in it, is to generate byte code throwing the exception you see, allowing the program to be run. This is possible as Eclipse uses its own built-in compiler, instead of javac from the JDK which Apache Maven uses, and which fails the compilation completely for errors. If you use Eclipse on a Maven project which you are also working with using the command line mvn command, this may happen.
The cure is to fix the errors and recompile, before running again.
The setting is marked with a red box in this screendump:
try to clean the eclipse project
you just try to clean maven by command
mvn clean
and after that following command
mvn eclipse:clean eclipse:eclipse
and rebuild your project....
Your compiled classes may need to be recompiled from the source with the new jars.
Try running "mvn clean" and then rebuild
The major part is correctly answered by Thorbjørn Ravn Andersen.
This answer tries to shed light on the remaining question: how could the class file with errors end up in the jar?
Each build (Maven & javac or Eclipse) signals in its specific way when it hits a compile error, and will refuse to create a Jar file from it (or at least prominently alert you). The most likely cause for silently getting class files with errors into a jar is by concurrent operation of Maven and Eclipse.
If you have Eclipse open while running a mvn build, you should disable Project > Build Automatically until mvn completes.
EDIT:
Let's try to split the riddle into three parts:
(1) What is the meaning of "java.lang.Error: Unresolved compilation
problem"
This has been explained by Thorbjørn Ravn Andersen. There is no doubt that Eclipse found an error at compile time.
(2) How can an eclipse-compiled class file end up in jar file created
by maven (assuming maven is not configured to used ecj for
compilation)?
This could happen either by invoking Maven with no or incomplete cleaning. Or, an automatic Eclipse build could react to changes in the filesystem (done by Maven) and re-compile a class, before Maven proceeds to collect class files into the jar (this is what I meant by "concurrent operation" in my original answer).
(3) How come there is a compile error, but mvn clean succeeds?
Again several possibilities: (a) compilers don't agree whether or not the source code is legal, or (b) Eclipse compiles with broken settings like incomplete classpath, wrong Java compliance etc. Either way a sequence of refresh and clean build in Eclipse should surface the problem.
I had this error when I used a launch configuration that had an invalid classpath. In my case, I had a project that initially used Maven and thus a launch configuration had a Maven classpath element in it. I had later changed the project to use Gradle and removed the Maven classpath from the project's classpath, but the launch configuration still used it. I got this error trying to run it. Cleaning and rebuilding the project did not resolve this error. Instead, edit the launch configuration, remove the project classpath element, then add the project back to the User Entries in the classpath.
I got this error multiple times and struggled to work out. Finally, I removed the run configuration and re-added the default entries. It worked beautifully.
Just try to include package name in eclipse in case if you forgot it
Import all packages before using it, EX: import java.util.Scanner before using Scanner class.
These improvements might work and it will not give Java: Unresolved compilation problem anymore.
Also make sure to check compiler compliance level and selected jdk version is same
As a weird case, I encountered such an exception where the exception message (unresolved compilation bla bla) was hardcoded inside of generated class' itself. Decompiling the class revealed this.
I had the same issue using the visual studio Code. The root cause was backup java file was left in the same directory.
Removed the backup java file
When the build failed, selected the Fix it, it cleaned up the cache and restarted the workSpace.
I have been working on a Java (Java 8) web application in Eclipse, using maven for one year. I created this webapp and use Maven v 3.5 since the beginning of my project. I usually deploy my web application on a tomcat 8.5 server ('Run as => run on server').
I have always managed my dependencies with my pom.xml, preventing with doing weird things using hte build path configuration menu from Eclipse.
The issue started yesterday : I add a dependency from other java/maven project I have madeand installed simply before, and add this lines on my pom.xml :
<dependency>
<groupId>tlnPdf</groupId>
<artifactId>tlnPdf</artifactId>
<version>1.0</version>
</dependency>
As my eclipse does sometimes when I add a new dependancy from other project, I had an issue when deploying the webapp, some message (sorry but I can't remember it) about the pom.properties from my other project. In this case, and as I always did, I just have to close my webapp project, launch a mvn eclipse:clean from a command prompt and then reopen my project; and the issue disappear.
Eclipse doesn't show issue on the classes that import classes from the new dependancy included.
Also I have a listener on a class at the starting of my webapp, declared on my web.xml :
<listener>
<listener-class>com.package.InitTomcat</listener-class>
</listener>
This listener is funcional and I have not modified it lastly.
But yesterday, a new issue appear; when I wanted to deploy my webapp on my server, I had a lot of warning like this :
org.apache.catalina.webresources.Cache.getResource Unable to add the resource at [...] to the cache because there was insufficient free space available after evicting expired cache entries - consider increasing the maximum size of the cache. And then, an error telling me that the InitTomcat class does not exist :
java.lang.ClassNotFoundException: com.package.InitTomcat
So, firstly I thought that the cache warning was causing the issue. I did what this this stackoverflow post explain, and the warnings disappeared; but not the error.
Outside from eclipse, in a command prompt, I try to compile my project and getting my app.war file using mvn clean install. The compilation did not show any error, and the war is correct. I deployed manually my war on tomcat and no issue appeared.
Thus, I look on the two deployed directory (one from eclipse, the other manually by my app.war) and I saw something curious on the tree of repository deployed :
On the good deployed webapp (from app.war), I have something like that:
|*some directories and files
|*META-INF
|*WEB-INF
|*classes
|com (etc...)
|*lib
|web.xml
And in the deployed webapp from eclipse :
*some directories and files
*META-INF
*WEB-INF
|*classes
|*.settings (why the hell does this directory are here ?)
|*bin
|*.settings
|*src
|*target
|*classes
|*com ect... (my .class files are here !!)
|*generated-sources
|*m2e-wtp
|*maven-archiver
|*maven-status
|*myapp (this directory have the same content as the "good web app deployed")
|*test-classes
|*WebContent
|*temp
|*webContent
|pom.xml
|.project
|*src
|*target
|*temp
|*WebContent
|*...
|*lib
|web.xml
The "good" webapp as a size of 275Mb, the other is 865Mb
I suspect that the issue occur when eclipse deploy my web-app and which explain that it could not find the InitTomcat class since it seems to be at the wrong place. But I have no idea why it decided to do this now.
I tries to delete the project from eclipse, cleaning eclipse, etc... but no result. I have tried with 3 different versions of tomcat : 8.5.14, 8.2.23 and 9.0.2, always with the same behaviour
As I was depressed, I download the last version of eclipse, and import my webapp project into it with maven; but it has the same result.
Finally, my question is simple : does anyone has an idea of what it is happening, and how to solve it ? Thanks in advance !
I finally saw where my problem was: looking on properties > "deployment Assembly" of my project, the deploy pathes were weird. I dont know when did he change, nor why, but I did the following to reinitiate "cleanly" them:
Delete the project (but not the sources) in eclipse
Manually delete .settings directory, .classpath and .project files
Import as a maven project in eclipse
These do the tricks. The issue is that before, I had not deleted the properties files from eclipse and the bag configuration was reload when importing the project.
Introduction
I have inherited a project that I am able to build using the maven command mvn clean install -DskipTests. However, I am not able to make using the inteliJ button. I am able to deploy the project using Remote debugging but I am not able to hotswap new code in/out due to make not working.
Errors during make
When I run make I get a series of errors such as:
Older Maven Version
I have been told to use an older version of maven, specifically 3.0.3 .
I have gone to the settings for the current project and manually set maven 3.0.3 as the default.
Question 1) Is there a chance this does not apply to the sub directories? Should I change my system path variable and set the old maven as the system default?
Red Highlighting in POM.XML
I am seeing that InteliJ is highlighting a pom.xml in one of the sub-modules for errors. This code has been committed by colleagues so it is strange that there would be errors.
and
and
Question 2) Could Maven be the issue here? Or could there legitimately be an error in the POM.xml?
Maven > Reimport does not solve the issue
Additionally, running Maven > re-import does not solve the issue.
Updating Indices
I tried selecting the proposed option to Update Maven Indices. This has brought up the following dialogs and is downloading in the background from both the maven servers but also a private artifactory.
The indices were taking too long to update so I invalidated the cache/restarted and will try again as proposed # Intelli J IDEA takes forever to update indices .
Summary of Questions
Question 1) Is there a chance this does not apply to the sub directories? Should I change my system path variable and set the old maven as the system default?
Question 2) Could Maven be the issue here? Or could there legitimately be an error in the POM.xml?
Update
Indices finished downloading after some time.
I removed some of the problematic entries in the pom.xml and the project now is not red-underlying the various packages that they do not exist.
I am starting to believe the pom.xmlwas problematic. However, if someone downloads the dependencies/indices, then the problem no longer appears.
Update - Remove Module
I talked with a colleague and he said the specific modules are no longer used (even if they do include faulty pom.xml files). I was told to right click the module and select "remove module". This pretty much stopped the problem.
I talked with a colleague and he said the specific modules are no longer used (even if they do include faulty pom.xml files). I was told to right click the module and select "remove module". This pretty much stopped the problem.
I have a project that runs Spring and I am using IntelliJ as the compiler. I started building the project in Ubuntu but I was having problems viewing my database edits so I switched to Windows and lost my Ubuntu partition (due to some other unrelated error). I am trying to reset up my project in Windows but I can't get it to compile properly.
I have tried redownloading IntelliJ, restarting my computer, clean installing maven, and searching everywhere for a solution. I found a link on IntelliJ's website but they never actually address a solution to the problem ( http://devnet.jetbrains.com/thread/436515 ). I started to try the unfinished advice to "remove all artifacts selected for deployment from the list and then add them again" but I cannot figure out how to add them again once deleted.
Additionally, I keep seeing the error "Configuration Error: deployment source '(projectname): war exploded' is not valid"
Any advice or tips to what I could try or am doing wrong would be great.
Thanks!
This will happen when you remove an artifact that is already set in the configuration. You can see the artifact is red in the configuration:
To solve it, just removed the missing one and add another valid artifact.
Edit Configurations - deployment add your artifacts.
Maybe you can try the following process.
1.Open Project Structure add an artifact (web application:exploded) from modules, select your module, add it:
2.Build Artifacts [(top menu) - build - build artifacts - build]
3.Edit Configurations - deployment add your artifacts
I fixed the issue for me.
I do not know why, but for some reason my .war file got corrupted. I went to Project Structure > Artifacts, deleted my old artifact (which IntelliJ already highlighted red) and added it again.
One of the reason it may happen is, you have restructured your project packages. In that case you have to re-adjust your run configuration in the intelliJ. Edit Configuration > Deployment (On your server) > Delete the existing one and add newly build war again.
Long time ago, i faced similar issue. I made a Spring MVC webapp using IntelliJ on Ubuntu(Running on a VM).
Later on when i tried to run it on Windows IntelliJ, it went bonkers... so to fix that...
I deleted all IntelliJ configuration files, *.iml target WARs
and then it worked fine.
For those who restructured and/or moved a lot of files; a rebuild will fix this error
Build Artifacts (Top menu - Build - Build Artifacts):
I have a straightforward maven2 java project (JMS relaying system). After we released the first version, we found that we spent more time configuring maven than actually coding.
For the next release we wanted to clean up the build process and someone suggested migrating to builder. So I was tasked with doing just that.
I setup buildr (1.3.4) according to the documentation on their website. And then from the root of the project I typed the buildr command and then informed buildr to create the build file based upon my pom.xml. That processed fine and compiled all the code. All was gravy until buildr started running the tests. Here is the ouput:
Test framework error: taskdef class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask cannot be found
Obviously the class specified isn't in my classpath. However, the buildr documentation says that all the required items needed for basic testing are included. Their documentation doesn't say that they need any specific libraries for ant or a version of ant. Although I do have ant 1.7.0 installed (not included in my classpath however).
Has anyone seen this before?
Update
I located the infamous ant-optional jar on the maven repository. Including that in my test.with options did not resolve the issue.
Running the buildr command with --trace gives this extra information...
Tests failed!
/pathtoruby/buildr-1.3.4/lib/buildr/core/test.rb:455:in `run_tests'
/pathtoruby/buildr-1.3.4/lib/buildr/core/test.rb:199:in `initialize'
Found the issue... Apparently there is an ant-junit.jar that is needed but for whatever reason in my local repository it was owned by root and not my local user account (OSX system). So it wasn't accessible to buildr. I deleted the items from my local repository and reran buildr (it downloaded the needed items).
Update
Also this caused a few other issues. It seems that a few other items in my local repository had strange permissions. I ended up just archiving my repository and letting maven reconstruct it. This resolved all my issues. I now have a nice build file that is 25 lines of code compared to my previous pom.xml file that was over 100 lines.
You get that error because JUnitTask isn't on the classpath. I'm not very familiar with Buildr so can't say if it is required for you to specify the JUnit jars or not, but if Buildr uses the system classpath, try adding JUnit to it and see what happens.
Once you've confirmed your builds will run with JUnit hacked in to the classpath, you can then try varying your configuration until it runs as you expected, or leave it as is.
Can you post the reference to the relevant part of the documentation? I didn't see anything (in my very brief reading of the site) that says required items are included.
Is it possible that you've not downloaded all the gems? If you run "gem update --system" to update Ruby, then "gem update buildr" you can ensure that the required dependencies have all been installed.