0

I have the following setup:

Project A - A Dynamic Web project, which depends on project B. Project B - A Dynamic Web project, that defines a Test.jsp file.

If I launch project B on the server, or move the Test.jsp to project A and launch project A on the server. it works just fine, and I can access the .../Test page'.

But when the Test.jsp remains in project B and I launch project A, although I do see the project-b.jar in the war file and the classes from project B does load, which means most of the process works ok, and only the jsps are not added...

How can I solve this?

YakovL
  • 7,557
  • 12
  • 62
  • 102
TacB0sS
  • 10,106
  • 12
  • 75
  • 118
  • http://stackoverflow.com/questions/5013917/can-i-serve-jsps-from-inside-a-jar-in-lib-or-is-there-a-workaround – JB Nizet Aug 30 '14 at 15:04
  • I've searched for quite some time, but didn't get to that question... Thanks, that question really solved it! – TacB0sS Aug 30 '14 at 17:48

1 Answers1

0

In Case anyone would get to this question, the solution described in here works well, though was not very clear at first:

In my project B, place your jsp files so:

src/main/webapp/META-INF/resources/${path-to-jsp}/file.jsp

In src/main/webapp/META-INF/ create a web-fragment.xml with your variation of the following content:

<web-fragment
    metadata-complete="true"
    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-fragment_3_0.xsd">

    <servlet>
        <servlet-name>jspTest</servlet-name>
        <jsp-file>/${path-to-jsp}/file.jsp</jsp-file>
    </servlet>
    <servlet-mapping>
        <servlet-name>jspTest</servlet-name>
        <url-pattern>/test</url-pattern>
    </servlet-mapping>
</web-fragment>

and now if your buildpath is defined correctly, then clean-build both project B, and project A and run the server again... it works!

Community
  • 1
  • 1
TacB0sS
  • 10,106
  • 12
  • 75
  • 118