0

I'm doing a web application in Java and I want to use Servlets with tomcat.

In my local environment with Netbeans on Windows and everything works perfectly. The problem is that the OS of my server is Ubuntu and when I copy the build folder generated by Netbeans, my web application doesn't work.

I have discovered that my problem is my web.xml file. When it's inserted inside the WEB-INF folder, the index.html doesn't display. Need I anything special to run it on Ubuntu?

Thank you!

My web.xml is:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 
      xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
                          http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <servlet>
        <servlet-name>ServletManager</servlet-name>
        <servlet-class>Servlets.ServletManager</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>ServletManager</servlet-name>
        <url-pattern>/ServletManager</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
</web-app>
Jorge Campos
  • 22,647
  • 7
  • 56
  • 87
dario
  • 170
  • 1
  • 14
  • 3
    Copied "the build folder"? Aren't you creating a .war file for the webapps folder on your Tomcat installation? – Bruno Lowagie Dec 11 '13 at 22:16
  • Look in the Tomcat logfiles if there is any error message. If yes, then add that error message to your post. Which version of Tomcat are you using on Ubuntu? Is it a version that supports the Servlets 3.0 spec (as that is what your `web.xml` indicates you're using)? – Jesper Dec 11 '13 at 22:18
  • I'm inclined of voting to close the question. You're saying your problem is related to Ubuntu. Why would that be relevant? It's Java and Tomcat; the OS doesn't matter. You say the problem is caused by your web.xml, but if your web app works on one OS, why would there be a problem with the web.xml? And when you say "it doesn't work", I'm wondering how you're trying to access the Servlet. There are too many assumptions in your question that seem to be wrong. – Bruno Lowagie Dec 11 '13 at 22:25
  • Hi Bruno, i didn't create a .war file. When i said "It doesn't works would say that my index.html page didn't display. I have two error messages: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]] Caused by: java.lang.UnsupportedClassVersionError: Servlets/ServletManager : Unsupported major.minor version 51.0 (no puedo cargar clase Servlets.ServletManager) Thank you!! – dario Dec 12 '13 at 23:35

1 Answers1

1

Just to ensure I am understanding you correctly.

You have this layout:

/app
/app/WEB-INF/web.xml
/app/index.html
/app/WEB-INF/classes/Servlets/ServletManager.class

You have copied all files, including the web.xml from above.

When you call:

http://server:port/app/

You don't see the index.html?

This would be correct, because you don't have a <welcome-file-list> element (How to configure welcome file list in web.xml)

If you call

http://server:port/index.html 

you should see your index.html.

BUT This is a really bad way to create a Java-Webapplication. You should use some build management-tool like Maven.

Community
  • 1
  • 1
Christian Kuetbach
  • 15,850
  • 5
  • 43
  • 79