1
votes

I have a Tomcat server and a Glassfish4 server. My Servlet launches perfectly fine with the Tomcat server BUT gives me an "HTTP Status 404" error for the Glassfish4 server. Here is all I have in the Tomcat ROOT directory:

WEB-INF

  • classes (folder)
  • lib (folder)
  • web.xml

Here are the contents for the "web.xml" file...

<web-app>
    <servlet>
        <servlet-name>HelloWorld</servlet-name>
        <servlet-class>HelloWorld</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>HelloWorld</servlet-name>
        <url-pattern>/HelloWorld</url-pattern>
    </servlet-mapping>
</web-app>

This is the output I get using the Tomcat server ( when I run --> localhost:8080/HelloWorld ):

TOMCAT SERVER OUTPUT

For Glassfish4, I added the "WEB-INF" folder ( which is all I had in the Tomcat server ) into the "C:\glassfish4\glassfish\domains\domain1\docroot" folder ( ROOT equivalent of Tomcat server ) and used the same url ( localhost:8080/HelloWorld ). Which is when I got the 404 error.

GLASSFISH OUTPUT

I know the Glassfish4 server works because I put an ordinary index.html and it pulled it up just fine. I understand Glassfish4 is more than just a servlet container, maybe I am missing something?

Any answers will be appreciated. Please let me know if you need anything else.

Thanks.

1
C:\glassfish4\glassfish\domains\domain1\applications\appName\projectNameOfWebModule_war is the location of the WEB-INF. (deployed with Eclipse)code_angel
With the Tomcat I was not using Eclipse or any other IDE for it to work... I simply used the "Sublime Text 2" editor and compiled my work with javac using the command prompt on Windows. Is there a way to be able to deploy a servlet, as simple as the Tomcat server, but for the Glassfish 4 server?dani.nykh
You can deploy via copiing the WAR file from Tomcat to Glassfish. Or the entpacked WAR like in my other comment. Don't waste your time thinking an deployment, use an IDE like Eclipse.code_angel

1 Answers

1
votes

For manuall deployment without IDE there are few examples in the official documentation:

Excerpt:

Use the asadmin deploy command. The general form for the command is:
as-install/bin/asadmin deploy war-name

To deploy the hello.war sample, the command is:
as-install/bin/asadmin deploy sample-dir/hello.war