Wildfly in Eclipse is adding the Maven SNAPSHOT to the web context - eclipse

I'm having a new problem when we moved to a Wildfly 8.x server in eclipse.
My project is called PayloadSvc. The first part of the pom.xml looks like this:
<modelVersion>4.0.0</modelVersion>
<groupId>PayloadSvc</groupId>
<artifactId>PayloadSvc</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
Later in the pom I have this:
<build>
<finalName>PayloadSvc</finalName>
In eclipse I also have my context root in the Web Project Settings set to PayloadSvc
However, when it deploys into Wildfly it deploys this way:
Registered web context: /PayloadSvc-0.0.1-SNAPSHOT
I can't seem to get it to remove the "-0.0.1-SNAPSHOT" part of the web context.
Oddly enough, other projects in the same workplace work correctly even with the same pom data (with appropriate context, groupId, artifact Id, and the same version attribute of course).
I'm using the STS version of Eclipse Neon.
Thank you for any advice you may have.

Just had the same problem solved.
If you don't have it already, create a WEB-INF\jboss-web.xml file, with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<context-root>PayloadSvc</context-root>
</jboss-web>
Republish the resource and you're done.
Not sure why the file is not created automatically though.

Edit the file \[root-of-your-project]\.settings\org.eclipse.wst.common.component, changing the deploy-name attribute and context-root value.
Show the server tab by: Window > Show View > Server
Right click on your server then Add and Remove.... Remove all projects from server.
Right click on your server and clean.
Just to be sure, go to the directory where WildFly is installed and delete the content of the directory [wildfly-path]\[standalone-path]\deployments, if it exits.
Add again the projects into your server and run.

Have you tried adding the <name>PayloadSvc</name> element in the root of the pom (same spot as your group,artifact,version elements)?
If that doesn't help, what does the artifact look like when you build it with mvn install? Does it include the version number in the war filename?

For Eclipse Neon:
1 Did a Eclipse Neon 'Check for updates' and updated it.
2 I editted file org.eclipse.wst.common.component adding a blank line and saved (check if deploy-name is suffixed with SNAPSHOT).
3 After that the suffix '0.0.1-SNAPSHOT' disappear from the war name when adding it to Wildfly server.

Related

Specify context-path for spring-boot WAR

I have a spring boot web application that deploys as a WAR. Right now when I deploy it to my Tomcat 7 server, it uses the name of the war file as the context, such as /myartifactid-1.5.4.SNAPSHOT/. I want to specify the context-path, but
server.contextPath=/mywebapp
seems to only work for embedded tomcat. I've added a META-INF/context.xml with only this
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="false" path="/mywebapp" />
but that hasn't had any effect.
EDIT: This is NOT a spring-boot issue, but instead related to how NetBeans behaves differently from Eclipse. NetBeans apparently recognizes the context path parameter in context.xml, but Eclipse doesn't. In Eclipse you have to modify the Web Projects Settings to set the context path.
Changing Tomcat context path of web project in Eclipse
Since you are packaging your Spring Boot application as a war (as opposed to a jar with an embedded tomcat container) the context path will be the name of the war.
For example if you name your packaged application mywebapp.war and you place it under Tomcat's webapps, it will be available under /mywebapp
when the war does not have the same name with the project, the application will not be accessible via the context path on the tomcat,
to fix this you need to go to the POM.xml change the name of package to match the context path name
server.servlet.context-path=/virtualcard
<groupId>com.test.csc.virtualcard</groupId>
<artifactId>virtualcard</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>virtualcard</name>
then the war will be: virtualcard.war

GWT Maven - webapp files getting deleted when running in dev mode

As specified in the gwt maven mojo plugin documentation, I have selected src/main/webapp folder as my war directory in eclipse->project properties->Google->Web application. Then, when I tried to run my gwt project in dev mode from eclipse, the html files in webapp folder was getting deleted. After some investigation, I was able to fix this by modifiying -war value in run configuration to the target folder of the project. But the problem I am facing now is that, after running the project in dev mode, I have to manually copy the html files to the target directory each time for the dev mode to work. Can anyone please help me to identify what I am missing here. How can I set the webapp folder as war directory and prevent the files from getting deleted? Please help.
The correct way to configure the Google Plugin for Eclipse (using M2Eclipse) and run DevMode is explained in the FAQ: http://web.archive.org/web/20130619170526/https://developers.google.com/eclipse/docs/faq#gwt_with_maven
May be you have to set the copyWebapp parameter to true?
<configuration>
<style>PRETTY</style>
<strict>true</strict>
<runTarget>index.html</runTarget>
...
<copyWebapp>true</copyWebapp>
</configuration>
Our .pom uses this:
<properties>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<gwt.war.directory>${project.build.directory}/war</gwt.war.directory>
</properties>
In the Arguments tab of the debug configuration we use:
-remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -startupUrl appname.jsp -logLevel INFO -port 8888 -codeServerPort 9997 -war
"${workspace_loc:appname/target/war}" com.yourcompany.app
Seems to work without the problem you are having.
I am not sure if this is a problem faced only by me, but even after following the steps specified in the maven plugin configuration the issue had occurred to me randomly. But nowadays its not happening and this is what I did differently.
Use the gwt only in eclipse java perspective, not in j2ee perspective.
In eclipse->project properties->Google->Web application, check the Launch and deploy from this directory option.
I was caught out by this too. If you put your static files for the webapp into the "src/main/webapp" folder, they will be copied over to the target folder if the tickbox in Settings->Web Application is unchecked (as it would be by default if it's an M2eclipse project).
I set my target folder to be the "war" folder on the project and ignored it in version control.

RAD not adding an EAR project to a WAS instance

In my RAD workspace, I have an EAR project. Now I have a WAS 6.1 instance which i created from inside RAD. When I right click the WAS 6.1 instance and do 'Add Remove projects' and select the EAR, I get error:
Cannot add an EAR project to the server unless it contains a Web, EJB, or Connector module.
Now this is not true because in my EAR project there is META-INF/application.xml and it has the contents:
<?xml version="1.0" encoding="UTF-8"?>
<application id="Application_ID" version="1.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
<display-name>
someEAR</display-name>
<module id="EjbModule_1291759813449">
<ejb>someEJB.jar</ejb>
</module>
<module>
<web>
<web-uri>someWeb.war</web-uri>
<context-root>someWeb</context-root>
</web>
</module>
</application>
So clearly it has a <web> and <ejb> module. Why is RAD complaining?
A couple of potential solutions:
Uninstall your application, stop the server, reinstall your application, start the server.
right click on the EAR and check "Deployment Assembly" and make sure your modules are being exported. if so, it is a good idea to remove them and re add them.
Check "Project References" and make sure they are checked.
To add the project back to the server,
Right click on your jar project and go to properties, click Java EE module dependencies. Select the project jar checkboxes under Available Java EE modules.
This will get the project back.
Now right click on your was server and try add/remove project. It will appear in the left panel for selection.
In my case the solution was:
1-Make sure the web project had already run Maven so as to have the .war inside Target.
2-Right click on ear project, go to Properties > Deployment Assembly.
3-Click “Add” button, choose Archives from Workspaces. Click Add, and choose your war.
4-The War now is at Deployment Assembly list.
5-Start server.
In my case I went to "Project Facets" first uncheck Dynamic web module and applied the changes. Again I selected the Dynamic web module. This helped to replace the corrupted war file and resolved the issue.

Eclipse WTP - specify deploy folder for the project

I'm using Eclipse WTP plugin for my java web project. I am deploying project via Servers view. Now, I'd like to know whether it is possible to specify name of the deploy folder, by default all files are being placed into a folder that has same name as project has. Is this configurable? Can this be done without modifying project name?
For instance: I have project name in Eclipse MyCompanyProject and when it is being deployed, I get folder with binaries and other resources in webapps\MyCompanyProject. But I'd like to have it deployed to webapps\projectA
Okay, file org.eclipse.wst.common.component should be modified in order to achieve that.
Lines:
<wb-module deploy-name="projectA">
...
<property name="context-root" value="projectA"/>
This change will be reflected inside server.xml:
<Context docBase="MyCompanyProject" path="/projectA" reloadable="true"/>
Resolved...

Eclipse - How can I change a 'Project Facet' from Tomcat 6 to Tomcat 5.5?

(Eclipse 3.4, Ganymede)
I have an existing Dynamic Web Application project in Eclipse. When I created the project, I specified 'Default configuration for Apache Tomcat v6' under the 'Configuration' drop down.
It's a month or 2 down the line, and I would now like to change the configuration to Tomcat 'v5.5'. (This will be the version of Tomcat on the production server.)
I have tried the following steps (without success):
I selected Targeted Runtimes under the Project Properties
The Tomcat v5.5 option was disabled and The UI displayed this message:
If the runtime you want to select is not displayed or is disabled you may need to uninstall one or more of the currently installed project facets.
I then clicked on the Uninstall Facets... link.
Under the Runtimes tab, only Tomcat 6 displayed.
For Dynamic Web Module, I selected version 2.4 in place of 2.5.
Under the Runtimes tab, Tomcat 5.5 now displayed.
However, the UI now displayed this message:
Cannot change version of project facet Dynamic Web Module to 2.4.
The Finish button was disabled - so I reached a dead-end.
I CAN successfully create a NEW Project with a Tomcat v5.5 configuration. For some reason, though, it will not let me downgrade' an existing Project.
As a work-around, I created a new Project and copied the source files from the old Project. Nonetheless, the work-around was fairly painful and somewhat clumsy.
Can anyone explain how I can 'downgrade' the Project configuration from 'Tomcat 6' to 'Tomcat 5'? Or perhaps shed some light on why this happened?
Thanks
Pete
This is kind of hacking eclipse and you can get into trouble doing this but this should work:
Open the navigator view and find that there is a .settings folder under your project expand it and then open the file: org.eclipse.wst.common.project.facet.core.xml you should see a line that says:
<installed facet="jst.web" version="2.5"/>
Change that to 2.4 and save.
Just make sure that your project isn't using anything specific for 2.5 and you should be good.
Also check your web.xml has the correct configuration:
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
This may be old but I tried and found the following in eclipse Galilio.
Open the navigator view and find that there is a .settings folder under your project expand it and then open the file: org.eclipse.wst.common.project.facet.core.Delete the content of this file and right click on the project and click on properties. Go to Project Facats in the popup window there you can click on runtime tabs and convert your project to the new facet you want.
if you are using Maven, then shutdown eclipse, then type >mvn eclipse:eclipse -Dwtpversion=2.0, and restart the eclipse.
Sorry it seems I can't post a comment without enough Rep so...
I think it's too difficult for eclipse to degrade safely to a lower standard because it can't really know if you've used something from the newer web standard. So if it just allows you do to that it could cause your program to fail on an older version.
You can always be backward compatible but not forwards compatible.
You can try to uncheck the facet, apply, change the value of the facet and check. It works for me in Eclipse Helios SR1.
So the main difference is that I do it with 'Dynamic Web Module'.
I hope it works for you too.
I saw the same thing, then I changed the web-app version value in the web.xml. Doing so could fix this for you.
If you are using maven you can generated the eclipse settings using the maven eclipse plugin.
For the jst.web version the Maven eclipse pluging takes into account the dependencies of the project. If you have a servlet api dependency defined :
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>servlet-api</artifactId>
<version>6.0.32</version>
</dependency>
You jst.web parameter will be 6.0
<faceted-project>
...
<installed facet="jst.web" version="6.0"/>
...
</faceted-project>