Hibernate makes Weld not initializing in Java SE - java

So, I have a basic Java SE program with dependency injection using Weld 1.2.
Everything is working fine, until I throw Hibernate into the mix, with the following pom.xml dependency entries:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se</artifactId>
<version>2.2.4.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.6.Final</version>
</dependency>
Hibernate being the added dependency, making it break. This is my entry class:
public class EntryPoint {
public static void main( String[] ARGV ) {
Weld weld = new Weld();
WeldContainer container = weld.initialize();
Application application = container.instance().select(Application.class).get();
application.testFetch();
weld.shutdown();
}
}
When I try to run it after including Hibernate dependency, this is my output:
Sep 11, 2014 11:13:44 PM org.jboss.weld.bootstrap.WeldStartup <clinit>
INFO: WELD-000900: 2.2.4 (Final)
Sep 11, 2014 11:13:44 PM org.jboss.weld.bootstrap.WeldStartup startContainer
INFO: WELD-000101: Transactional services not available. Injection of #Inject UserTransaction not available. Transactional observers will be invoked synchronously.
Exception in thread "main" org.jboss.weld.exceptions.DeploymentException: org.jboss.jandex.ClassInfo.hasNoArgsConstructor()Z
at org.jboss.weld.executor.AbstractExecutorServices.checkForExceptions(AbstractExecutorServices.java:66)
at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:43)
at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:51)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer.addClasses(ConcurrentBeanDeployer.java:62)
at org.jboss.weld.bootstrap.BeanDeployment.createClasses(BeanDeployment.java:209)
at org.jboss.weld.bootstrap.WeldStartup.startInitialization(WeldStartup.java:351)
at org.jboss.weld.bootstrap.WeldBootstrap.startInitialization(WeldBootstrap.java:76)
at org.jboss.weld.environment.se.Weld.initialize(Weld.java:157)
at com.mybeautycompare.integration.EntryPoint.main(EntryPoint.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: java.lang.NoSuchMethodError: org.jboss.jandex.ClassInfo.hasNoArgsConstructor()Z
at org.jboss.weld.environment.se.discovery.WeldSEClassFileInfo.<init>(WeldSEClassFileInfo.java:65)
at org.jboss.weld.environment.se.discovery.WeldSEClassFileServices.getClassFileInfo(WeldSEClassFileServices.java:85)
at org.jboss.weld.bootstrap.FastAnnotatedTypeLoader.loadAnnotatedType(FastAnnotatedTypeLoader.java:61)
at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:97)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:65)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:62)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Line 24 in my EntryPoint class is: WeldContainer container = weld.initialize();

This has nothing to do with Hibernate. You're missing jandex from your classpath, which is required in Weld 2.2.x. Verify that you end up with a jandex 1.2 jar on your classpath after building.
Since you're using maven, add this to your pom.xml:
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
<version>1.2.2.Final</version>
</dependency>
Also related:
Why is Hibernate 4.2 using jandex and classmate if its Maven POM defines them as test scope?

For people who have same issue with the latest versions of Weld and Hibernate:
Both Weld and Hibernate have dependency on Jandex but with different versions, you need to exclude Jandex dependency from the hibernates dependency:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
<exclusions>
<exclusion>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
</exclusion>
</exclusions>
</dependency>
Good Luck

Related

how to add jsf com.sun.faces in websphere 9

I want to start my app using com.sun.faces jsf and primefaces dependency in websphere 9.
The part of pox.xml:
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.13</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.13</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.2</version>
</dependency>
I added jsf-impl-2.2.8-30.jar and jsf-api-2.2.8-30.jar to shared libs in WebSphere (Enterprise Applications > app_name > Shared library references, for application and for module) and got exception in log:
Could not invoke an operation on object: WebSphere:name=ApplicationManager,process=server1,platform=proxy,node=OPOLSKYNode01,version=9.0.0.9,type=ApplicationManager,mbeanIdentifier=ApplicationManager,cell=OPOLSKYNode01Cell,spec=1.0 because of an mbean exception: com.ibm.ws.exception.RuntimeError: java.lang.RuntimeException: com.ibm.ws.cdi.CDIRuntimeException: com.ibm.ws.cdi.CDIDeploymentRuntimeException: org.jboss.weld.exceptions.DefinitionException: Exception List with 1 exceptions:
Exception 0 :
javax.enterprise.event.ObserverException
at java.lang.J9VMInternals.newInstanceImpl(Native Method)
....
Caused by: java.util.ServiceConfigurationError: com.sun.faces.util.cdi11.CDIUtil: Provider com.sun.faces.util.cdi11.CDIUtilImpl not a subtype
...
Later I found that there was a warning written in websphere (Enterprise Applications > app_name > JSP and JSF options):
Version 9.0 and later nodes use the MyFaces JSF implementation, even if SunRI is selected in a mixed-cell environment. For more configuration information, read about JavaServer Faces in the product documentation.
And I tried to add a shared libraries with mojarra-jsf-impl-2.0.0-b04.jar and mojarra-jsf-api-2.0.0-b04.jar
but got:
com.ibm.ws.classloader.CompoundClassLoader#bce1c60f[war:isclite/isclite.war]
Local ClassPath: C:\Program Files\IBM\WebSphere\AppServer\systemApps\isclite.ear\isclite.war\WEB-INF\classes;C:\Program Files\IBM\WebSphere\AppServer\systemApps\isclite.ear\isclite.war\WEB-INF\lib\abdera.client.0.2.2-incubating.jar;C:\Program
...
00000093 annotations W ScannerContextImpl getInputDataForClass Class loader [
com.ibm.ws.classloader.CompoundClassLoader#2d433080[app:isclite]
Local ClassPath: C:\Program Files\IBM\WebSphere\AppServer\systemApps\isclite.ear\lib\batik-all.jar;C:\Program
...
Help me please!
Is it possible to start app with jsf dependency in websphere ?

EJB ETL NoClassDefFoundError: org.apache.poi.util.SAXHelper during runtime

Root pom has the following dependencies,
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.16</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.16</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.16</version>
</dependency>
But during runtime, during etl process following error occurs,
EJB threw an unexpected (non-declared) exception during invocation of method "****" on bean "BeanId(***-ear#***-ejb.jar#***ServiceImpl, null)". Exception data: java.lang.NoClassDefFoundError: org.apache.poi.util.SAXHelper
Root cause is NoClassDefFoundError in the following code snippet,
XMLReader parser = SAXHelper.newXMLReader();
Environment used,
JDK 1.6.0_35
Websphere Application Server v8.0
Eclipse Juno Service Release 2
Full stack trace can be found here
Caused by: java.lang.ClassNotFoundException: org.apache.poi.util.SAXHelper
at java.net.URLClassLoader.findClass(URLClassLoader.java:434)
at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:230)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:703)
at java.lang.ClassLoader.loadClass(ClassLoader.java:682)
at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:123)
at java.lang.ClassLoader.loadClass(ClassLoader.java:665)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:62)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:566)
at java.lang.ClassLoader.loadClass(ClassLoader.java:665)
... 87 more
note: I have opened the ear archive and found the respective jars available. Checked Eclipse java build path also. Everything seems to be fine.
Thanks.
SAXHelper is in poi-ooxml-3.16.jar. I suspect that one of the static initializers in this class is failing.
https://github.com/apache/poi/blob/trunk/src/ooxml/java/org/apache/poi/util/SAXHelper.java

mapping classes in simple jpa project

I whant to configure a simple JPA project, i using Wildfly 8, and the datasource is configured in standalone.xml.
<datasource jta="true" jndi-name="java:jboss/datasources/postgresql" pool-name="postgreSql" enabled="true" use-ccm="true">
<connection-url>jdbc:postgresql://localhost:5432/sell</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<driver>postgres</driver>
<security>
<user-name>postgres</user-name>
<password>sell</password>
</security>
</datasource>
in Web project i configure the persistence.xml file like this
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="sellAppPersistenceUnit"
transaction-type="RESOURCE_LOCAL">
<jta-data-source>java:jboss/datasources/postgresql</jta-data-source>
<class>br.com.sell.app.orm.Usuario</class>
</persistence-unit>
but, when i add a br.com.sell.app.orm.Usuario i got a error on project startup, the error indicates a hibernate problem org/hibernate/proxy/HibernateProxy, but i don't use hibernate.
13:17:50,738 ERROR [org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer] (ServerService Thread Pool -- 58) HHH000142: Javassist Enhancement failed: br.com.sell.app.orm.Usuario: java.lang.RuntimeException: by java.lang.NoClassDefFoundError: org/hibernate/proxy/HibernateProxy
at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:515)
at javassist.util.proxy.ProxyFactory.createClass2(ProxyFactory.java:492)
at javassist.util.proxy.ProxyFactory.createClass1(ProxyFactory.java:428)
at javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:400)
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxyFactory(JavassistLazyInitializer.java:162)
at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.postInstantiate(JavassistProxyFactory.java:67)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:224)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:212)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:80)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:135)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:188)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:403)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:520)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:148)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
Why i can solve this problem?
the pom.xml file:
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
br.com.sell.app
sellApp
0.0.1-SNAPSHOT
pom
sellApp
Backend rest sell app
<modules>
<module>sellAppEndpoint</module>
<module>sellAppWeb</module>
<module>sellAppCors</module>
<module>sellAppDto</module>
<module>sellAppOrm</module>
<module>sellAppJpa</module>
</modules>
<dependencies>
<!-- para importar pacotes javax.* para o REST -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.0.SP1</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.0.0.Final</version>
</dependency>
</dependencies>
Your problem seems to be due to declaring inconsistent dependencies - hibernate-entitymanager in version 5.0.0 requires hibernate-core 5.0.0, but you force to use hibernate-core in version 3.3.0.SP1. The class org.hibernate.proxy.HibernateProxy does not exist in version 3.3.0.SP1. As hibernate-entitymanager declares transitive dependency on hibernate-core, you can just remove the dependency on hibernate-core.
Furthermore, Wildfly 8 already includes hibernate (version 4.3), as it must provide Java EE functionality by specification. You may just use hibernate on Wildfly, which is more standard, unless you don't require special features of hibernate 5.0. In that case remove also hibernate-entitymanager dependency from pom.xml and your code should still work.

Neo4j - Unmanaged extensions with SDN - InvalidDataAccessApiUsageException: Could not resolve dependency of type:javax.transaction.TransactionManager

I followed example from: https://inserpio.wordpress.com/2014/04/30/extending-the-neo4j-server-with-spring-data-neo4j/
Created 1 Repo, 1 Controller (with get and put rest endpoints. get /test/get/{name} uses 'name' property to get the node, put /test/create is just a test endpoint for now that always should create same node which later on i want to get...) and 1 Domain class.. Together with the PluginInitializer, that exposed Neo4jTemplate and my custom repo.
My app-context:
<context:annotation-config />
<context:spring-configured />
<context:component-scan base-package="uk.co.neo4j.extension.tvshow">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<neo4j:config base-package="uk.co.neo4j.extension.tvshow.domain" graphDatabaseService="graphDatabaseService" />
<neo4j:repositories base-package="uk.co.neo4j.extension.tvshow.repository" />
<tx:annotation-driven mode="proxy" />
Pom file dependencies:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>${spring-data-neo4j.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j-rest</artifactId>
<version>${spring-data-neo4j.version}</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>${commons-configuration.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
<version>${neo4j.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${javax.validation.version}</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>${javax.transaction.version}</version>
</dependency>
Followed by maven-compiler-plugin to copy all dependant jar files into lib folder. Add PluginInit fqp to PluginLifecycle file, as well as added package to neo4j server config:
org.neo4j.server.thirdparty_jaxrs_classes=uk.co.neo4j.extension.tvshow=/tv
I copied my jar file + all dependant jar files into neo4j server plugin folder, started it successfully:
**2015-03-22 21:49:37.411+0000 INFO [o.n.s.m.ThirdPartyJAXRSModule]: Mounted unmanaged extension [uk.co.neo4j.extension.tvshow] at [/tv]**
2015-03-22 21:49:37.535+0000 INFO [o.n.s.w.Jetty9WebServer]: Mounting static content at [/webadmin] from [webadmin-html]
2015-03-22 21:49:37.625+0000 INFO [o.n.s.w.Jetty9WebServer]: Mounting static content at [/browser] from [browser]
2015-03-22 21:49:40.361+0000 INFO [o.n.s.CommunityNeoServer]: Server started on: http://localhost:7474/
2015-03-22 21:49:40.361+0000 INFO [o.n.s.CommunityNeoServer]: Remote interface ready and available at [http://localhost:7474/]
2015-03-22 21:49:40.361+0000 INFO [o.n.k.i.DiagnosticsManager]: --- SERVER STARTED END ---
BUT! When I try to use it via rest, i.e. :PUT /tv/test/create OR :GET /tv/test/get/testnode i always get:
Error: 500 - Internal Server Error
In logs I found this, and it happens for both get and put:
SEVERE: The RuntimeException could not be mapped to a response, re-throwing to the HTTP container
org.springframework.dao.InvalidDataAccessApiUsageException: Could not resolve dependency of type:javax.transaction.TransactionManager; nested exception is java.lang.IllegalArgumentException: Could not resolve dependency of type:javax.transaction.TransactionManager
at org.springframework.data.neo4j.support.Neo4jExceptionTranslator.translateExceptionIfPossible(Neo4jExceptionTranslator.java:48)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy72.save(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:201)
at com.sun.proxy.$Proxy74.save(Unknown Source)
at uk.co.neo4j.extension.tvshow.rest.TestController.createTestNode(TestController.java:64)
...
So basically, whenever any operation is done against my repository:
testRepository.getTestNodeByName(name);
testRepository.save(testNode);
It treats it as transaction and the Transaction Manager is not found... From the doc's of SDN I've read that neo4jTransactionManager bean is already configured as part of Neo4jConfiguration, and yes I've checked - it is already there:
#Bean(name = {"neo4jTransactionManager","transactionManager"})
#Qualifier("neo4jTransactionManager")
public PlatformTransactionManager neo4jTransactionManager() throws Exception {
return new JtaTransactionManagerFactoryBean(getGraphDatabaseService()).getObject();
}
So what am I missing? :(

NoSuchMethodError on startup in Java Jersey app

I've been getting a very strange error when trying to start a Jersey app on Tomcat. The same code works on other computers. I tried reinstalling tomcat, all my maven dependencies, even Eclipse and Java itself, no luck. It seems like a bad Jersey version is being loaded, I think?
Any pointers in the right direction will be appreciated.
Here's the effective pom: http://pastebin.com/NacsWTjz
And the actual pom: http://pastebin.com/H6sHe4ce
2015-02-13 13:43:40,870 [localhost-startStop-1] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/middleware-server] - StandardWrapper.Throwable
java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:304)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:285)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1231)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1031)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4901)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5188)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Note: Please see above comments for further discussion and tips.
This error usual means that you have a both a JAX-RS 1 and JAX-RS 2 jar on the classpath. Jersey 2 uses JAX-RS 2 (javax.ws.rs-api-2.0.1.jar), but if you have the jsr311-api.jar also, which is JAX-RS 1, there is a javax.ws.rs.core.Application in each jar. But the jsr311-api Application doesn't have the method getProperties() (hence NoSuchMethodError).
I've come to the conclusion that all you need to do is add the above exclusion to the swagger dependency. The Jackson 2.0 provider (which depends on JAX-RS 1) seems to be overridden by a 2.4.1 provider (which uses the new version). So we don't need to add it ourselves. When it's overridden, it seems to leave behind the jsr311-api.jar. So if we exclude it, no one can attempt to use it, which looks to be the current problem
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-core_2.10</artifactId>
<version>1.3.11</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
</exclusions>
</dependency>
We are using jersey-json 1.9 which has a dependency on jersey-core which also happen to have a javax.ws.rs.core.Application class.
So our fix is to exclude the jersey-core from jersey-json:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.9</version>
<exclusions>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
</exclusion>
</exclusions>
</dependency>
the problem is related about "com.sun.jersey:jersey-core:jar:1.18.3" (or any 1.* version) because old versions of Jersey didn't have that "public Map getProperties()" method.
And one of your dependencies use Jersey version 1 (you can check that in running mvn dependency:tree and search all jersey-core version used)
Me I have resolved the problem deleting all com.sun.jersey dependancies (old api) and using the new one org.glassfish.jersey API
https://mvnrepository.com/artifact/org.glassfish.jersey.core

Categories

Resources