Maven update results in NullPointerException. Where to find the stacktrace/cause? - eclipse

First a tiny bit of background:
I'm working on a large application for which the development started around 2008 (so as you can imagine, it's huge with loads of dependencies of which part are already unsupported/outdated)
I have a git branch with the current (developer) version, as well as a bunch of other branches with earlier versions (and some other branches like master and such, but those are irrelevant for now)
These days, every time I switch from the current branch to an older branch to do some hotfixes, the Maven update and Clean build work fine. However, when I switch back after the hotfix is done to the current branch, and do a Maven update, I get the following error:
This is a pretty well-known error based on some earlier stackoverflow questions I saw. Most answers you'd find will say to remove the entire .settings and .project files, and re-import the project; or to remove the .metadata of your workspace, and restart Eclipse. In the past I remembered using this solution of only deleting the .metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi file of the workspace, so the damage to your Eclipse project settings is limited. However, it doesn't always work, and I'm also getting a bit tired of getting this exception every single time I switch back and forth from a branch..
Note that I've already tried a bunch of other things without much avail:
Removing my entire .m2 folder and letting it download everything from our Nexus again
Looked in the Maven Console to see what is being logged, which isn't anything related to this NPE unfortunately
Do the Maven Update Project both with or without "Force Update of Snapshots/Releases" enabled
Do a Clean Build with the "Update Snapshots" enabled
What I'm mainly looking for right now is a stacktrace of this NullPointerException, so I can (hopefully) fix this issue at the core of the problem, instead of using all these workarounds like deleting Eclipse/Maven folders and/or settings (which only work halve of the time anyway)..
It gives a NullPointerException, so I assume I should be able to see the stacktrace of this NullPointerException to determine the cause somewhere in an Eclipse log or console, shouldn't I?
Is there perhaps a mvn command flag/argument I could use? Or is this NullPointerException an issue of Eclipse rather than Maven?

Related

What is netbeans doing now?

This is getting tedious. I created a test project, simple java hello, to test a problem I have in another project. Having created the project, I could run it and build it to a jar.
Then I added some ivy stuff and tried a build which did not work. The ivy stuff consisted of ivy.xml ivysettings.xml and 2 tasks added to the otherwise default netbeans build.xml.
So then I removed the ivy files and the ivy sections from build.xml. I then did a diff on that and the previous unedited build.xml file and they are identical.
So now why after a clean build do I get this error?
/home/tester/WORKSPACE/NetBeans/Foo/nbproject/build-impl.xml:63: Source resource does not exist: /home/tester/WORKSPACE/NetBeans/Foo/lib/nblibraries.properties
Correct that file does not exist and it does not exist in any other project I have access to whether they use ivy or not.
I have reset everything I did yet Netbeans cannot continue. I have tried to work out how the hell nb actually builds a project but got lost. Just don't know what to say.
I guess nb and myself differ on what clean actually means and also on whether a task should be able to produce exact same results everytime given the same input, something that nb does not seem to be able to do. That or it cannot recover from the real world or their documentation just hides the useful information like how to reset a project.
I'm assuming there is some nb state that needs to be cleaned up manually but have no idea where to start. Any ideas please?
#Tim Biegeleisen, your comment got me thinking.
I shut down/restarted netbeans then tried the build again and it worked. So it seems that ivy is still running inside netbeans and has some form of state for my project that it will not release. I'll have to dig around to see if there is a way to reset ivy state without restarting nb but this whole process is turning in to a very tedious onerous task. I seem to be spending more time on the dev tools than I am on solving my coding tasks.
So the solution/workaround to my problem seems to be to restart netbeans to clear ivy state.

Can anyone help me fix this m2e-jdt/jdt bug?

Introduction
I have spend a lot of time to fix this bug
In our application we have a lot of generated code by cxf and jaxb which produces tons of warnings. We use the maven-build-helper plugin to add this code to our projects automatically.
By adding this enhancement, eclipse JDT enabled the possibility to set the javac -nowarn flag for specific source folders. Unluckily, by updating the maven project the flag gets lost. There are a few threads on SO where users got bugged by bug.
What I have tried so far
So i came up with a clever solution, javac has a nowarn flag. I set it to my maven-compiler-plugin and specified the directory. My maven build was fine, but my eclipse build wasn't. My research told me, that eclipse jdt does only use the maven-compiler-plugin source and target version. So my next step was to try to configure the EclipseCompiler, but this is not possible, because there is no possibility to add custom compiler Arguments in eclipse JDT.
Next Step. Inside of the .classpath file, eclipse JDT adds an ignore_optional_problems attribute for each ignored path. By updating the maven project inside of eclipse, this entry gets lost. So i started to write a maven "ignore-source-folder" plugin which should add the missing attribute. To run the plugin each time eclipse starts a build, i also created a m2e connector to refresh the .classpath file and everything should be fine.
By testing my plugin with my connector i realized, it works, but only 70% of the repetitions.
What happened?
Every time eclipse m2e/Jdt starts a new build, all classpath entries will be removed and populated again. When my maven plugin gets triggered by eclipse, a race condition starts.
So I started to analyze the code of jdt and m2e jdt. The ignore_optional_problems flag gets only once set manually inside of the patch which was provided to JDT and isn't stored somewhere else. By triggering a new build via m2e-jdt this information gets lost.
How to fix this problem
To fix this problem, some element has to be added or extended in jdt which contains all ignored folders. If a new build gets triggered and the classpath file gets newly generated by m2e-jdt this element should be checked for ignored paths. ClasspathEntryDescriptor seems to be a good place for it.
My problem
I checked out jdt and m2e jdt, but i have tons of errors inside of my IDE and i have no idea how to start. And even if I fix the code, I have no idea how to build and test it. I think my effort will be to high and we talk about 20 or 30 simple lines of code.
I am afraid if I add my results to the filed bug at eclipse, no one will care about it.
So, is there any developer able and willing to help me for this tiny job?
You need to "fix" the M2E's JDT project configurator. Probably somewhere in the m2e-core project. So, your change should obtain some kind of configuration flag from the project pom and create corresponding classpath entries for JDT.

Remote Play framework and Eclipse

I have a play framework project which run on remote server.
I'm trying to configure eclipse to work remotely on the project.
since no build is required my requirements are to be able to edit the project files from eclipse and automatically save on server, auto complete and debug.
I've installed Remote System Explorer on eclipse and setup a remote ftp connection to my server.
The play environment on my server is under
/play-2.0.2/
My project path is
/play-2.0.2/test
In RSE I clicked on /play-2.0.2/test and 'Create Remote Project'
Now in Java perspective I can browse through the project, change files and then automatically save to server.
My problem is auto completion of play framework library doesn't work well since all the reference are to /play-2.0.2/repository/...
any idea how to solve it? I tried to play with the build path but no success
Thanks!
So, I was looking into achieving the same thing myself.
The problem you are experiencing is due to the fact that the .classpath file has absolute values. While for me, besides the symlink that doesn't work between two different kinds of O.S., I thought on another two solutions:
Use sed to rewrite the classpath on the .classpath file after it's generated
Use a "classpathTransformerFactory" for the sbt eclipse command
I haven't had to deal with it (it's more of want to than whatnot) as soon as I do, I will explore the two options and post details. I just leave the answer here in case someone wants to pick up where you left.
Another thing is:
Seen that sbt picks up the libs referenced in build.sbt, downloads the jars and puts them in the ~/.ivy2 directory, if you use any of those methods to change the reference from the remote machine to the local one, you would need to make sure that the same libs are on the local ivy cache. So, just as I wrote this, another idea came to mind:
sbt eclipse or play eclipse or activator eclipse [it should be the same] on a local environment, and on the remote one, then, transfer the .project and .classpath files from the local to the remote, and see what happens (if it doesn't work, scan them for absolute and incorrect paths that might need to be changed)
Sorry for the unproved answer, still I think it's better than no answer.
Cheers

Incremental Publishing in Eclipse for Static Web Project

I have a static Web project added to an Apache server. Whenever I make a change to the project, regardless of how small the change is, the entire project republishes instead of the individual file. I was under the impression that the publishing process was supposed to keep a delta and only republish the files that have been marked as changed in the delta.
I wouldn't mind if the project were small, but it's a large project (200+ MB) and the connection to the server I'm publishing to is a bit slow. A republish takes anywhere between 15 minutes and a half hour.
Does anybody know if my install of Eclipse is working as expected?
Environment Specifics:
Eclipse Galileo
Aptana Studio Plug-in 1.5.1
Maybe you've found a bug. Try rsync instead.
There was a bug about delta publishing, but it should be fixed by now. And from other Eclipse projects, I assume that they added a test case for this, so it shouldn't happen again. But maybe your circumstances trigger a new bug.
Are you manually changing the files or do you use some script outside of Eclipse? Anything that makes Eclipse think the whole project has changed, will trigger a full redeploy.

maven classpath container refresh job

I get stuck with m2eclipse and maven. After adding some dependency (hibernate 3.4, but I guess that doesn't really matter) eclipse got stuck with a message like in the title. Removing the dependency from pom file didn't help either. Restarting eclipse, checking out this as a clean project from repo neither. Alwyas gets stuck on refreshing. :/
What can get (m2)eclipse stuck on refreshing the project? All ideas welcome.
Workspace resolution can really slow the dependency resolution down. Maven needs to partially calculate each project to determine the dependency hierarchy, the time taken to do this increases rapidly as the number of related projects increases. To limit this, close projects you're not working on or uncheck the option to resolve workspace projects (so Maven will resolve the dependencies from the local repository, this means you need to install the projects after each update though).
If that doesn't help, try one of these:
Are your Maven settings correct? It may be that the preferences are not pointing to your platform install so Maven is downloading the dependencies to your user home in the background - this can take ages. If so tweak those settings. Select Window->Preferences->Maven and check if it is using the embedded Maven or not.
If you are behind a proxy you will need to set the proxy settings in your preferences, though if the problem is intermittent it won't be that.
Sometimes the persisted container isn't updated, I've never been able to isolate exactly why. I've found that closing the project and reopening can prod the container back into life.