javaservletssap-business-technology-platform

Access a Java Servlet on SAP cloud platform


I'm trying to create a servlet and deploy it to the SAP cloud platform. Not familiar with servlets at all.

To start, I have created and deployed what is pretty much whatever eclipse generates as their example app

@WebServlet("/hello")
public class HelloWorldServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
    */
    public HelloWorldServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.getWriter().println("Hello World!");
    }
}

Then, I deploy this and I can see the app is running and I have a URL.

enter image description here

I'm trying to access it from the browser now, by the URL you see in the screenshot above. I thought that all I had to do was add /hello to the end of it and we're off. It gives a 404 though. The access logs say I'm accessing that servlet but I cannot get the "hello world" to show:

enter image description here

Anyone know what the URL's are meant to be here?

Edit:

On redeployment, it starts to chuck errors. Only the initial deploy seems to work:

Problem during deploymentJava version [8] is not compatible with the currently specified runtime; use runtime neo-java-web 2.x or 3.x or neo-javaee7-wp 1.x


Solution

  • The answer was not to use the "deploy to sap cloud platform" options in Eclipse, but to export as WAR file and choosing Tomcat 8 as the runtime environment. After that, manually update the application on SCP by uploading the WAR file and restart the running process.

    Worked for me.