deploy netbeans Java EE web project - deployment

Hi
I am new to deploying web projects. I want to deploy my Java EE Netbeans project on a different remote server. I just kept the .war file in the tomcat webapp folder and it worked fine. But I could not see the images and CSS effects in the webpage. How do I bundle my images, CSS files, scripts etc. in the .war file?

If you have a Netbeans web application project there is a folder WebPages under the project node. You can for example create a folder resources (right click on WebPages --> new folder) and put all your images, css files and scripts in it.
Then they are automatically included in the war.
(The WebPages folder in the project window is mapped to the project-name/web on file system.)

Have a look into this document: http://www.examulator.com/moodle/mod/resource/view.php?id=455 and see how it works instead of relying only on the IDE provided features, then use the IDE (like Netbeans) build the project and see the war file which IDE created for you.

Related

Eclipse WebLogic exploded deployment republish only JSP on file change

I'm using Eclipse with WebLogic extensions.
I'm developing my J2EE application as Exploded. Each time I modify a JSP file content it is copied automatically inside the exploded deployment folder.
Unfortunately this scenario works only for JSP files, any other project file, like CSS and JS, must be copied by hand.
Is it possible to tell Eclipse to auto deploy other file types too?
Thanks!

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

How to make war file of gwt project in eclipse?

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.

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.