I got one weird problem with eclipse as well as in Spring Tool Suite.
At first I created a Maven project in Eclipse, And it works absolutely fine without an issue. As in below image you can see "Deployment Assembly" option is visible in it.
So, after that I copied the entire project as it is and given to my friend. So he imported it as maven project, But the option of "Deployment Assembly" was not visible, due to which "Tomcat's LifeCycleException" occurs. We can solve that solve that exception only when we add Maven dependencies at java build path entries, But for that you need Deployment Assembly option to be visible.
Here is the screenshot taken from my friend's Eclipse after importing my project as it is without any change.
So is anyone know the cause of this. As I am getting that exception. Any help or suggestion will be much appreciated. Thanks
Related
We have a multi-module Maven project: project-war depends on project-api.
I have imported the modules into IntelliJ, and I would like to use tomcat7:run to run run the project-war application in Tomcat. I do so, the application runs fine.
I make a change to project-api, stop Tomcat, restart Tomcat. The project-war application runs again fine, but the changes to project-api are not reflected as expected.
How to get the transitive changes from my workspace to be reflected when running tomcat7:run?
I've tried "Resolve Workspace artifacts". It didn't help. In fact, I don't get this setting at all.
I've tried "Before launch:" "Make". It does what appears to be a build (compile) but it didn't help either.
I think what I"m looking for is pretty much what m2e/Eclipse calls workspace resolution. Can't get it to work in IntelliJ. Your help much appreciated!
This is a good repository to test this out.
As it turns out, this problem existed using IntelliJ 12.1.7, but not anymore using IntelliJ 13.1.5.
Workspace resolution works with a combination of the described configuration:
Resolve Workspace Artifacts
Before launch: Make
I've been fighting an internal Eclipse error for two days. I'm running the latest Spring Tool Suite edition of Eclipse, and I've attempting to import a collection of existing Maven projects. Whenever I do so, Eclipse throws a NullPointerException, but no stack trace is available from the Error Log view. If I instruct Eclipse to update the Maven project (Maven > Update Project), I get a NullPointerException again. This time, the Error Log view reports the following stack trace:
java.lang.NullPointerException
at org.eclipse.wst.common.componentcore.internal.resources.VirtualResource.getProjectRelativePaths(VirtualResource.java:119)
at org.eclipse.wst.common.componentcore.internal.resources.VirtualFile.getUnderlyingFiles(VirtualFile.java:104)
at org.eclipse.wst.common.componentcore.internal.resources.VirtualFile.getUnderlyingResources(VirtualFile.java:93)
at org.eclipse.wst.common.componentcore.internal.resources.VirtualResource.exists(VirtualResource.java:88)
at org.eclipse.jst.common.internal.modulecore.util.ManifestUtilities.getNonBinaryComponentManifest(ManifestUtilities.java:124)
at org.eclipse.jst.common.internal.modulecore.util.ManifestUtilities.getManifest(ManifestUtilities.java:81)
at org.eclipse.jst.common.internal.modulecore.util.ManifestUtilities.getManifestClasspath(ManifestUtilities.java:147)
at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getManifestClasspath(J2EEModuleVirtualComponent.java:248)
at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.calculateManifestReferences(J2EEModuleVirtualComponent.java:368)
at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.cacheManifestReferences(J2EEModuleVirtualComponent.java:360)
at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java:176)
at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java:214)
at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java:207)
at org.eclipse.m2e.wtp.WebProjectConfiguratorDelegate.configureClasspath(WebProjectConfiguratorDelegate.java:386)
at org.eclipse.m2e.wtp.WTPProjectConfigurator.configureClasspath(WTPProjectConfigurator.java:107)
at org.eclipse.m2e.jdt.internal.DefaultClasspathManagerDelegate.populateClasspath(DefaultClasspathManagerDelegate.java:61)
at org.eclipse.m2e.jdt.internal.BuildPathManager.getClasspath(BuildPathManager.java:253)
at org.eclipse.m2e.jdt.internal.BuildPathManager.getClasspath(BuildPathManager.java:363)
at org.eclipse.m2e.jdt.internal.BuildPathManager.getClasspath(BuildPathManager.java:343)
at org.eclipse.m2e.jdt.internal.BuildPathManager.getClasspath(BuildPathManager.java:371)
at org.eclipse.m2e.jdt.internal.BuildPathManager.updateClasspath(BuildPathManager.java:191)
at org.eclipse.m2e.jdt.internal.BuildPathManager.mavenProjectChanged(BuildPathManager.java:180)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.notifyProjectChangeListeners(ProjectRegistryManager.java:746)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.applyMutableProjectRegistry(ProjectRegistryManager.java:865)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:289)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration0(ProjectConfigurationManager.java:369)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$2.call(ProjectConfigurationManager.java:316)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$2.call(ProjectConfigurationManager.java:1)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:161)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:137)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:89)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1301)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:313)
at org.eclipse.m2e.core.ui.internal.UpdateMavenProjectJob.runInWorkspace(UpdateMavenProjectJob.java:77)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Here's what I've tried:
I've blown away my workspace and created a new one. Multiple times.
I've blown away my Maven repository so that it would be re-created.
I've reinstalled Spring Tool Suite.
I've tried asking Eclipse to update the Maven repositories.
I've checked for merge conflicts in my local SVN repository. (There are none; this is a brand new branch from trunk that is freshly checked out.)
I've checked the Synchronize view in Eclipse to see if it notes any differences. (Eclipse can't get far enough to recognize any projects available to synchronize.)
I've searched Google for NullPointerExceptions occurring in VirtualResource.getProjectRelativePaths(). I've found NullPointerExceptions in other very similar places, and I've tried the recommendations for them, just for the heck of it, but none of them work.
I'm at my wits' end with this problem. Help me, Obi-Wan Kenobi, you are my only hope.
This is what I did to fix it:
Removed the project from the workspace
Remove .classpath, .project and .settings folder
Reimport the project
I'm strongly sure that the problem is not related to the maven plugin; but if it is, i was wandering if you run a mvn eclipse:eclipse before importing the project into eclipse, if you do that and you are using maven 3, I had checked that maven plugin does not support maven 3 properly yet; so I encourage you to make a mvn eclipse:clean, then import the project as an existing project, and after that activate the maven plugin nature from eclipse.
I hope it helps,
PS. it seems to be a know eclipse bug (https://www.google.com.uy/search?q=j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java&oq=j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java&aqs=chrome..69i57.128j0j7&sourceid=chrome&espv=210&es_sm=91&ie=UTF-8); try downloading the last eclipse version; I'm using kepler at work, and I'm working in maven/spring projects and it works fine.
Good luck!
This happens because your m2e plugins are corrupted. To rectify follow the steps below.
close eclipse
Go to your eclipse workspace folder Under .metadata/pluigns folder, identify all m2e plugins
delete them
copy the relevant plugins from non-corrupted workspace, either from
your machine or from any one of your team members machine
restart eclipse
As echinelli indicated, this did turn out to be an Eclipse (or STS) bug, but installing the latest version isn't the fix, as I already had that version installed. I had installed STS based on Eclipse 4.x; when I uninstalled that and went to the 3.x version, the problem went away.
Ok, I had the same issue with a more obscure reason.
I used pluginExecution for aspectj-maven-plugin and over the course of trying to fix yet another maven issue I had commented out <action><execute><execute></action>
This leads to the nullpointerexception.
I solved by adding the <build> section with "maven-compiler-plugin" artifact in the POM. I noticed that without it, Eclipse threw a java.lang.NullPointerException.
I'm using Eclipse for Java Develepers (Juno x64 running on Windows 7).
I have a project in which I was trying out a jar I no longer need (args4j), so have removed the dependency. At some point, my PC lost power unexpectedly, and I've since restarted Eclipse.
My project now has an error, "Project 'MyProject' is missing required library: '/path/to/args4j-2.0.21.jar'". I was working with the project for some time after removing the dependency without any issues.
Under the Project Properties > Java Build Path, there's no reference to args4j in any of the tabs.
I've tried:
searching for the string "args4j" in all files within my project, but there are no matches. There are a bunch of references within <workspace>\.metadata\.plugins\org.eclipse.core.resources\.history\, but I'm reticent to touch them out of fear I might break something else.
[Edit] clean rebuild has no effect.
Does anyone have any idea why Eclipse is complaining, and what I might be able to do to fix it?
Please do the following, if one does not solve your problem, skip to the next one:
Check .classpath file in your project folder. You might have a reference there.
Close and re-open the project without closing eclipse, this might rebuild Eclipse resource cache.
Make a clean build after re-opening.
Re-import your project into a clean workspace.
Re-adding the problematic jar, then removing it did the trick. This is better than reconfiguring the entire workspace in my case, as I have many projects, and ADT configuration in my workspace.
I've found that the easiest and simplest way is to switch to the navigator view, open the .factorypath file and delete the offending dependency.
Deleting .classpath and .project, then reimporting the project as a Maven Project did work for me. It may also be useful to mark all Eclipse workfiles like .classpath in the p4ignore or gitignore from the beginning at the initial commit.
DO - mvn eclipse:clean eclipse:eclipse, on project and then refresh and then clean project , will solve this problem
I'm working on a swing project, using maven2 (from command-line) and eclipse (without maven integration). So, I generate the eclipse project through maven eclipse plugin (mvn eclipse:eclipse), import it inside eclipse, and do all my work.
My problem is: when I run my app in eclipse (as a Java Application), I can't find none of the resources that are in my src directory. Digging for information on my problem, I get into this answer from another question. So, I compared the output from the following instructions:
MyClass.class.getResource("/").getPath();
MyClass.class.getProtectionDomain().getCodeSource().getLocation().toString();
Those gave me the following outputs, respectively:
${workspace_loc}/${my_project}/target/test-classes/
file:/${workspace_loc}/${my_project}/target/classes/
Checking the above locations, I could see that the former is empty, while the other one contained all my compiled classes and resources. So, I came to the conclusion that the classloader is looking for my resources in the wrong place. So, I think I have three questions:
Is my understanding correct?
If so, how it does to find the classes it is loading?
How do I solve this?
UPDATE: I've changed my code, so instead of invoking MyClass.class.getResource(...) or MyClass.class.getResourceAsStream(...), I'm now using ClassLoader.getSystemResource(...) and ClassLoader.getSystemResourceAsStream(...). In this way, everything is working fine in eclipse. I just don't know exactly why. Any hint on this?
Two possibles cases for me :
You are using eclipse to compile your project. Then eclipse is configured to exclude (or not include) resources in the src folder. You can set it in Project/Properties/Java Build Path/Source. Then you expend your src folder, and ensure you have something like "Included All", "Excluded None".
You run your maven application using maven to compile and not eclipse, even though you are using eclipse as your IDE. Then by default maven will not copy resources from the source folder to the output folder... Because it is not the standard maven way of doing things. Thus the resource are missing from the classpath and you don't find them. Just change your maven configuration to also include resources from your source folder.
I think you have to add src/main/resources to the build path. This is done in Project Properties > Build Path > Source. Here is how the standard maven project looks:
In future when using Eclipse I suggest to use m2eclipse plugin and create project using it. This will automatically make sure that all these folders are in the build path.
Try this:
Run configurations... -> Classpath -> User Entries -> Advanced... -> Add Folders
Can you try loading the resources using below?
this.getClass().getClassLoader().getResourceAsStream(propertyFileName)
This might be useful information
Eclipse Maven plugin has its own Classpath Container that conflicts with generated class paths when enabled.
What I would suggest is stop using eclipse:eclipse (sorry - harsh I know). I used it for about 8 months, cant believe it took me that long, and used M2Eclipse. M2Eclipse is an eclipse plugin in which you do the following.
Enable Dependency Management.
Update Project Configuration
(In Eclipse) Project -> Build Project
(In Eclipse) Run Application
It may not seem it, but its a much easier and less frustrating way of doing it.
Before, with eclipse:eclipse. You would have to run it then hit refresh and hope that everything is configured - if you have a multi-module pom things can really go wrong.
For me the Files within the WEB-INF were not getting included. Hence I added them to Buildpath (Project -> Build Path -> Configure Build Path -> Add folder (project/src/main/webapp). This resolved the issue.
I'm expiriencing multiple compilation errors in my project, most of the code is in red, but the strange(or not) thing is that while building the project with maven everything is build successfully and the war is assemled as it should be.
The thing is that auto suggest is not working because code is not compiling. What can I do to fix this?
I'm using eclipse, sorry
UPDATE:
I've tried all suggestions below but none worked
If you are using Eclipse, try Project > clean.. your project.
I don't know why, but Eclipse sometimes just think your project was wrong but it's not. Clean it to entirely build it again.
If it's Eclipse do
Project > Clean
then right click at the parent-most project and do
Maven > Update Project Configuration
Maven > Update Dependencies
I guess you have m2eclipse installed, already.
Use a maven plugin in your IDE
plugin for eclipse
plugin for netbeans
Most likely you have to include external libraries/dependencies in your IDE. It seems when you're building with maven, those dependencies are solved for you.
Some IDE's support Maven projects, try to see if yours does.
You haven't specified what IDE you're using or what the errors are, which makes it pretty hard to give you advice. My guess is that you haven't configured your project (or whatever the equivalent IDE concept is) to tell it the libraries you're using... whereas the Maven build file already contains that information.
EDIT: Okay, so it can't find the right libraries. Options:
Use a Maven plugin and let it manage the project
Edit the project's build path and explicitly tell it which jar files to use.