Can you publish a .war directly from eclipse to a web server - java

Can you publish a .war directly from eclipse to a web server.
I know it's not a programming question, but I still think it's a relevant question.
Thanks

yes you can.
right click on the project, select export -> select web - > then war and give destination which is your deploy folder.

Yes, but it depends a lot on your project configuration. Generally you need to define the server in eclipse, and choose "Run on Server".
See this as an example of deploying on JBoss server from eclipse.
In case you are using Ant then using "deploy" target will work.

This should be pretty easy:
Import the war file into eclipse. File > Import... > Web > WAR File.
(likely only works on eclipse for java ee development)
Pick the war file, create a new project (any new name works), click finish
Add the new project to your server
Blam!

If your project is setup as a web project in Eclipse, you can choose to run it on a server (You'll have to configure the server first). This will publish the war file directly on the server from Eclipse.

This is easiest if the web server has an auto-deploy facility, with a magic directory. Then just File-> Export the WAR file into the auto-deploy folder.
If not, or if you want to be able to debug the WAR file inside Eclipse you need to have an appropriate server connector in the WTP module (which is included by default in the Java EE edition of Eclipse).
If you want to programmatically push the WAR file to a given server directly from within Eclipse, then you can e.g. use the Tomcat Ant tasks - http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html#Executing%20Manager%20Commands%20With%20Ant - or use the Cargo library to do this with many different types of servers - http://cargo.codehaus.org/

I created my own ant file, and set eclipse to use that ant file when building.
Part of that ant build file is a target that publishes to Tomcat, so I can just right click
and chose install from within eclipse.
Eclipse pic http://img408.imageshack.us/img408/6701/eclipseant.png
The basis of such an ant file is here: http://tomcat.apache.org/tomcat-6.0-doc/appdev/build.xml.txt

Yes, you do that
Start the build the application
Create the war file
A WAR (or "web archive") file is simply a packaged webapp directory. It is created using the standard Java jar tool. For example:
cd /home/alex/webapps/mywebapp
jar cf ../mywebapp.war *
- copy that war file to the following deploy directory in your server
say in Jboss its like this
"C:\Jboss405\server\default\deploy"
I hope this might be clear, else let me know any issues if you face any issues

Related

How do I export a GWT project into a executable JAR file with Eclipse?

There's a huge legacy codebase that I'm working with and I need to export it into an executable JAR file to make it easier for my co-workers to run it. It's a web application built on top of GWT, but I'm not sure what kind of application server it uses (e.g. Apache Tomcat, Eclipse tells me it uses a "built-in" server).
The run configuration shows up when I try to run the project, but not when I'm trying to export it as an executable JAR. All it does is run an application server on the machine, and allows a user to access it via 127.0.0.1:8888 in a web browser. Any ideas?
Right click on the project.
Google
GWT Compile
Zip the output (I think the war folder) into a war file which can be deployed in tomcat or jetty or something else.
(Creating an executable jar from a GWT project is not possible, you should create a war).
(Make sure to have the eclipse google plugin installed (https://developers.google.com/eclipse/docs/getting_started))

Where is my webapp deployed(From Eclipse to Tomcat 7)

I am trying to deploy my Web application(Dynamic web Project) from Eclipse to Tomcat 7( in Windows). Although the deployment works, I would like to see where exactly(the location) the web app is deployed. I did search for my webapp (named as 'Demo') in TOMCATINSTALLATION/webapps directory. But could not find my application('Demo') there.
Double-click on the Eclipse Tomcat server instance and have a look at the configuration. If you are using the option "Use workspace metadata" then the app is deployed in a path like
<workspace>/.metadata/.plugins/org.eclipse.wst.server.core/tmpX/wtpwebapps/<context>
Not sure about particular Eclipse case, but usually IDE deployment works by dynamically overriding CATALINA_BASE environment variable and setting it to your project output folder. CATALINA_BASE tells Tomcat to search for your wepapps, server settings, etc. in the specified folder.
So answer to your question is that the actual working code sits somewhere in your project's build folder: subfolder build for regular projects or target for maven ones.

Deploying to Glassfish via Eclipse

I have set up a project inside Eclipse which I can debug on a Glassfish (3.1) server using the Eclipse Glassfish plugin. So when I click 'Debug on server', it uploads fine and I am able to step through the code correctly etc.
The problem is that I don't know if the program is being compiled/build (to a new .war) each time I press debug. I have got an Ant script in the project (as I previously built the project via terminal) but I'm not sure if it is actually being used in Eclipse.
Is there any way to check if my ant script is being run?
Also, how does Glassfish know what resources to upload? Does it just look for any .war files in the project?
Not sure about this particular jar plugin but as far as I know here is how Eclipse handles web applications:
Eclipse automatically compiles all of the sources in the class path
Then it creates a configuration file which tells Application Server to look for webapp on your project folder and does some mapping based
on your project setup. This will not create a WAR file. Eclipse will
just map WEB-INF/classes to {projectDir}/bin, your classpath jars to
WEB-INF/lib and so on.
When launching the Application Server, eclipse will feed it the config file made above.
Actually answering your question: Eclipse will not use the Ant script you created, nor will it create a WAR of any kind. It will just use project configuration to properly map project folders to web application structure.
Again, this is how eclipse handles things by default, the plugin you're using might do something different. This is based on my experience and is not based on some kind of documentation.

How to deploy a web application

I have created a dynamic web projects in eclipse which includes jsp pages and servlet.The back end of this application is Mysql and i include mysql-connector-java-5.1.15-bin.jar in the lib folder. I want to deploy this web application using Tomcat server instead of running this application in eclipse using tomcat. How is it possible?. Can any one suggest any sample codes or methods to solve this problem.
copy the WAR file to Tomcats webapps folder and it should auto deploy. answer by Will Hartung is correct
you need to build a war file (or ear depending on which technologies you use), and then deploy that to your container. (in the tomcat/webapps folder i believe). Ant and Maven, two popular technologies for managing a project, both support doing this. There is plenty of documentation on the web as well
http://www.vaannila.com/ant/ant-sample-build-file-war-1.html
Step 1: Go to Windows > SHow View > Other > Select Servers
Step 2: In Server Tab . Right Click > Add New Server > Add Run time if not available and add tomcat server.
Step 3: Add your project to it and finish. If you will see in Server tab, you will see your project.
Step 4: Right click on server and choose either debug or run.
You can use ant build script by running that script from your eclipse your web application will automatically deploy into your tomcat. Another one option is to copy the war file into the tomcat's webapps folder
After export your application from Eclipse to .WAR file you can deploy, undeploy and reload it at Tomcat Web Application Manager Panel: http://localhost:8080/manager/html.

How do I build .war file in Eclipse for Glassfish server

I have web application written in java using Eclipse. It has just one servlet that does some file manipulations. How do I build war file so I can easily deploy it to my remote server.
Right-click on the project, select 'Export...', then choose web -> WAR.
You should be able to use Maven to package a WAR to deploy to your remote server. It looks a little daunting, but once you create your own WAR file you should be ok, check out:
http://maven.apache.org/plugins/maven-war-plugin/usage.html
In fact you should be able to manage deployment using the Maven Glassfish plugin here:
https://maven-glassfish-plugin.dev.java.net/
That will allow you to start,stop,deploy,undeploy etc... your web app. Example here:
https://maven-glassfish-plugin.dev.java.net/examples/complete.html
Just for the record,
The default build artifact for a
NetBeans Web project is a war
The default build artifact for a simple
Java project is a jar

Categories

Resources