views:

445

answers:

3

Hello!

I am really new in this so I hopefully don't make any terrible mistake. I apologize before hand if I have.

In my project I was using tomcat and deploying WAR files. But now some bosses wants to deploy EAR files. So there we go.

I first downloaded Glassfish (don't know if it's the apropiate application server for a newbie like me), instaled it and all (I even deployed the hello.war in the autodeploy >_< ). Then prepared an EAR file.

From what I know, I just need to create an Enterprise Application Project in Eclipse and add to the module my war file. This changes the application.xml file automatically (thanks eclipse project!). So I exported it to an EAR file and uploaded it to the glassfish server.

Wonders of wonders, it doesn't work.

I also tried deploying the old WAR file in this new shiny glassfish but it goes on http-404 not found error. The glassfish seems to say that my project is not in ~/domains/domain1/docroot. By the way I am using windows and I am aware of some problems between glassfish and windows due to some updating open files or such.

So I have to questions: First, Am I doing the EAR package correctly? Second, Do I need to do some especial configuration to the glassfish server to deploy EAR and WAR files?

Thanks!

+4  A: 

If your app doesn't have EJBs, I see no value in deploying it as an EAR.

The domain and URL ought to involve the name of your domain somehow. I'm a WebLogic/JBOSS user. Is there some way to create a domain in Glassfish? If yes, do so and put your EAR in it. Maybe this will help.

duffymo
Thanks! I also think that there is no value in deploying EARs over WARs as it is a simple project. Sadly, it is not my decision.Thanks for the link! I keep on with configuration errors.
Random
+1  A: 

In my project I was using tomcat and deploying WAR files. But now some bosses wants to deploy EAR files. So there we go.

It would be interesting to get the motivations behind this decision. The general trend is to make things simpler, not more complicated (e.g. in Java EE 6, it is possible to put EJBs directly directly into a WAR).

I first downloaded Glassfish (don't know if it's the apropiate application server for a newbie like me), instaled it and all (I even deployed the hello.war in the autodeploy >_< ). Then prepared an EAR file.

I like GlassFish v3 very much, it provides a very productive environment for development. And I don't find it complicated for simple needs, the admin console make it friendly if you're not used to it.

(...) So I exported it to an EAR file and uploaded it to the glassfish server. Wonders of wonders, it doesn't work.

Check the server logs.

I also tried deploying the old WAR file in this new shiny glassfish but it goes on http-404 not found error.

What URL did you try to access? How do you see the application in the admin console.

So I have to questions: First, Am I doing the EAR package correctly?

No idea, I don't rely on IDEs for this. Show your ear structure (use tree), show your application.xml.

Do I need to do some especial configuration to the glassfish server to deploy EAR and WAR files?

There are several ways to deploy a WAR, an EAR (via the console, via the autodeploy directory, via the asadmin command line tool) and they all work out of the box.

Pascal Thivent
A: 

First of all, thanks for your responses. I will try to gather all this information up. I think the motivation for changing it to an EAR file is related to ‘corporate decisions’ and maybe someone who doesn’t want to write the context whenever he installs some application in the server, although I am no one in the company to challenge this. My bad. They are also still using Java EE 1.5. I installed Glasshfish 2.1 and the Glassfish 2.1 connector to my eclipse Galileo. I think it manages fairly easy between the eclipse conector, the console and the web administration. I eventually find someplace where I can do any action. It’s very big compared to Tomcat and I feel a somehow lost, but I try to take it slowly.

In my EAR file there is not much, the WAR file, and inside the META-INF directory there are my application.xml and manifest.mf. My application.xml reads:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" 
    id="Application_ID" version="5">
  <display-name>foo</display-name>
  <module>
    <web>
      <web-uri>FOO.war</web-uri>
      <context-root>foo</context-root>
    </web>
  </module>
</application>

I access the url via http://localhost:8080/foo the server.log shows (in Spanish, I will translate it the best I can manage), by the way I use the web service to administrate the glassfish and not the win console.

[#|2010-04-29T09:46:59.722+0200|INFO|sun-appserver2.1|javax.enterprise.system.tools.deployment|_ThreadID=26;_ThreadName=Thread-419;|deployed with moduleid = foo|#]

[#|2010-04-29T09:46:59.909+0200|SEVERE|sun-appserver2.1|org.apache.catalina.core.StandardContext|_ThreadID=27;_ThreadName=Thread-418;_RequestID=9bff8714-d870-4f30-8a7a-22dca0375b6b;|PWC1300: Error while initialization of the resources in the context /foo|#]

[#|2010-04-29T09:46:59.909+0200|SEVERE|sun-appserver2.1|org.apache.catalina.core.StandardContext|_ThreadID=27;_ThreadName=Thread-418;_RequestID=9bff8714-d870-4f30-8a7a-22dca0375b6b;|PWC4430: The document base C:\Sun\SDK\jdk\glassfish\domains\domain1\docroot\FOO does not exist or it is a directory that can’t be read|#]

[#|2010-04-29T09:46:59.925+0200|SEVERE|sun-appserver2.1|org.apache.catalina.core.StandardContext|_ThreadID=27;_ThreadName=Thread-418;_RequestID=9bff8714-d870-4f30-8a7a-22dca0375b6b;|PWC1306: The start-up of the context /foo has failed because previous errors|#]

[#|2010-04-29T09:46:59.925+0200|INFO|sun-appserver2.1|org.apache.catalina.core.StandardContext|_ThreadID=27;_ThreadName=Thread-418;|PWC1240: The WebModule[/foo] container hasn’t been started|#]

As I said, I also tried to use the WAR directly and it also didn’t work. I deployed it well (or so it says) and then it has a pretty button (in the action column) to start the web service, the server gives me http://localhost:4848/applications/webApplicationLinks.jsf?appID=FOO&amp;contextRoot=/FOO (the ear is foo while the war is FOO), and redirects me to a page telling me that if the server or the listener are not running it is possible that the links will not work. The below links are http://localhost:8080/FOO and http://localhost:8181/FOO (neither work, AKA http-404 in 8080 and blank page in 8181). By the way, this start button is not available in the ear, I don’t like that.

As for other interesting things on the server.log it doesn’t seem to say much more but I could be wrong since I am really very new in the server world.

Random