OHDSI Home | Forums | Wiki | Github

WebAPI JAR Conflict

I am new to the ODHSI suite of web tools, and I am having trouble with my installation of the WebAPI (cloned from github 12/5/2017) using PostgreSQL 9.6.6. I am using Java 1.8.0.151, Maven 3.5.0 and Tomcat 8.5.24 on Ubuntu 17.10.

When Accessing http://localhost:8080/WebAPI/source/sources I get the following error:

Type Exception Report

Message Servlet.init() for servlet [org.ohdsi.webapi.JerseyConfig] threw exception

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

javax.servlet.ServletException: Servlet.init() for servlet [org.ohdsi.webapi.JerseyConfig] threw exception
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
	org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
	org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	java.lang.Thread.run(Thread.java:748)
Root Cause

java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
	org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:331)
	org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:392)
	org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
	org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369)
	javax.servlet.GenericServlet.init(GenericServlet.java:158)
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
	org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
	org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	java.lang.Thread.run(Thread.java:748)

When ging through the jar files in the web applications’s lib directory I noticed that there are two jar file that contain the class javax.ws.rs.core.Application:

kai@kai-VirtualBox:~/tomcat/webapps/WebAPI/WEB-INF/lib$ grep -lir "javax.ws.rs.core.Application" *.jar
javax.ws.rs-api-2.0.1.jar
jersey-core-1.13.jar

When expanding the source version of jersey-core-1.13.jar I see that its version of javax.rs.core.Application has indeed no getProperties() method. How can I as an implementer resolve this conflict? I am building the WebAPI from source code cloned from github within the past week. Thansk for your help!

I think we need to either update the dependency of jersey-core or exclude it. There’s a way to specify this in the maven pom.xml file, but I need to dig into what the solution is. I think this was raised as an issue under the WebAPI repo.

Update: I removed the ‘scope’ element from this dependency XML example. Apologies. Please update the POM to the updated form below:

Could you try to modify your local POM.xml file to switch the microsoft JDBC dependency to this:

<dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>mssql-jdbc</artifactId>
    <version>6.2.2.jre8</version>
</dependency>

Then recompile the WAR with the mvn command, and redeploy to tomcat. Let us know if that resolves this.

Hi Chris, thank you so much, that worked! Cheers, Kai

No Problem. We’ll make an update to the POM for the next release of WebAPI.

Hi @kaiwpost @Chris_Knoll

I am having trouble with the deployment of WebAPI war .
I cloned from github on 8th Aug 2018 using postgres 9.6.2 .However when i am deploying the WebAPI war on tomcat i am getting sqlserver exception on startup logs .

SEVERE: Unable to create initial connections of pool.
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host serverName, port 1433 has failed. Error: "serverName. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.

I am not able to find anything in documentation which states that i need to configure sqlserver apart from the database you are using.

The pom file does mention this however:

<!-- Primary DataSource -->
    <!-- default sql server - TODO How about making postgres the default (e.g. in line with open source tech)? -alexfranken -->
    <datasource.driverClassName>com.microsoft.sqlserver.jdbc.SQLServerDriver</datasource.driverClassName>
    <datasource.url>jdbc:sqlserver://serverName;databaseName=databaseName</datasource.url>
    <datasource.username>user</datasource.username>
    <datasource.password>password</datasource.password>

Am i missing anything.Any help is appreciated.

Edit:I have found a solution for the error i was receiving during startup. :yum:

I build the WebAPI again with webapi-postgresql as profile id.

t