2

When I was using JBoss 7.1.1 I could display a JSP page doing something like that :

@WebServlet("/path")
public class Controller extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.getServletContext().getRequestDispatcher("/WEB-INF/login.jsp").forward(request, response);
    }

}

But when I do the same thing with WildFly 9.0.2 it's not working and I have the following error :

15:55:40,264 DEBUG [org.jboss.resteasy.core.SynchronousDispatcher 60] (default task-2) PathInfo: /WEB-INF/login.jsp
15:55:40,269 WARN  [org.jboss.resteasy.core.ExceptionHandler 135] (default task-2) failed to execute: javax.ws.rs.NotFoundException: Could not find resource for full path: http://localhost:8080/myapp-web/WEB-INF/login.jsp
    at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:112) [resteasy-jaxrs-3.0.11.Final.jar:]
    at org.jboss.resteasy.core.registry.RootNode.match(RootNode.java:43) [resteasy-jaxrs-3.0.11.Final.jar:]
    at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48) [resteasy-jaxrs-3.0.11.Final.jar:]
    ...

My web.xml file is almost empty :

<?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">
</web-app>

How to do it working with WildFly 9 ?

cheb1k4
  • 2,316
  • 7
  • 26
  • 39
  • 1
    Works for me. Did you put login.jsp in you WEB-INF directory and that it's getting copied into your WEB-INF deployment directory? – K.Nicholas Dec 05 '15 at 19:47
  • Yes my mistake. I have a class which extends `javax.ws.rs.core.Application` with the annotation `javax.ws.rs.ApplicationPath`. And the value of the annotation was `"/"`. That's why I could't reached my JSP. – cheb1k4 Dec 10 '15 at 16:14

2 Answers2

0

I found the solution. It was my mistake. In the following class, the annotation value was "/" instead of "/ws" for example:

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("/ws")
public class JaxRsActivator extends Application {

}
cheb1k4
  • 2,316
  • 7
  • 26
  • 39
0

It sounds like you are redirecting a client/user to a login prompt for your restful service. The way I have seen this done is to use the BASIC authentication configuration in the web.xml file. I recently ported dukes-forest to wildfly and it uses that setup. You are welcome to look at it if you want. The service is a payment service and it is setup to use a database to hold users. The database configuration is in the entities project, and the client is in the main dukes-store project in the PaymentHandler.java class. Hope this helps.

K.Nicholas
  • 10,956
  • 4
  • 46
  • 66