NoSuchMethodError: io.swagger.jaxrs.config.BeanConfig.setUsePathBasedConfig(Z)V - java

I am working with CXF 3.1.8,i want to integrate Swagger,so i added the code below:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description-swagger</artifactId>
<version>3.1.7</version>
</dependency>
And in JAXRSServerFactoryBean i added :
JAXRSServerFactoryBean jfb =new JAXRSServerFactoryBean();
Swagger2Feature feature=new Swagger2Feature();
jfb.getFeatures().add(feature);
But i get error when i want to deploy my application:
Caused by: java.lang.NoSuchMethodError:
io.swagger.jaxrs.config.BeanConfig.setUsePathBasedConfig(Z)V
Any help is appreciate.

Please check the version of the swagger-jaxrs dependency that you are using.
I suggest to upgrade the CXF version too. Latest 3.1.x would be 3.1.18, but you should probably use the latest 3.3.0 version. Look here https://github.com/apache/cxf/tree/cxf-3.3.0/distribution/src/main/release/samples/jax_rs for several working samples.

Related

Elasticsearch method not being found in spring boot

I have been stuck with this issue for a while now and any assistance is appreciated. I am running Spring Boot version 2.2.0 with the ElasticSearch high-level REST Client version 6.4.3 and using version 3.2.0 for the Spring-Data-Elasticsearch version. I am getting the error below. I have tried the following attempts to fix but none do.
Change Spring Boot Version multiple times
Change ES version multiple times
I have cleared my .m2 folder and redownloaded the maven dependencies multiple times.
The issue I am getting below is
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.putMapping(ElasticsearchRestTemplate.java:292)
The following method did not exist:
org.elasticsearch.client.IndicesClient.putMapping(Lorg/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest;Lorg/elasticsearch/client/RequestOptions;)Lorg/elasticsearch/action/support/master/AcknowledgedResponse;
The method's class, org.elasticsearch.client.IndicesClient, is available from the following locations:
jar:file:/Users/user/.m2/repository/org/elasticsearch/client/elasticsearch-rest-high-level-client/6.4.3/elasticsearch-rest-high-level-client-6.4.3.jar!/org/elasticsearch/client/IndicesClient.class
It was loaded from the following location:
file:/Users/user/.m2/repository/org/elasticsearch/client/elasticsearch-rest-high-level-client/6.4.3/elasticsearch-rest-high-level-client-6.4.3.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.elasticsearch.client.IndicesClient
My POM is below
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>3.2.0</version>
</dependency>
Any help is appreciated. I am sure it has to deal with compatibility issues but not sure which. Thanks all!
Update
I was able to get it run sucessfully by changing my elasticsearch version to 6.7.0. But now I am receiving the following error
org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=index_not_found_exception, reason=no such index]
My POM looks like this below now also.
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>6.70</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>6.70</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>6.70</version>
</dependency>
Previous issue of method that does not exist. was resolved by changing the elasticsearch version to 6.7.0.
To avoid these incompatibility issues its always recommend to use the same version of elasticsearch server and its client.
I faced the exact same issue, I was using elastic search 6.8.18.
and as mentioned changed the version of elastic search by using below in Gradle.
ext['elasticsearch.version'] = '6.8.18'
use this for reference - overriding dependency versions

Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.Transformer [duplicate]

I am receiving the following error java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer trying to use BeanMap from the Apache Commons BeanUtils library.
It is generated from the following code: BeanMap studentBeanMap = new BeanMap(cohortStudentData.get(row)); where cohortStudentData is a list of beans.
I am using BeanListHandler from Apache DBUtils to form the list of beans from a database.
I understand from this and this bug report that BeanMap is dependant on the Apache Collections framework. However, I have imported all relevant libraries into my project and into my class, as you can see below:
Does anyone know why this might be happening?
I am not really sure, but i think your error is because of jar versions. Lately apache has changed the package of the new versions of their jars because they implement new functionality or something that is not fully backward compatible. For example the jar commons-beanutils-1.9.2.jar depends on commons-collections-3.2.1.jar (according to this site) and you are using commons-collections-4.4.0.jar. If you are planning using the universe of apache jars, you need to be sure that they are all compatible.
Just add this dependency to your project.
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
commons-collections4-x.x.jar Add the library to your classpath and try to run again. It will work.
Download the library from:
https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.1
Adding dependency of version 3.2.1 seems working here
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
Add commons-collections-3.2.jar to library of the project

java.lang.ClassNotFoundException: com.sun.mail.util.MessageRemovedIOException

While upgrading application from jdk6 to jdk8, we are getting following error on Message msg = new MimeMessage(session);
SEVERE: Servlet.service() for servlet [default] in context with path [] threw exception [java.lang.reflect.InvocationTargetException] with root cause
java.lang.ClassNotFoundException: com.sun.mail.util.MessageRemovedIOException
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
Has anyone faced the same or related issue while upgrading their java app ?
EDIT: the same code is working with java6.
You've got a mix of JavaMail classes from different versions of JavaMail in your classpath. What application server are you using and what's in the lib directory of your web application?
i used this and it worked:
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.5</version>
</dependency>
I had a similar problem. I am using Maven dependencies to
configure external libraries.
The problem was resolved by switching from the new maven repository
for the Java Mail Api, to the old Maven repository
New Repository(raises the exception):
javax.mail
javax.mail-api
1.5.5
Old repository(works fine):
javax.mail
mail
1.4
I have no idea why using the old repository works, and using the new one doesn't. It would be great if someone was to clarify this.

Neo4j 2.0, java - Failed to start Neo4j with an older data store version

I used to use neo4j-community-1.9.4 with my java maven project. I switched to version 2.0 and made completly new db in 2.0. When I run the same java code, I get error:
Exception in thread "main" org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException: Failed to start Neo4j with an older data store version. To enable automatic upgrade, please set configuration parameter "allow_store_upgrade=true"
at org.neo4j.kernel.impl.storemigration.ConfigMapUpgradeConfiguration.checkConfigurationAllowsAutomaticUpgrade(ConfigMapUpgradeConfiguration.java:39)
at org.neo4j.kernel.impl.storemigration.StoreUpgrader.attemptUpgrade(StoreUpgrader.java:64)
at org.neo4j.kernel.impl.nioneo.store.StoreFactory.tryToUpgradeStores(StoreFactory.java:104)
at org.neo4j.kernel.impl.nioneo.store.StoreFactory.newNeoStore(StoreFactory.java:86)
at org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource.<init>(NeoStoreXaDataSource.java:232)
at org.neo4j.kernel.InternalAbstractGraphDatabase.create(InternalAbstractGraphDatabase.java:423)
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:226)
at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:79)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:70)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:205)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:56)
at tools.Import.main(Import.java:32)
Any idea? Thank you.
Neo4j 2.0 requires an explicit store upgrade, because older versions will no longer be able to run on the upgraded store. The exception mentions this:
Failed to start Neo4j with an older data store version. To enable automatic upgrade, please set configuration parameter "allow_store_upgrade=true"
Simply add allow_store_upgrade=true to your neo4j.properties file, and start the database again. Then it should do the upgrade. You can read more about this here:
http://docs.neo4j.org/chunked/stable/deployment-upgrading.html#explicit-upgrade
Solved, I replaced dependency from spring:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>2.3.3.RELEASE</version>
</dependency>
By this:
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>2.0.0</version>
</dependency>
For community edition on windows,
click on Options, Database Configuration, Edit
look for allow_store_upgrade

Apache CXF Dynamic Client creation

I am trying to use Apache CXF to talk to a unknown web service. I have followed the Dynamic Client example from Apache.
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
Client client = factory.createClient(wsdlURL.toExternalForm(), SERVICE_NAME);
This was working but now i am getting this exception when calling createClient():
java.lang.IllegalStateException: Unable to create schema compiler
Caused by:
javax.xml.bind.JAXBException
- with linked exception:
[java.lang.ClassNotFoundException: com/sun/tools/internal/xjc/api/XJC]
This looks similar to an existing bug. I am using DOSGi singlebundle 1.2 which includes cxf-minimal-2.2.9.jar; meaning the bug should be fixed in the version I'm using. the jaxb-api is included in my Apache CXF distribution which upon inspection contains jaxb-xjc.
Can anybody provide me some insight as to what I'm doing wrong? I swear this used to work.
"java.lang.ClassNotFoundException: com/sun/tools/ " is often occurs if you use JRE in your IDE intead of JDK.
Make sure, you use JDK in IDE (e.g. eclipse)
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.2.11</version>
</dependency>
resolved problem
Another solution is to include the cxf-rt-core in your Maven dependencies.

Categories

Resources