There are No resources that can be added or removed from the server - eclipse

I have created a Dynamic web project, but I am not able to deploy it into
Apache Tomcat Server 6.0. I am getting this error when I try to deploy my project:
There are No resources that can be added or removed from the server.

For this you need to update your Project Facets setting.
Project (right click) -> Properties -> Project Facets from left
navigation.
If it is not open...click on the link, Check the Dynamic Web Module Check Box and select the respective version (Probably 2.4). Click on Apply Button and then Click on OK.

Check whether your Java version is compatible with the project. Right click the project>>Properties>>Project Facets>>Java check the version is compatible with your project.

The issue is incompatible web application version with the targeted server. So project facets needs to be changed. In most of the cases the "Dynamic Web Module" property. This should be the value of the servlet-api version supported by the server.
In my case,
I tried changing the web_app value in web.xml. It did not worked.
I tried changing the project facet by right clicking on project properties(as mentioned above), did not work.
What worked is:
Changing "version" value as in jst.web to right version from
org.eclipse.wst.common.project.facet.core.xml file. This file is present in the .setting folder under your project root directory.
You may also look at this

if your project maven based, you can also try updating your project maven config by selecting project. Right click project> Maven>Update Project option. it will update your project config.

I used mvn eclipse:eclipse -Dwtpversion=2.0 in command line in the folder where I had my pom.xml. Then I refreshed the project in eclipse IDE. After that I was able to add my project.

I didn't find the Dynamic Web Module option when I clicked on the link, then I have installed Maven(Java EE) Integration for Eclipse WTP from the Eclipse Marketplace.Then, the above steps worked.

I encountered this error even though the Project Facets were set appropriately. The problem was that the "Runtime Environment" property was not set on the server:
It simply needed to be set to the appropriate Runtime:

The only thing that worked for me was creating a
.java-version
file with "oracle64-1.8.0.112" as the only entry ( use something that is 1.6+ )
Make sure you have dynamic web module facet turned on.

Right click on the project, select properties and then select "Targeted Runtimes". Check if Tomcat is selected here.

The issue is it is missing Dynamic Web Module facet definition.
Run the following at command line
mvn eclipse:eclipse -Dwtpversion=2.0
After build is success, refresh the project and you will be add the web project to server.

First check Project Facets setting as most replies had been answered.
Then check the Runtime Server is also aligned with the appropriate JRE.
In my case, I updated project JRE System Library and JDK compiler to 1.8,
but original Tomcat server is setting up on JRE 1.7,after upgraded to 1.8,the issue is resolved.

Related

Rename JEE project

I'm working on a JavaEE project, I already have the skeleton of an old project. All i have done is rename the project, packages and change the name in the project file (.project). But now when i'm trying to run, it returns error in the browser "The requested resource is not available". I've checked the web.xml and added a new jsp in vain it doesn't work. In the browser's address, it gives me the old name of the project(http://localhost:8061/smsgate/). I've tried a lot to fix the problem. what can i do? Is there any other file that i have to update and write in the new name? Please give me your ideas (knowing that i have to use that old project)
Do Project -> Clean in your workspace by selecting your current project. Also if using maven then right click your project and do maven -> clean.
Manually go to your target directory of your ear module and shift-delete everything inside your target and then rebuild your project to form new ear.
if you have configured the web.xml properly then strike your app url. Also ctrl+shift+delete your browser history and then check.
Why not create a new project using a maven archetype, just type in the console:
mvn archetype:generate
It will show you a list of available archetypes from the web, just choose one of them, for JEE6/JEE7 you could choose among:
1019: remote -> org.codehaus.mojo.archetypes:webapp-javaee6 (Archetype for a web application using Java EE 6.)
1020: remote -> org.codehaus.mojo.archetypes:webapp-javaee7 (Archetype for a web application using Java EE 7.)
If you agree with me, just type:
1019 or 1020 according to your needs and answer the questions like:
projectId:your-project-name
groupdId:com.yourdomain.reverse
version:1.0

Unable to deploy my spring web project to eclipse internal tomcat server.(java.lang.ClassNotFoundException on tomcat startup)

when I use an external tomcat everything is just fine. but I need to deploy my project on internal eclipse tomcat server in order to be able to use DCEVM class hot swapping.
When I try to start tomcat server from within eclipse it says it is not able to find one of my service classes I mentioned in my spring security configuration file as a bean.
I also tried to add the project to tomcat class path but it did not solve my problem.
UPDATE
I found out the problem is because when I deploy my web project to eclipse tomcat server, no .class is copied to:
C:\Users\Meysam\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\villapweb\WEB-INF\classes
in fact, this folder contains my src/java/main package structure but no .class is copied in it.
lib folder is fine though (e.g. all dependencies of maven and other stuff copies in the path it is supposed to)
I think there might be something wrong with m2e-wtp plugin. I dont know what!
I am using eclipse 4.3 BTW.
SOLVED
I Solved this issue following these steps:
right click on project in eclipse > properties > project facets
in the right panel select runtimes and select your target server. Apply and ok.
in the server modules list right click on project module and click clean module work directory
right click on the server itself and you can clean both server and tomcat work directory one after another
if that didn't work, try project > clean and also toggle "build automatically" option under project menu item.
Thats it. tomcat now copies all .class files to the target server and you see no ClassNotFound exception as tomcat starts up.
[Copied to answer section]
I Solved this issue following these steps:
right click on project in eclipse > properties > project facets
in the right panel select runtimes and select your target server. Apply
and ok.
in the server modules list
right click on project module and
click clean module work directory right click on the server itself
and you can clean both server and tomcat work directory one after
another
if that didn't work, try project > clean and also toggle
"build automatically" option under project
Thats it. tomcat now copies all .class files to the target server and you see no ClassNotFound exception as tomcat starts up.
I've followed the steps on the answer but It still wouldn't work for me, so, besides doing these steps once, I've found that doing a refresh on the target after doing a clean install automatically triggers the "Republish" status on the server, so when the server is executed all changes on the compiled classes (new classes and changes to existing ones) are then copied to wtpwebapps when the server is started.
I had almost the same problem - one of my projects did not make it to the deployment area (its jar). What i did is 1) remove the appliction from tomcat 2) clean tomcat work directory 3) most important: project - clean - all. Then i added the application again and... problem solved
I had the same problem in Web Dynamic project converted to Maven project.
I found error in properties->Deployment Assembly->right panel.
There was source=src folder and deploy path=WEB-INF/classes. Classes couldn't be found by Eclipse.
Changed to source=target/classes.

Tomcat: Generated context-path is different for cloned application in Eclipse Juno

I've been trying to merge few different projects in to a single one in eclipse. In this attempt I've tried this following steps which causes the context path to be generated differently(incorrectly?).
Core-Problem:
Copied a dynamic web project (Maven) in eclipse and paste as a new project
(Cloned-duplicate)
Add the project to embedded Tomcat server in
eclipse.
Go to Tomcat Server project in eclipse and open server.xml
Generated < Context > tag contains the following
<Context docBase="DuplicateApp" path="App" reloadable="true" source="org.eclipse.jst.jee.server:DuplicateApp"/>
I would've expected both 'path' and 'docBase' to point to DuplicateApp, which is the name of the cloned app, however it is appearing incorrect. Is this even expected behavior?
Quite a bit of searching confirms my learning that both 'path & 'docbase' should point to the name of the web application/war file name.
Additional Information:
Eclipse Juno Java EE version installed
M2E plugin installed in Eclipse
Tomcat version 7
pom.xml did not override war name - cross checked.
After desperately refreshing to find no answer to my post, found answer to my own question after few additional hours of slogging!
There seems to be a property named 'Web Project Settings' which can be accessed via Project > properties > 'Web Project Settings' where context root can be changed. Not sure how this get populated or where it is retained just as yet. But atleast this solves my problem!

GWT - Refreshing changes with 'Development Mode' with Maven

If I use GWT's Development Mode with Eclipse, changes that I make in the IDE are immediately reflected in my browser upon refresh. However, I can't seem to get the same result when using the maven plugin to build. Is this possible?
Here's what I've tried:
Running gwt:run, making a change and saving it in Eclipse, refreshing the browser.
Same as above but clicked the 'restart server' button on the GWT Development Mode console.
Telling Eclipse that my project is a GWT project and configuring a Web Application, but it fails to list any Entry Point Modules for me to choose from.
'webAppCreator -templates maven com.xx.WebApp' - creates just a pom, no project (?).
The only option seems to be: stop the console, gwt:compile, gwt:run. This cycle takes minutes each time..
Any ideas on how to achieve this, or if it's even possible? Not being able to do this is really a show stopper for us adopting GWT, since we can't scrap maven.
TIA, Roy
The real answer to this question came from Thomas Broyer's comment, but I wanted to spell out all of the steps that I took for future reference:
With Maven:
Create the project using the gwt maven plugin archetype.
Move the xxx.gwt.xml file from the 'resources' tree to the 'java' tree, as recommended by Thomas.
Run 'mvn clean install' to ensure that all's well, and to generate the async classes.
To get around this issue, add this to your pom. When you change your maven dependencies you'll need to run a maven compile to get them to take in Eclipse.
With Eclipse:
Import the project into Eclipse using 'Import Existing Maven Project'
Right-click on target -> generated-sources -> gwt, and select Build Path -> Add to Build Path.
In project properties -> Google -> Web Toolkit, 'Use Google Web Toolkit' is checked.
On the same page, add your entry point modules.
In project properties -> Google -> Web Application, ensure that 'This project has a WAR directory' is checked, and the dir points to 'src/main/webapp'
Right-click on the project, select Run As -> Web Application
Ready to go!

How to get peer project source in eclipse and maven

creating a parent project with only a pom.xml, and lots of sub projects such as:
my-web
my-core
my-backoffice
etc. is easy, and the sonotype eclipse plugin does most of the work.
However, getting one project to know about the source in the other project seems to be hard. E.g. when you are debugging the my-web project, and step into my-core, eclipse doesnt know where to get the source.
Looking in the Java Build Path in eclipse, the maven plugin has added my-core as a folder under "Web App Libraries". I.e. its not using the my-core-0.0.1.SNAPSHOT.jar or similar, its using the raw java files. Great!
But how to tell maven to tell eclipse to look for the source in the same place?
Im not really sure where to start. Im guessing its possible to get maven to put the source in a special jar using the maven-soure-plugin, but this will usually be out of sync with the actual java files which the web project seems to be using directly.
A quick and dirty solution is to manually Edit the Java Build Path for each project, and add my-core and other dependant projects in the "Projects" tab. Is this best practice? Any other suggestions?
A quick and dirty solution is to
manually Edit the Java Build Path for
each project, and add my-core and
other dependant projects in the
"Projects" tab.
If this doesn't happen automatically you have a configuration problem.
My Guess would be that you have a version mismatch between the pom dependencies and the actual project versions. Or your projects have an unusual name template (m2eclipse resolves projects by their artifactId AFAIK)
Either way, what always helps is in your Debug configuration (Run > Debug Configurations ...) select the Source tab and just Add... the selected projects.