How to make war file of gwt project in eclipse? - gwt

I am making web application using GWT toolkit in eclipse and my application is running successfully as we run from eclipse to right click on project and select Run as web project.
But when i make war file from eclipse-ide to Right-click on the project, pick Export, then WAR file so it does'nt work.It give me error "enter module name" it does'nt detect automatically module name. it happens only when i make a web application with gwt plugin otherwise in simple web dynamic application war file create easily with eclipse ide.i want to know how to make a war file in eclipse? And how to deploy my gwt application with tomcat server?
Thanks
Rahul

Take a look to this other question: create a .war file from gwt-project
In fact the real answer will depend if you want to use ANT or Maven.

WAR files are just compressed version of your built web app projects. One simple way to make them is to use jar.exe in JDK package. That's enough to run this command after building your project in eclipse to compress those files as a WAR file:
jar -cvf name_of_jar_file.war -C /path-to-app-built-dir /path-to-put-jar-file

The best approach is to use the command
Export > Export ... > Web > War file
You will have this command on the context menu (right mouse button on the project folder) if you installed the Java tools for Web Applications. Otherwise that should you first step.
It may be the case that your GWT project doesn't show on the selector of the Web Project field, the first on on the dialogue box when you execute the command above. If this is the case you must make sure you have the Dynamic Web Module facet on you project. Select the project root project navigator and then execute
Properties > Project Facets
and check Dynamic Web Module on the right panel if it not already checked.
You should make sure that the WAR directory used by GWT is the same used by the dynamic web module. If you are not sure what is your WAR directory (probably it's the one named "war") you can go to
Properties > Google > Web Application
and read the content of the field WAR directory on the right panel.
Then make sure that the WAR directory is specified in the "Web Deployment Assembly". You need to go to
Properties > Web Deployment Assembly
and check if your WAR directory is listed there. If you war directory is "war" then you should have /war on one of the rows with the deploy
path /. Otherwise
press Add...
select Folder
press Next
select your WAR folder (e.g. war)
press Finish
If you fail to make your WAR directory part of your Web Deployment Assembly them the Export > Web > WAR command will create a WAR file, but it will lack the web.xml and all the static files on the WebContent folder, such as the HTML, images, etc.

Open your project.
Navigate to war folder.
Go to File>Export>Archive File
Export your war FOLDER as zip file.
Change your file extension form .zip to .war
Keep calm and enjoy your war file.

Related

How do I convert an app engine WAR folder into a single WAR file

Currently I have created a web application and have it deployed via GAE(Google App Engine). It currently creates a WAR Folder. I need to be able to convert this project to be deployed on tomcat.
Is there anyway that I can convert the WAR folder into a single WAR file, or does anyone know how to convert an app engine project in eclipse to work with tomcat.
Any help is appreciated.
I assume you have created a project using the Google App Engine plugin for Eclipse. That project structure looks very similar to the Eclipse Dynamic Web project structure, the only difference is the war folder which is an Eclipse project is probably called WebContent.
First you need to add the Dynamic Web Module facet to the project. Right click on the project and select Properties, on the properties window choose Project Facets and check the Dynamic Web Module option, click Apply then Ok
At this stage Eclipse will change the icon of the project and create a WebContent folder, now delete this folder and tell Eclipse to use the war folder instead. Again right click on the project and select Deployment Assembly then remove the WebContent folder and add the war folder.
Finally export the project as a war file, select the project form the File menu select Export, then choose Web --> War File, enter destination file, etc...
Note: I've not tried this myself so not sure if your war will run under Tomcat or not

Export a web project

i have made a web application using java pages with eclipse.
But i have no idea how to export it for use?
I was asked to provide a make file or somehting, what other ways can i do this from eclipse?
It sounds like you need to export it as a WAR file:
Right-click the project in Eclipse
Choose Export
Choose WAR File
Just right click on the project and say export war.
There choose the appropriate server runtime for which you have created the project.
Then put that war file inside the webapps folder in case apache tomcat and restart the server.
And you have done. :)

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.

How do I deploy/import war package into Netbeans

I have looked through the help documentation in netbeans 6.5.1 but cannot find anything explicit explaining how to deploy/import a war package.
I know in Eclipse, it's as easy as right clicking in the Project Explorer >> select IMPORT >> WAR FILE.
However, I still am unable to find a solution for Netbeans.
Thankyou,
Jordan
posted elsewhere, thought i might post here too.
after some googling I've found the solution and here are the steps:
(tested using apache's ode.war in NetBeans 8.0)
unzip the war file
in the unzipped folder, you will see WEB-INF/, META-INF/, etc., create a sub-folder named web in the unzipped folder.
put everything else into web (now they will be web/WEB-INF/, web/js/, ...)
go to netbeans, new project -> java web -> web application with existing sources
pretty much just press next all the way through. voilà, it's done.
I assume you don't already have an ant or maven project for your web project? If you did, you would just import a maven project or create a Web Free-Form Application and wire it up to your ant script.
I would unzip the war file, create a new web application with existing sources in netbeans and wire everything up using the wizard.
Import the war project to eclipse.
Then import the eclipse project to netbeans
If you don't have eclipse handy, just place the war file into the webapps folder of Tomcat, go to the bin folder of Tomcat and run startup. Tomcat will automatically extract the war file for you. Now go to the webapps folder and you'll find another folder there, with the same name as your war.
I couldn't find an option to import a war directly into Netbeans (strange. Perhaps someone could create this feature and submit it as a patch to Netbeans). The folder which gets extracted into the Tomcat folder can be used as the Netbeans project. It's advisable to copy it to some other folder first. Import by File > New Project > Web application with existing sources.
Eclipse has an option to export a war and include the sources with it too, so there's a chance that the source files are in the war too.