I am running Eclipse Galileo with Tomcat 6.0.18.
Currently, I have a working application with the m2Eclipse plugin installed. It deploys to Tomcat and I am able to test my application.
I am wanting to switch over to just using the Maven Eclipse plugin. The problem is that Tomcat is refusing to deploy my application.
I have converted my web project to a dynamic web module and set all my build paths as close to my previous m2Eclipse workspace as possible and still no success. When I hit the url, I just get a blank page.
What I did narrow down was that in my m2Eclipse workspace, when Tomcat publishes the web project, the context.xml file in [TOMCAT_HOME]\conf\Catalina\localhost has the docBase set to the "Web Content" directory. While my Maven Eclipse workspace, the context.xml that Tomcat publishes to have the docBase set to "Java Source" directory.
What do I need to do to have my "Maven Eclipse" workspace integrated with Tomcat work successfully like my m2Eclipse workspace?
Seams you don't have proper configuration of maven-eclipse-plugin if you converted project manually to dynamic web module.
According to maven-eclipse-plugin documentation you need to specify additional configuration in your pom (or by passing -D parameters) for WTP project. Key is <wtpversion> tag.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<projectNameTemplate>[artifactId]-[version]</projectNameTemplate>
<wtpmanifest>true</wtpmanifest>
<wtpapplicationxml>true</wtpapplicationxml>
<wtpversion>2.0</wtpversion>
<manifest>${basedir}/src/main/resources/META-INF/MANIFEST.MF</manifest>
</configuration>
</plugin>
Look into using the Tomcat plugin for Eclipse.
I went the other way, taking an existing Eclipse Dynamic Web project and converting it to a Maven project. To get them both to work will likely involve manually editing the project files.
First choose to "Customize View" from the little arrow in your "Project Explorer" view and uncheck ".* resources" from the list of filters. This will allow you to view the contents of the .settings directory.
Open org.eclipse.wst.common.component. It's an XML file that tells the WTP project where the webapp files are located.
To make it work with Maven, you'll need it to look something like:
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="(project name)">
<wb-resource deploy-path="/" source-path="/src/main/webapp"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
<property name="context-root" value="(project URL)"/>
<property name="java-output-path"/>
</wb-module>
</project-modules>
There are two "variables" in there that you'll probably want to leave alone - the name of the project (as it appears in the "Servers" view) and the name of the URL where the project is deployed on Tomcat.
I think that's the only change really needed to get WTP to play nice with Maven, since that tells it where to find the various files it needs to deploy to Tomcat.
Related
We have a number of war projects in eclipse. When they are imported as maven projects, the annotation processing are automatically enabled.
Tried disabling the annotation processing by adding <proc>none</proc> to the maven-compiler-plugin. It doesn't help.
If preferences -> Maven -> Enable Java EE configuration is disabled, the annotation processing is NOT enabled (but then the modules can't be deployed). As soon as that option is checked, the maven update starts and the annotation processing is re-enabled.
All the modules affected are identified as J2EEModuleVirtualComponent show the same maven debug information:
YYY is a J2EEModuleVirtualComponent
Underlying resources for the root folder are :
-/YYY/src/main/java/
-/YYY/src/main/resources/
-/YYY/.apt_generated/
Is there a way to enable the Java EE configuration while disabling the annotation processing?
It turned out the annotations were being enabled by two plugins from the GWT eclipse plugin. To disable them I had to do the following:
Make a security copy of C:\Users\.p2\pool\artifacts.xml and remove the following entries (the versions might change depending on your GWT plugin). Depending on your installation the .p2 folder might be in the eclipse instead.
<artifact classifier='osgi.bundle' id='com.ibm.etools.javaee.cdi.ext.ui' version='1.2.300.v20171018_0400'>
<properties size='1'>
<property name='download.size' value='161017'/>
</properties>
</artifact>
<artifact classifier='osgi.bundle' id='com.ibm.etools.javaee.cdi.ext.ui' version='1.2.0.v20150617_2241'>
<properties size='1'>
<property name='download.size' value='158451'/>
</properties>
</artifact>
Same for the entries in all the versions of C:\Users\.p2\pool\features\com.ibm.ws.st.jee.tools.feature: Backup the feature.xml and remove the "com.ibm.etools.javaee.cdi.ext.ui" and "com.ibm.etools.javaee.cdi.ext.ui" entries.
Restart your eclipse and verify in help->about eclipse->Installation details-> Plug-ins that "com.ibm.etools.javaee.cdi.ext.ui" and "com.ibm.etools.javaee.cdi.ext.ui" are no longer listed.
If you want to clean your work space, remove all the imported maven projects (not the parent ones) and execute the attached script from the root of the work space. This will delete all the generated files, and leave the projects as if they had been just imported from the repository. After that you can re-import the existing maven projects, and verify that no apt_generated folders are created or added to the paths, and annotation processing are disabled in all the the projects.
To verify automatically that no annotation processing has been enable, search your work space for "org.eclipse.jdt.apt.core.prefs" files and ".apt_generated" folders. There should be none.
I've been looking for this all-over the internet and somehow I can't find a easy way to do it.
What I need is really simple and I believe that many of you probably do it already:
- I develop Java Web Apps in Eclipse and so does my team;
- we have a tomcat7 server running on a Ubuntu machine which works as a centralized Dev environment;
- I would like to click a deploy button and send the new data to the server and deploy it (reload it), instead of exporting a war every time and manually upload it to server.
Up till now seems like the only way to do it is with Maven plugin for eclipse, which uses the manager/HTML interface of tomcat.
Problem: I just can't get it to work. But somehow I can't find a simple walk through that explains how to do it. I'm not too experienced with eclipse or Linux but the configuration of local tomcat servers seems pretty straightforward. I don't understand why is so hard to install a remote one.
Could you please help me out by explaining in detail how to do it? Thank you in advance for you patience.
Yes, you can use Tomcat7 Maven Plugin. Here is the steps:
1) Install Maven Integration for Eclipse (m2eclipse) to your eclipse from Eclipse Marketplace etc.
1.1) Navigate to Help -> Eclipse Marketplace and search "Maven Integration for Eclipse".
2) From eclipse, create a maven project.
2.1) Navigate to File -> New -> Project... -> Maven -> Maven Project.
2.2) Click Next (Leave all fields with default).
2.3) Select "maven-archetype-webapp" and click Next.
2.4) Enter arbitrary value on Group Id and Artifact Id. (e.g. "org.myorg" for Groupd Id and "myapp" for Artifact Id) and click Finish. (You will see pom.xml in your project's root.)
3) Edit pom.xml like this: (Replace yourhost below with your hostname or ip address.)
<project ...>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<url>http://yourhost:8080/manager/text</url>
</configuration>
</plugin>
</plugins>
</build>
</project>
4) Add following lines to your CATALINA_BASE/conf/tomcat-users.xml and restart your tomcat.
<tomcat-users>
...
<role rolename="manager-script"/>
<user username="admin" password="" roles="manager-script"/>
</tomcat-users>
5) From eclipse, run tomcat7:redeploy goal.
5.1) Right click your project and navigate to Run As -> "Maven build...".
5.2) Enter tomcat7:redeploy to Goals and click Run.
6) Once you create the run configuration setting above, you can run tomcat7:redeploy goal from Run -> Run Configurations.
Please refer to the following documents for details:
http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html#Configuring_Manager_Application_Access
http://tomcat.apache.org/maven-plugin-2.1/index.html
http://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/plugin-info.html
If you use another user instead of admin with empty password (which is plug-in's default), you need to create %USERPROFILE%.m2\settings.xml and edit pom.xml like below:
%USERPROFILE%.m2\settings.xml:
<settings>
<servers>
<server>
<id>tomcat7</id>
<username>tomcat</username>
<password>tomcat</password>
</server>
</servers>
</settings>
%USERPROFILE% is your home folder. (e.g. C:\Users\yourusername)
pom.xml:
<configuration>
<server>tomcat7</server>
<url>http://localhost:8080/manager/text</url>
</configuration>
Add server tag.
Is it possible to define a different location for the webapp folder than the standard one ("/src/main/webapp/") in pom.xml? I know that you can define your web folder with
<wb-resource deploy-path="/" source-path="/webapp"/>
in a file called "org.eclipse.wst.common.component".
The problem is when I click Maven -> Update Project, this line is overwritten with the standard
<wb-resource deploy-path="/" source-path="/src/main/webapp"/>
And then I have problems testing my project with Tomcat7 within Eclipse.
I'm very thankful for every hint.
Answers in How to configure custom maven project structure are sufficient for a purely Maven build, i.e. from commandline. When import the project into Eclipse (via m2e), you need tell m2e a little bit more so that it can create and maintain the project structure properly within Eclipse.
Actually, from Eclipse's perspective, it doesn't really care about how your project folder structure looks like, as long as the webapp folder is declared as a source folder or inside a source folder, however, by modifying .classpath doesn't make much sense as it's a auto-generated file and changed quite often.
It is highly recommended to obey the convention if you are able to, if not, using the following configuration for your customization:
<build>
<resources>
<resource>
<directory>${basedir}/webapp</directory>
</resource>
... ...
</resources>
... ...
</build>
I am not able to run maven java web application project to the configured tomcat within eclipse ide.
Initially I could right click on the project and run it on tomcat server but ever since I shared the project to a repository I am not able to do that.
I disconnected the project form the repository and now I I dont even see the Run as -> Run on Server option inside eclipse ide.
I am using m2e plugin version .0.12.1 and eclipse helios and tomcat 6.
Could someone help me understand what am I missing here?
Thanks.
PROBLEM
When you try to run the project on the server using "Run on Server" (SA+X+R) option, eclipse returns the following message:
The selection did not contain any resources that can run on a server.
SOLUTION
On the navigation panel, click over the project for pop-up menu, properties, Project Facets, check:
- Dynamic Web Module
- Java
It worked for me try this may be this is your problem
Maybe you sholud update two file in .settings folder in your web project:
.settings/.jsdtscope
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/WebContent"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
.settings/org.eclipse.wst.common.component
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="Web">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/" source-path="/src/main/WebContent" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test"/>
<property name="java-output-path" value="/Web/build/classes"/>
<property name="context-root" value="shequwang-web"/>
</wb-module>
change the path="src/main/WebContent" value's as yours in the two files,then restart the IDE.After I done this,it was work well again.
I faced this issue recently in STS
After following below steps error disappeared .
Check default JRE version configured in IDE and check JRE System Library version showing in project
If versions are different ,make them same first .
Now right click on Project and select properties .
Select on Project facets and choose Dynamic Web Module
Refresh the Project.
I don't know if you solved your problem, but I had the exact same problem and could never fix it. Then I saved all my projects, deleted everything else, started Eclipse from 0 as if it had been just downloaded, re-installed plugins and started new projects copying my older projects' stuff.
Yes, it took me like an hour and it's not an expert solution but sometimes it's better to just start over.
copy your project to the other location.
go to eclipse and right click on Project and expand runAs.
click maven install.
if problem presists, remove the project and import it again.
you placed it in wrong folder remember java code in src and UI files in webapp
I use Eclipse J2EE 3.5 with Maven and tomcat. To deploy my maven webapp with WTP I added a Dynamic Web Module facet and changed the "org.eclipse.wst.common.component" file of the project because the webapp is not in a WebContent directory, here is the content of the file:
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="toto">
<wb-resource deploy-path="/" source-path="/src/main/webapp"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="context-root" value="toto"/>
<property name="java-output-path" value="/toto/target/classes"/>
</wb-module>
</project-modules>
But it never deploy the content correctly, in "workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\toto\" the directory structure is correct with WEB-INF and META-INF but empty, the jsp, html, css files are in "workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\toto\WEB-INF\classes\" with another WEB-INF and META-INF structure but with the files.
I don't understand this at all, thanks.
You shouldn't mess with facets and Eclipse configuration files manually, these files should be derived from the Maven POMs. To do so, either use the maven-eclipse-plugin to generate Eclipse specific files from your Maven project or use the m2eclipse plugin to make Eclipse able to deal with Maven projects.
Both approaches provide Maven/Eclipse integration and support the WTP (i.e. allow to get your project recognized as a dynamic project than you can Run on a Server...), but are also different. The former is very light and only generates Eclipse files, the later provides full integration, wizards, etc but is heavier. I've been an happy user of both, using one or the othe really depends of what you're looking for.
Just in case, if you decide to install m2eclipse, make sure to install the optional Maven Integration for WTP component from the the m2eclipse Extras update site..