6
votes

I have an EAR with a WAR that I'm deploying on GlassFish 3.1

Currently, the application runs at localhost:8080/myapp/index.jsf

I want it to run on localhost:8080/index.jsf

To accomplish this, I changed the application.xml in the EAR from contextRoot "myapp" to contextRoot="/"

When I deploy my EAR using the GlassFish admin UI, it gives me a deployment error, then when I try to browse to the admin UI, it shows me the default GlassFish home page. To recover I have to undeploy my EAR using asadmin from the command line and then do a restart-domain to restart the server.

My theory is that my application and the GlassFish admin UI are both running on root "/".

QUESTION: What is the correct way to deploy my web app in root of GlassFish 3.1? Or is this bad practice?

Thanks!

Rob

2
I think I followed your 'steps' and am not able to replicate the issue you are seeing. I am on Mac OS X 1.7.2, GF 3.1.1. Your steps work just fine for me... though they are a bit vague and I might be interpreting them incorrectly, thus I am not able to replicate the issue. More details about the 'it gives me a deployment error' might be a useful addition to this question. - vkraemer
@vkraemer - I started a new more detailed question for my problem, please visit it, any help is greatly appreciated! stackoverflow.com/questions/7878645/… - user550738

2 Answers

2
votes

Rob,

If your deploying from the command line you can use an argument to asadmin to choose the context root. This has never given me the issue you describe.

$ASADMIN deploy --contextroot "/" your.war

Your other option is to under the Virtual Server settings to choose a default web module, but personally I prefer just setting one application to /.

Kevin

2
votes

The easisest way is having a glassfish-web.xml.

This is my configuration which is located at my WEB-INF directory.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
   <context-root>/myapplication</context-root>
</glassfish-web-app>

As a note, you should consider to use war instead of ear. Glassfish 3.x which is reference implementation for the JavaEE6 has a feature to use war with EJB's. That is to say you can easily use your war with your ejb without ear bundle. It will not only decrease your application size significantly but also lets you to have a good practice in terms of class loading issues, memory footprint etc...