0

Hi there I an issue trying to deploy my Maven jsp college project to a bluemix server. Every thing work fines locally on my tomcat server. I use cloud foundry to push to the server which is okay. the index page works fine but I can not access the pages i get for example.

Error 404: java.io.FileNotFoundException: SRVE0190E: File not found: /handler

Which is a Java class using annotation instead of setting routes in web xml like so.

@WebServlet("/handler")

My pom.xml looks like so.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>ie.cit.ooss</groupId>
    <artifactId>BarSurvey</artifactId>
    <packaging>war</packaging>
    <version>1.0</version>
    <name>assignment2 Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>BarSurvey</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <warSourceDirectory>src</warSourceDirectory>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>

And my project structure looks like so.

enter image description here

You can see my project here .

https://github.com/yawlhead91/ChocolateBarsSurvey/tree/master/BarSurvey

If any one has some help would be great.

Thanks

2 Answers2

1

I made some changes after cloning your git project:

  1. in index.jsp file

    change <form action="/BarSurvey/handler" method="POST">

    to <form action="/handler" method="POST">

  2. in Handler.java file

    change response.sendRedirect("/BarSurvey/results.jsp");

    to `response.sendRedirect("/results.jsp");

  3. in results.jsp file

    change <a href="/BarSurvey">Return</a>

    to <a href="/">Return</a>

Push your application using the java_buildpack

cf push appname -p target/BarSurvey.war -b java_buildpack

Alex da Silva
  • 4,552
  • 2
  • 17
  • 25
0

Check your web.xml - you are currently using:

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" 
version="2.4">

When you should be using:

<web-app 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"
  version="3.0">

See this post : servlet 3.0 @WebServlet use..what will be in web.xml?

Community
  • 1
  • 1
Michael Peacock
  • 2,011
  • 1
  • 11
  • 14