Change the EAR deployment name in JBoss 7.x - deployment

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

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

Since 4.5.1 Eclipse update my .ear files are generated with a SNAPSHOT suffix in the filename

I have a basic Maven knowledge and I am developing in a project that uses it to build ear packages.
It was working like a charm: the ear were being created (name format: project-name.ear) and and deployed in my local wildfly directory by the eclipse IDE.
Now I had to update my Eclipse from 4.5 to 4.5.1, but the ears are being build with the name format: project-name-SNAPSHOPT-X.X.X.ear) and the JDNI name for the beans also changed.
What do I have to set so my file name and module name do not have the SNAPSHOT.X.X.X suffix?

Eclipse not generating META-INF for .ear

I'm trying to add a web project to my ear, but eclipse won't generate the /EarContent/META-INF.
What I do:
Web project test_web_project_1 already created.
New->Enterprise Application Project, create ear.
Right Click->Properties-> Deployment Assembly
Add test_web_project_1 as a project.
The test_web_project_1 war is then added to modules, but EarContent/META-INF and the corresponding application.xml is not created.
What am I doing wrong?
The Java EE 5 specification makes the deployment descriptor xml files
optional. This results in an EAR 5 project that is created without application.xml by default.
You can create one for your EAR project by Clicking once on the project parent folder in the Project Explorer pane and then right-click > Java EE Tools > Generate Deployment Descriptor Stub.
This should populate your ear content folder with a META-INF/application.xml file.
Have you tried with EAR project -> right-click -> properties -> Java EE Module Dependencies ( or 'Project References' depending on the used version of Eclipse) ?

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

Deploying a WAR in Tomcat / Eclipse

I use Tomcat 6.0 and Eclipse 3.0 under Linux and I try to deploy a WAR in Tomcat. The problem is that the server is managed by Eclipse and I have some Eclipse project deployed. I tried to modify the server.xml file then launch Tomcat via Eclipse but it doesn't work:
Could not load the Tomcat server configuration at /Servers/Tomcat v6.0 Server at localhost-config. The configuration may be corrupt or incomplete.
I tried to extract the war in the webapps directory but the webapp is still inaccessible.
What is the best practice to deploy a War ?
Tomcat behaves differently in development and production mode. When you develop your webapp in Eclipse there is no reason to deploy a WAR file of your application as a WAR during development.
Just go to the "servers" view and add a new server (you should already have done this otherwise you could not create your Dynamic Web project). In the server view you should see the server you created (Tomcat at localhost or something similar) just right click it and go to the Add and Remove section. Here you can add and remove the Dynamic Web projects you created in Eclipse. Once you added your project, all you have to do is click the green start button in the servers view and your app should be available in at localhost:8080/mycontext.
When you're done building your app just right click the project and go the the Export section in the menu. You should be able to export a WAR file. Once you have your WAR file you can upload and deploy that on a Tomcat instance that is NOT tied to Eclipse running in dev mode.
Yes, in a way, you can deploy a war in the dev mode.
I have the same problem.
I have an Eclipse webapp project, which Eclipse deploys to an instance of Tomcat run by Eclipse, so I can hot-edit the project.
This Web project needs to use resources published by another webapp that has to be run within the same instance of Tomcat. The other webapp is a completed project by someone else, so it is already in a war form.
I needed to File->Import the war as an Eclipse project and let Eclipse deploy it to the same instance of Eclipse, in order to run it in the same instance of Tomcat in which my webapp also runs.
The problem is that some wars work this way but some others do not, while all of them work perfectly fine in a stand-alone Tomcat (started by startup.sh). I can't figure out why.
This is old but is one of the first answers in google search.
You can import the war file:
A Web Archive (WAR) file is a portable, packaged Web application
that you can import into your workspace.
Before importing a WAR file,
you should first determine if the WAR file contains needed Java™ source
files. When importing a WAR file into an existing Web project, the imported
Web deployment descriptor files are either not changed or overwritten by the
ones included in the imported WAR file, based on your response to the prompt
that is provided. In either case, this action does not represent a
merging of the two sets of deployment descriptors.
To import the
Web project resources in a WAR file into your workspace, complete the following
steps:
Select File > Import
.
In the Import dialog, select WAR file and
then click Next.
Locate the WAR file that you want to import using the Browse button.
The wizard assumes you want to create a new Web project with the
same name as the WAR file. If you accept this choice, the project will be
created with the same servlet version as specified by the WAR file and in
the same location. If you want to override these settings, you can click New and
specify your new settings in the Dynamic Web Project wizard.
Click Finish to populate the Web
project.
Source: http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.wst.webtools.doc.user%2Ftopics%2Ftwimpwar.html
If all you have is a binary WAR (no source code), it cannot be installed within Eclipse. This can happen in certain scenarios outside of normal development workflows. Here's the work-around solution:
Launch another instance of Tomcat (outside Eclipse).
Modify the tomcat-users.xml file to enable admin
Go to http://localhost:8080/manager/html
Scroll down to WAR file to deploy
Click Choose File (next to Select WAR file to upload) and click Deploy.