RAD not adding an EAR project to a WAS instance - deployment

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.

Related

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

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.

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...

How do I change the context path of my Enterprise Project

So my enterprise project name TestProject, which contain TestProject-ejb and TestProject-war, so when I run the project the url is like this locahost:8080/TestProject-war. How can I change this url to localhost:8080/testproject. I use netbean 6.9, I try to right click on TestProject-war folder in netbean, and specify the context-path there under Run, but it still load locahost:8080/TestProject-war
You need to check that the context-root element for the web module in the application.xml file that's in the META-INF directory of your EAR has been correctly changed.
An example would look like this:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd"
id="Application_ID" version="6">
<display-name>TestProject</display-name>
<module>
<web>
<web-uri>TestProjectWeb.war</web-uri>
<context-root>testproject</context-root>
</web>
</module>
<module>
<ejb>TestProjectEJB.jar</ejb>
</module>
</application>
In this example the web module should be available under /testproject of the server you deploy to, so in your case http://localhost:8080/testproject.
(In case you would like to deploy to the root of your server, you can leave the context-root element empty: <context-root></context-root>.)
If you indeed see that your action in Netbeans has correctly changed this file, it may be a deployment problem like BalusC indicated. Check the location the EAR is deployed to and manually inspect whether the deployed version also has the correct value.
As Harry pointed out the default project template doesn't create an application.xml file, so you have to create it by hand at $ENTERPRISE_APP_PATH/src/conf (tested with NB 6.9.1)
Just ran into this question in the course of figuring out the same thing. Since the OP was asking about doing this in Netbeans, let me add to previous answers by describing specifically how to do this using the Netbeans IDE.
With Netbeans 8 (and possibly also with earlier versions) you can tell the IDE to create the application.xml file for you, as follows. Right-click the enterprise application project (in the OP's example this would be "TestProject"), select "New" then "Standard Deployment Descriptor...". This will create an "application.xml" file and put it in the appropriate place in your Netbeans project. Then you can easily edit this file to set the context-root element to be whatever you want.

Eclipse 3.4 GWT 1.6 project - how to reference source from other projects?

I've got a GWT 1.6 project in Eclipse 3.4 and am trying to reference source from another (non-GWT) project in my workspace. I've added the project to my build path, but I can't run the application in hosted mode. When I do, I get a "no source code is available" error.
I've done some searching and reading and have tried a few things that others have suggested (including creating a jar from the dependent project and linking to it), but frankly nothing has worked.
If you're actually doing this, could you please help me out with a simple step-by-step setup? I'd really appreciate it, thanks!
I have 2 Eclipse Projects. One is gwt project and one is not. Here's the directory structure that works for me:
workspace
-- gwt-project
-- src/main/java
-- com.gwt.GwtProjectModule
-- GwtProjectModule.gwt.xml
-- non-gwt-project
-- src/main/java
-- com.nongwt.package.that.contains.source.you.need
-- nongwt.gwt.xml
-- com.nongwt.package.that.contains.source.you.need.client
nongwt.gwt.xml tells gwt to look inside "client" package, here's what it looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd">
<module rename-to='nongwt'>
<inherits name='com.google.gwt.user.User' />
<source path="client" />
</module>
GwtProjectModule.gwt.xml can then inherit source code from nongwt. Here's the relevant line from inside GwtProjectModule.gwt.xml:
<inherits name="com.nongwt.package.that.contains.source.you.need.nongwt" />
Make sure you include non-gwt-project inside gwt-project's classpath in eclipse. It's the normal drill; right click on gwt-project, choose properties, choose "Java Build Path", click "Projects" tab, and "non-gwt-project"
Or, instead of including non-gwt-project in gwt-project's classpath as a project reference, you can also jar the contents of non-gwt--project, ensure that you include the source in the jar, and then include the jar in gwt-project's classpath.
Good Luck!
I know this post is quite old but as I spent quite a lot of time on this issue and finally found the way to do it, I thought I might share the answer :
once you've created your launch configuration, open it run>run configurations...
go to classpath tab and select user entries. add advanced>folder and select the source folder of your other module project. If as me you've separated the module conf file in a src/main/resources folder you have to add it as well.
should work.
The client-side code in your GWT project (the classes under the client package) can't reference any classes that aren't in a GWT module.
If you've got code in another project that you want to reference from client code in your GWT project, you need to:
Make sure it's all "GWT safe", which means it doesn't reference any JRE classes that aren't emulated by GWT (http://code.google.com/webtoolkit/doc/1.6/RefJreEmulation.html), or reference any classes that reference JRE classes not emulated
Make sure all referenced classes are within a GWT module. This means putting a MyOtherProject.gwt.xml file in your other project, and all the referenced classes must be under a client subpackage
Make your GWT project inherit from the other project. So add the following to your GWT project's gwt.xml module file:
<inherits name='com.yourCompany.otherProject.MyOtherProject' />
Boden: add the following to your module file
<source path=""></source>
in addition to your other sources, eg:
<source path=""></source>
<source path="com.acme.otherpackage"></source>
then the compiler won't complain.
Atleast that's how I solved it. Not sure if using path="" allows inclusion of everything, I'm assuming it's the default value when no sources are specified.
This is a fantastic solution of your problem proposed by Sven Buschbeck (must a norwegian, lol!), worked for me!
When work­ing on sev­eral large scale projects (in Eclipse), it’s con­ve­nient and of course more effi­cient to share and reuse code via com­mon libraries. While those are in an early stage they need to be changed a lot and there­fore it’s handy to link projects in instead of cre­at­ing new jars each time the library has been updated.
Unfor­tu­nately, this stan­dard approach for Java devel­op­ment in Eclipse does not work that straight for­ward as with plain old Java projects, it requires three steps in total:
Link the library project to all rel­e­vant projects (“Project
Pref­er­ences” -> “Java Build Path” -> “Projects” -> “Add…”)
Then, add the client-side code of the library (by adding it as a
mod­ule.) There­fore, edit the gwt.xml of your appli­ca­tion and add
for exam­ple
where Super­Lib is the file name of the gwt.xml file in you library
project and before that is the pack­age it lies in.
Add the code to the project by link­ing a source folder.
Unfor­tu­nately, this is required if you do not want to write an Ant
script to com­pile your appli­ca­tion. (If you pre­fer Ant check
this out) I don’t like the idea of using such a script because if
you for­get to run it each time you make changes, you will end up in
confusion—let’s go for the con­ve­nient, auto­matic way then.
Add a folder to your appli­ca­tion project; open the “advanced” sec­tion in the folder cre­ation dia­log, select “Link to alter­nate loca­tion” and pick the source folder (usu­ally “src”) of your library project. (Hint: if you work within a team using a ver­sion­ing sys­tem, you can cre­ate a vari­able for that folder and use this instead. This way, each of your col­leagues can put the library project in a dif­fer­ent folder and accom­mo­date for that by adjust­ing the vari­able :) )
Right click the folder, “Build Path” -> “Use as Source Folder”. Done.
Sur­pris­ingly, the GWT plu­gin for Eclipse does not honor the project link­ing, thus all the ref­er­ences need to be made explicit or you will end up with lots of the fol­low­ing: ClassNotFoundException.
GWT doesn't know about that other code because it is not in the client directory of your project. You need to add the source path for the other code to the .gwt.xml file. Just added it to the xml as follows
<source path="common" />
common is the directory where the extra code is for this example.
Check out the XML Element Reference section of this doc
In your gwt project, go to properties, Java build path, source, click "link source" and point to your non-gwt project source package that you wish to include.
Edit: Found a eclipse fix. Run config > Classpath > Advanced > Add folder > otherproject/src .
Reason: Eclipse adds the bin folders of exported projects. GWT needs the src folders.
Elaborating on my comment.
I am using gwt 2.8 on Eclipse Neon, Java 1.8.0_92. Referring to another project in eclipse fails to launch devmode, because it cannot find the source for referred files from the other project.
What worked:
Switched to 'ant devmode' completely. Made the following changes to build.xml:
<target name="gwtc" ...>
<java ...>
<classpath>
<pathelement location="src"/>
<pathelement location="../otherproject/src"/><!-- Added -->
...
...
<target name="devmode" ...>
<java ...>
<classpath>
<pathelement location="src"/>
<pathelement location="../otherproject/src"/><!-- Added -->
Now do a production build with 'ant' or start devmode with 'ant devmode'.
Other things I noticed
Using the method in the accepted answer, otherproject/src/foo.gwt.xml is picked up (complains if not available), and static values from classes are picked up. Nothing else is. Very weird.
I understand that the DevMode/gwtc executables pick up sources from their class path. So all that is needed is for eclipse to add referred projects to their class path. I was not able to achieve this but this seems possible. FIXED see top.

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>