For a long while all fast attempts to try Apache Jackrabbit 2.x on Apache Tomcat™ 8.x failed with a « Only one repository startup servlet allowed per web-app. » error message.

Few months ago I had to make those work together and spend some time to diagnose and fix it. Running it with JPDA DEBUG mode I found that getServletContext().getResourceAsStream(…) has strange behavior. Despite the javadoc states it should return null, it throws an IllegalArgumentException.


RepositoryStartupServlet.java (v2.10)

private void initRepository() throws ServletException {
...
    InputStream in = getServletContext().getResourceAsStream(bstrp);
...
}

throws java.lang.IllegalArgumentException: The resource path [jackrabbit/bootstrap.properties] is not valid.

The error is then catched by welcome.jsp


Repository rep;
try {
    rep = RepositoryAccessServlet.getRepository(pageContext.getServletContext());
} catch (Throwable e) {
    %>< jsp:forward page="bootstrap/missing.jsp"/><%
}

which hides a bit.

Fix :


RepositoryStartupServlet.java line 409
...
private void initRepository() throws ServletException
Replace :

InputStream in = getServletContext().getResourceAsStream(repConfig);

By (a better catch would be great)


InputStream in = null;
try {
    in = getServletContext().getResourceAsStream(repConfig);
} catch (IllegalArgumentException e2) {
    // TODO Auto-generated catch block
    e2.printStackTrace();
}

Then update web.xml : Replace all (2 values) bootstrap-config jackrabbit/bootstrap.properties

by :

<init-param>
    <param-name>bootstrap-config</param-name>
    <param-value>/jackrabbit/bootstrap.properties</param-value>
    <description></description>
</init-param>

Note : there is a new / character in the param-value for both ‘bootstrap-config’ parameters.

It should now start and run but the error may still to be improved.

(214 mots)