Eclipse WTP - specify deploy folder for the project - eclipse

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

Related

Why jars added to Deployment Assembly do not show up in Project Explorer (Eclipse Photon) under WebContent/WEB-INF/lib folder?

Working on a Dynamic Web Project I added a guava jar file to Deployment Assembly (Eclipse Photon) - thru Add -> Java Path Build Entry (same happens with Add -> Archives From File System)
I see that this jar gets deployed to the server and is actually inside /WEB-INF/lib of the generated and deployed WAR.
But my Project Explorer window looks like this and its WebContent/WEB-INF/lib folder is empty (I did project refresh)!
Is it normal behaviour?
In my opinion it breaks Least Astonishment Principle a lot!
It shouldn't appear there unless you actually copy the jar into the workspace (or link it, possibly).

Change the EAR deployment name in JBoss 7.x

I use Eclipse Oxygen (4.7.2). I have JBoss Tools in my eclipse. I have JBoss AS7.1.
I have a maven "ear" project. It is called abc-project. It is a maven project from the git repository. It's version in maven pom.xml is 4.7.5-SNAPSHOT. Its Artifact Id is abc-project. When I right click the server (under the Servers tab), and added the project, it is added as abc(abc-4.7.5-SNAPSHOT).
In the ear's application.xml, we have the display name as 'abc'
After I build and publish the project to JBoss, then in the standalone/deployments folder, the ear project is deployed under the folder with name abc-4.7.5-SNAPSHOT.ear
Now in one of our code, we refer as abc.ear while looking for some default labels files. The server starts fine, but it fails to access the project, because it s deployed under the folder name abc-4.7.5-SNAPSHOT.ear.
Can I change the deployment folder or the deployment name of this project?
I would like it to be deployed under the folder abc.ear
Wherever your project is, locate the .settings folder for your project. I believe this is the eclipse settings folder. Underneath this folder, there is a file called
org.eclipse.wst.common.component
Open this file, and change the name of your project in this following entry
from:
<wb-module deploy-name="abc-4.7.5-SNAPSHOT">
to:
<wb-module deploy-name="abc">
Then, remove the project from the jboss server in eclipse under the server tab/view.
Then restart eclipse clean.
Add the project again to jboss server in eclipse under the server tab/view
Publish and restart jboss from eclipse

deployment assembly using maven-eclipse-plugin

I am using maven-eclipse-plugin for working with a war project. This war project uses maven overlay method to include another war. When I deploy it using Maven, everything goes well. When I test the war locally in eclipse, it fails because the dependent war resources are available only in the target folder. To solve this, I go the deployment assembly and manually add the target folder. Is there way I could tell eclipse-maven-plugin to add the following line to org.eclipse.wst.common.component file inside the .settings folder when running the eclipse:eclipse goal.
<wb-resource deploy-path="/" source-path="/target/finalname"/>
You can embed any additional eclipse properties in your pom for mvn eclipse:eclipse.
The plugin reference has some examples for adding build commands, resources, facets, and of course also adhoc configuration.
You can probably copy paste something from there to help you.

I need Eclipse to deploy the WAR file my ANT script builds, not what it builds internally

I'm using Eclipse Helios. I have a dynamic web project going and I've set up Eclipse to use an Ant Builder to generate a WAR file. This all works fine; if I change a .java file, Eclipse automatically runs my build.xml via Ant and updates my WAR. If I deploy the WAR to an external instance of Tomcat, it works perfectly.
However, when I tell Eclipse to run my project under Tomcat, it is not using the WAR file generated by the Ant build, or using my Ant script to generate a temporary WAR.
I know this because my build.xml script includes some additional XML configuration files in WEB-INF/classes in the WAR that are not ending up in the WEB-INF/classes dir that Eclipse pushes out.
I can't seem to find anything within Eclipse that says "when you publish, use this WAR file instead of building your own".
An alternate approach would be to tell Tomcat when it is building a WAR to do so by adding a list of files, but I can't seem to find a way to do that either.
I'm also curious how Eclipse knows what to publish since it is obviously ignoring my build.xml and my previously-generated WAR file.
Eclipse deploys a web application by looking at the Web Deployment Assembly options for your project. You can see this by right-clicking the project, choosing Properties, and then click on Deployment Assembly. Eclipse usually uses an expanded directory deployment here rather than creating and deploying a WAR (this is based on the server plugin being used, but I think most of them use an expanded directory structure for speed). If you export as a WAR it will create a WAR with the same content.
There are two main choices to do what you'd like:
Modify the Web Deployment Assembly options to match exactly what you would like in the deployed app
Don't use Eclipse's deployment; add an "External Ant Builder" to the "Builders" options for your project (right-click project, choose Properties->Builders). You can then select which targets in the ant file you want to use when eclipse builds the project. One of these options can be a deployment step
I can't seem to find anything within Eclipse that says "when you publish, use this WAR file instead of building your own".
I'm an IntelliJ user, so take this with a grain of salt. But...
Right-click on the Project Explorer target/foo.war, select Mark Deployable.
Then right-click on the foo.war file again and Run As... -> Run On Server...
Choose the JBoss instance.
If you go to the Servers view, you'll now see your WAR file under the JBoss instance as /proj_root/target/foo.war
Oh Eclipse, sigh...

In eclipse, is there a way to specify a location other than the WEB-INF, for web.xml

I want to place development web.xml in another folder in eclipse.
This can be done using the Deployment Assembly properties. Right click on the web project, choose Properties, and then navigate to the Deployment Assembly panel. Remove the /WebContent entry (pointing to /) and then add another entry, of type Folder. It should be rooted where you want to keep the web.xml, and mapped to /.
This technique can be extended to make Eclipse work with arbitrary build tool source layouts.
You might want to use Apache Ant
for that purpose. You may define a "conf" directory and place all you config files there, or a resource directory for the same reason.
If haven't use ant for that purpose, I strongly recommend you to do so.
Here is a sample ant build.xml for a web app Sample Build.XML
I'll use Maven myself, but since you're just beginning, Ant would be just fine.
I am using the eclipse builder and not ant.
Actually what i did was that i defined web.xml in another folder. So now I have two web.xml, one for welogic with a lot weblogic specific stuff like filters. And i have another for development which i placed in another folder, in the web project and added this folder to the deployment descriptor for tomcat in eclipse. So now when i deploy the application, the web.xml for tomcat which is in my specified folder owerwrites the web.xml present in web-INF folder(in the deployment directory).
Looks to me a nice workaround.