Skip to main content

How to deploy existing tomcat web application in Glassfish ?

6 replies [Last post]
fishglass
Offline
Joined: 2008-07-10

I have an existing Apache-Tomcat web application (comprised of mainly servlets and some JSPs). I do not have a WAR file for the app just the context root containing a WEB-INF directory (with the Tomcat web.xml) and all the other js, html & css files.

Here's how I tried to deploy this app using Glassfish admin console.

In the "Deploy Enterprise Applications/Modules" screen :
- set Type to WAR (even though I do not have a WAR file)
- Location was local directory (current Tomcat context root /productname/webapps)
- Application Name (productname)
- Context Root was set to / (not sure abt this)
- Status was Enabled.

Is this correct ?

However when I deploy this app and try to access it, I get a HTTP 500 - Internal server error in my browser.

In my Glassfish Web admin tool, I can see (under Applications -> Web Applications) that the Sub components were recognized (from web.xml). Is the problem because my base directory (/productname/webapps) is different from /opt/glassfish/domains/domain1/config ?

Thanks in advance for your help.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Wolfram Rittmeyer

glassfish@javadesktop.org wrote:
> I have an existing web application (comprised of mainly servlets and some JSPs). I do not have a WAR file for the app just the context root containing a WEB-INF directory (with the Tomcat web.xml) and all the other js, html & css files.
>
> Here's how I tried to deploy this app using Glassfish admin console.
>
> In the "Deploy Enterprise Applications/Modules" screen :
> - set Type to WAR (even though I do not have a WAR file)
> - Location was local directory (current Tomcat context root /productname/webapps)

This looks weird. In Tomcat the directory layout is
TOMCAT_ROOT/webapps/contextName. And for the root context (/) it is
webapps/ROOT. So webapps doesn't look like the correct directory to me.

> - Application Name (productname)
> - Context Root was set to / (not sure abt this)

If your app has been in the root context (see my comment above) this is
correct. Otherwise you would have to take the name of the directoy
actually containing your web app.

> - Status was Enabled.
>
> Is this correct ?
>
> However when I deploy this app and try to access it, I get a HTTP 500 - Internal server error in my browser.
>

There should be s.th. in the server.log about this error. Can you post
the relevant parts? If no errors can be found in here, please enhance
the log level to fine for the web container.

> In my Glassfish Web admin tool, I can see (under Applications -> Web Applications) that the Sub components were recognized (from web.xml). Is the problem because my base directory (/productname/webapps) is different from /opt/glassfish/domains/domain1/config ?
>
> Thanks in advance for your help.
> [Message sent by forum member 'fishglass' (fishglass)]
>
> http://forums.java.net/jive/thread.jspa?messageID=285757
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

fishglass
Offline
Joined: 2008-07-10

I moved forward by copying ALL the jar files needed by my application under domains/domain1/autodeploy/
Is there a way to avoid this (like I said before, my CLASSPATH was set correctly) ?

Now I get :
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)

The one thing different is that before, the "root" user used to start Apache/Tomcat and here I'm starting Glassfish using a dedicated Glassfish user. I'm wondering if this is a permissions issue as the context dir owner is root.

Are there any downsides to running Glassfish as root ?

TIA.

Jason Lee

glassfish@javadesktop.org wrote:
> Are there any downsides to running Glassfish as root ?

From the hip:

File passwordFile = new File ("/etc/shadow");

would succeed, as every web app would have root access to the server.
I'm pretty sure... :P

--
Jason Lee, SCJP
Mojarra and Mojarra Scales Dev Team
https://mojarra.dev.java.net
https://scales.dev.java.net
http://blogs.steeplesoft.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

fishglass
Offline
Joined: 2008-07-10

>
> From the hip:
> File passwordFile = new File ("/etc/shadow");
>
> would succeed, as every web app would have root
> access to the server.
> I'm pretty sure... :P
>
Yikes ! You're right ! Don't wantt to do that then :)

fishglass
Offline
Joined: 2008-07-10

I rechecked the glassfish log and am seeing NoClassDefFoundError errors. How can I can make Glassfish see my application jar files ? The path is already in my CLASSPATH.

Wolfram Rittmeyer

glassfish@javadesktop.org wrote:
> One thing I am noticing in /opt/glassfish/domains/domain1/logs/server.log. Everytime I select the web applications page in the Admin Console I get the following error:

Please check the URL. Is this the same you enter manually? Most probably
not. The "launch" links do not work for me as well (they do not take
virtual server settings into account).

>
> (I do not however get it when trying to access my Web App using http://localhost:8080).
>
> [#|2008-07-10T14:05:23.989-0400|WARNING|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=15;_ThreadName=SelectorThread-4848;_RequestID=e04ee244-70fa-4cd7-b0fa-25fb9fe6b8d0;|setReuseAddress exception
> java.net.SocketException: Invalid argument
> at sun.nio.ch.Net.setIntOption0(Native Method)
> at sun.nio.ch.Net.setIntOption(Net.java:152)
> at sun.nio.ch.SocketChannelImpl$1.setInt(SocketChannelImpl.java:372)
> at sun.nio.ch.SocketOptsImpl.setBoolean(SocketOptsImpl.java:38)
> at sun.nio.ch.SocketOptsImpl.reuseAddress(SocketOptsImpl.java:156)
> at sun.nio.ch.OptionAdaptor.setReuseAddress(OptionAdaptor.java:177)
> at sun.nio.ch.SocketAdaptor.setReuseAddress(SocketAdaptor.java:333)
> at com.sun.enterprise.web.connector.grizzly.SelectorThread.setSocketOptions(SelectorThread.java:1910)
> at com.sun.enterprise.web.connector.grizzly.SelectorThread.handleAccept(SelectorThread.java:1475)
> at com.sun.enterprise.web.connector.grizzly.SelectorThread.handleConnection(SelectorThread.java:1439)
> at com.sun.enterprise.web.connector.grizzly.SelectorThread.doSelect(SelectorThread.java:1350)
> at com.sun.enterprise.web.connector.grizzly.SelectorThread.startListener(SelectorThread.java:1284)
> at com.sun.enterprise.web.connector.grizzly.SelectorThread.startEndpoint(SelectorThread.java:1247)
> at com.sun.enterprise.web.connector.grizzly.SelectorThread.run(SelectorThread.java:1223)
> |#]
> [Message sent by forum member 'fishglass' (fishglass)]
>
> http://forums.java.net/jive/thread.jspa?messageID=285761
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net