Good morning people.
I am trying to load an ontology from a Restfull service using Jersey. However, my application throws exception in the following line:
OWLOntologyManager manager OWLManager.createOWLOntologyManager = ();
I thank the help of all.
Error log:
javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class org.semanticweb.owlapi.apibinding.OWLManager
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:420)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
My web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>SemanticMDX</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
My Service:
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@Path("/semantichelper")
public class WS_SemanticMDX {
@GET
@Produces("application/xml")
public String convertCtoF() {
AssistenteSemantico moduloSemantico = new AssistenteSemantico();
moduloSemantico.loadOWLOntology();
return "";
}
}
Method to load ontology:
public class AssistenteSemantico {
public static final IRI iri = IRI.create(
"myIRI/NovaOntologiaDeFeriados.owl");
public OWLOntology loadOwlOntology(){
OWLOntology owlOntologyRedirect = null;
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
manager.addIRIMapper(new SimpleIRIMapper(
iri,
IRI.create(new File(myPath/OntologiaDeFeriados-v4.owl"))));
try {
owlOntologyRedirect = manager.loadOntology(iri);
} catch (OWLOntologyCreationException e) {
e.printStackTrace();
}
return owlOntologyRedirect;
}
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>SemanticMDX</groupId>
<artifactId>SemanticMDX</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>owlapi-distribution</artifactId>
<version>3.5.2</version>
</dependency>
<dependency>
<groupId>com.github.ansell.pellet</groupId>
<artifactId>pellet-owlapiv3</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.19</version>
</dependency>
</dependencies>
error after adding the jar OWL API both in WEB-INF / lib as in diterório lib tomcat:
com.google.inject.CreationException: Unable to create injector, see the following errors:
1) No implementation for java.util.Set was bound. while locating java.util.Set for parameter 0 at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.setOntologyStorers(OWLOntologyManagerImpl.java:1333) at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.setOntologyStorers(OWLOntologyManagerImpl.java:1333) at uk.ac.manchester.cs.owl.owlapi.OWLAPIImplModule.configure(OWLAPIImplModule.java:61)
2) An exception was caught and reported. Message: org.semanticweb.owlapi.oboformat.OBOFormatOWLAPIParserFactory cannot be cast to javax.inject.Provider at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:138)
2 errors com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:466) com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:155) com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107) com.google.inject.Guice.createInjector(Guice.java:96) com.google.inject.Guice.createInjector(Guice.java:73) com.google.inject.Guice.createInjector(Guice.java:62) org.semanticweb.owlapi.apibinding.OWLManager.createInjector(OWLManager.java:89) org.semanticweb.owlapi.apibinding.OWLManager.instatiateOWLOntologyManager(OWLManager.java:97) org.semanticweb.owlapi.apibinding.OWLManager.createOWLOntologyManager(OWLManager.java:58) AssistenteSemantico.carregarOwlOntology(AssistenteSemantico.java:35) AssistenteSemantico.inferirDiasParteDeIntervaloPorNomeindividuo(AssistenteSemantico.java:112) WS_SemanticMDX.convertCtoF(WS_SemanticMDX.java:17) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185) com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302) com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542) com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473) com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419) com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409) com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409) com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558) com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause
java.lang.ClassCastException: org.semanticweb.owlapi.oboformat.OBOFormatOWLAPIParserFactory cannot be cast to javax.inject.Provider org.semanticweb.owlapi.OWLAPIServiceLoaderModule.loadFactories(OWLAPIServiceLoaderModule.java:109) org.semanticweb.owlapi.OWLAPIServiceLoaderModule.configure(OWLAPIServiceLoaderModule.java:59) com.google.inject.AbstractModule.configure(AbstractModule.java:62) com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:340) com.google.inject.spi.Elements.getElements(Elements.java:110) com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:138) com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104) com.google.inject.Guice.createInjector(Guice.java:96) com.google.inject.Guice.createInjector(Guice.java:73) com.google.inject.Guice.createInjector(Guice.java:62) org.semanticweb.owlapi.apibinding.OWLManager.createInjector(OWLManager.java:89) org.semanticweb.owlapi.apibinding.OWLManager.instatiateOWLOntologyManager(OWLManager.java:97) org.semanticweb.owlapi.apibinding.OWLManager.createOWLOntologyManager(OWLManager.java:58) AssistenteSemantico.carregarOwlOntology(AssistenteSemantico.java:35) AssistenteSemantico.inferirDiasParteDeIntervaloPorNomeindividuo(AssistenteSemantico.java:112) WS_SemanticMDX.convertCtoF(WS_SemanticMDX.java:17) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185) com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302) com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542) com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473) com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419) com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409) com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409) com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558) com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)