Exception launching JUnit test nuxeo-opencmis-tests org/nuxeo/ecm/core/opencmis/impl/TestNuxeoSessionAtomPub.java from Eclipse
I receive the following error when I attempt to launch JUnit test org/nuxeo/ecm/core/opencmis/impl/TestNuxeoSessionAtomPub.java from Eclipse. The tests run fine from Maven command-line so I suspect this is a “Tomcat running within Eclipse” anomaly. Any suggestions?
DatabaseHelper: Database used for VCS tests: org.nuxeo.ecm.core.storage.sql.DatabaseH2
Unknown JNDI Context class: null
Jun 5, 2012 6:43:39 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-17488"]
Jun 5, 2012 6:43:40 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Jun 5, 2012 6:43:40 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.23
Jun 5, 2012 6:43:40 AM org.apache.catalina.startup.DigesterFactory register
WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_2.xsd
Jun 5, 2012 6:43:40 AM org.apache.catalina.startup.DigesterFactory register
WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_1.xsd
Jun 5, 2012 6:43:40 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-17488"]
Jun 5, 2012 6:44:03 AM org.apache.coyote.http11.AbstractHttp11Processor process
SEVERE: Error processing request
java.lang.NoSuchMethodError: javax.servlet.ServletContext.getEffectiveSessionTrackingModes()Ljava/util/Set;
at org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:674)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:402)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Not sure why it runs via maven indeed…
Yes HttpUtils.splitPath
is a bit strange. NXP-9550 includes a fix for this.
Note that when running the CMIS tests from Eclipse you must make sure that the classpath has tomcat-embed-core
early in the list of dependencies as it includes a version of servlet-api
3.0 which, if later in the classpath, could be overridden by the standard servlet-api
2.5 dependency of the rest of Nuxeo.
We don't quite support Tomcat 7 at the moment. It requires Servlet 3 but Nuxeo only has Servlet 2.5.
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>7.0.23</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-juli</artifactId>
<version>7.0.23</version>
</dependency>
Is this incorrect since Nuxeo does not yet support tomcat 7?
I went ahead and reconfigured NuxeoSessionClientServerTestCase to use Jetty instead of Tomcat to workaround the problem and as expected, the Servlet 3 problem disappeared. However, now I receive the following error, again when running within Eclipse. Any thoughts?
DatabaseHelper: Database used for VCS tests: org.nuxeo.ecm.core.storage.sql.DatabaseH2
Unknown JNDI Context class: null
failed SocketConnector@localhost:17488: java.net.BindException: Address already in use: JVM_Bind
failed Server@246972f1: java.net.BindException: Address already in use: JVM_Bind
The stacktrace I listed above with the JVM_Bind was a Red Herring. The real stacktrace that occurs when I run a TestNuxeoSessionAtomPub test in Eclipse with the test reconfigured for Jetty (USE_TOMCAT=false) is listed at the bottom of this comment.
After some troubleshooting, it appears the Apache Chemistry OpenCMIS server has problems parsing the following URL created by the test case: http://localhost:17488/?repositoryId=test. Specifically, the OpenCMIS HttpUtils.createContext(request, response, servletContext, binding, callContextHandler) method incorrectly sets the repositoryId to the empty string when the path="/". Instead, it should set the repositoryId = null in this case. I suspect this might be a bug with OpenCMIS method HttpUtils.splitPath(request) listed below.
public static String[] splitPath(HttpServletRequest request) {
String p = request.getPathInfo();
if (p == null) {
return new String[0];
}
return p.substring(1).split("/");
}
If this method is changed to handle ("/".equals(p)) just like (p == null), the problem disappears. Thoughts?
Also, I am not sure why I only seem to encounter this problem when running the tests within Eclipse. The tests work fine when run via Maven. Thoughts?
org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException: No such repository:
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:423)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.read(AbstractAtomPubService.java:554)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.getRepositoriesInternal(AbstractAtomPubService.java:718)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.RepositoryServiceImpl.getRepositoryInfo(RepositoryServiceImpl.java:63)
at org.apache.chemistry.opencmis.client.bindings.impl.RepositoryServiceImpl.getRepositoryInfo(RepositoryServiceImpl.java:69)
at org.apache.chemistry.opencmis.client.runtime.SessionImpl.connect(SessionImpl.java:676)
at org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl.createSession(SessionFactoryImpl.java:90)
at org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl.createSession(SessionFactoryImpl.java:64)
at org.nuxeo.ecm.core.opencmis.impl.NuxeoSessionClientServerTestCase.setUpCmisSession(NuxeoSessionClientServerTestCase.java:91)
at org.nuxeo.ecm.core.opencmis.impl.NuxeoSessionTestCase.setUp(NuxeoSessionTestCase.java:123)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.internal.runners.MethodRoadie.runBefores(MethodRoadie.java:129)
...