Spring Stomp websockets error stompWebSocketHandlerMapping - spring

I want to communicate through sockets for my web app (spring). I was following this documentation but I get this error. What is the problem?
Error creating bean with name 'stompWebSocketHandlerMapping' defined in class path resource

Solution for anyone getting this error, I replaced these dependecies
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-websocket</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>
with this:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>

Related

ClassNotFoundException: com.fasterxml.jackson.core.util.JacksonFeature in Spring boot, upgrading from Elasticsearch HLRC to Java API Client

I wanted to swap out the deprecated High Level Rest Client with the new Java API Client from Elasticsearch. Problem is, I'm not sure if my dependencies are configured correctly! I'm running into this error:
java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/util/JacksonFeature
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.core.util.JacksonFeature
Elasticsearch just got upgraded to 7.17.3 and Spring Boot is 2.2.8 right now, it will be upgraded later but I'm not sure if that's the problem? Here are my dependencies in the pom:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webmvc-core</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-security</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>co.elastic.clients</groupId>
<artifactId>elasticsearch-java</artifactId>
<version>7.17.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.2</version>
</dependency>
<dependency>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>
I followed the documentation from Elasticsearch here so I tried it with the 2.12.3 version of jackson-databind as well but the error persists. Any idea on what should be changed? Thanks!
Edit: just in case it helps, here's also my client which is where the dependency is needed (I assume)
#Configuration
public class ElasticsearchClient{
RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200)).build();
ElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
public ElasticsearchClient client = new ElasticsearchClient(transport);
}
(I had to put the public in front of client because it sits under another package and won't let me call on it unless it's there)
more info after playing around: turns out there is a parent and it would load an older jackson-databind, so I did the following
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-schema-registry-client</artifactId>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.3</version>
</dependency>
still doesn't work so I'm 200% out of ideas now
Add jackson-core solved my problem.
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.12.3</version>
</dependency>

Spring Boot with Hystrix

I am using Spring Boot with Hystrix for my university project.
The problem I have is when I add Netflix Hystrix dependency to pom.xml file and run the program, It throws an Error called AbstractMethodError : null, but without Netflix Hystrix dependency program runs without any error. How can I slove this?
These are my dependencies
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
This is due to dependency mismatch. Application is trying to call an abstractt method but it doesn't find that method. So, it is throwing the null exception.
Use two dependency netflix-hystrix-dashboard and hystrix as below.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>

java.lang.NoSuchMethodError: org.springframework.beans.factory.support.CglibSubclassingInstantiationStrategy

I have upgraded my Spring framework from 3.1.0 to 3.2.18.
Then I am getting below exception.
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'myService' defined in class path resource
[spring-biproxy-context.xml]: Instantiation of bean failed; nested
exception is java.lang.NoSuchMethodError: org.springframework.beans.factory.support.CglibSubclassingInstantiationStrategy$CglibSubclassCreator$LookupOverrideMethodInterceptor: method (Lorg/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy$CglibSubclassCreator;Lorg/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy$1;)V not found
I did not make any code changes. Only altered the spring version.
Looks like spring framework removed class called LookupOverrideMethodInterceptor in 3.2.18 But in runtime, spring is looking for this class.
Spring_bean_jar_diff
pom.xml
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.18</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.2.18</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.18</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>3.2.18</version>
<scope>compile</scope>
</dependency>

Apache Wink integration with Spring

I am trying to integrate Apache wink 1.4 with Spring on JBoss EAP 6.4. Below is my Pom.xml excerpt.
<dependency>
<groupId>org.apache.wink</groupId>
<artifactId>wink-server</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.wink</groupId>
<artifactId>wink-spring-support</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.wink</groupId>
<artifactId>wink-client</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.wink</groupId>
<artifactId>wink-json4j</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.jboss.archetype.eap</groupId>
<artifactId>jboss-javaee6-webapp-archetype</artifactId>
<version>6.4.0.GA</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
I also have configuration in web.xml to look for winkdefault.properties.
While building the application, It is not able to find the "META-INF/wink-default.properties" I am getting following exception in server log.
[org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 96) Context initialization failed: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [META-INF/wink-default1.properties]; nested exception is java.io.FileNotFoundException: class path resource [META-INF/wink-default.properties] cannot be opened because it does not exist
Could anyone help on this please ?
I decompiled wink-spring-support.jar and changed context with following classpath:META-INF/server/wink-core-context.xml and it was able to register.

SpringPersistenceUnitInfo :: AbstractMethodError

I have an application using Spring 3.0.5, JPA2 and Hibernate 3.6.7. Maven's handling my dependency management. Here's a pom excerpt:
<properties>
<spring.version>3.0.5.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
...
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-hibernate3</artifactId>
<version>2.0.8</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.7.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.7.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jpa</artifactId>
<version>2.0.8</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hibernate.java-persistence</groupId>
<artifactId>jpa-api</artifactId>
<version>2.0-cr-1</version>
<scope>compile</scope>
</dependency>
...
The application builds just fine, however, when trying to load it, the Tomcat container complains about the following:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError: org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
Any thoughts on what could be causing this? All the dependencies appear to be intact.
Thanks.
You are mixing artifacts from Spring 2.x and 3.x.
Replace old versions of spring-hibernate3 and spring-jpa with
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
I had exactly the same problem. I was hibernate validator (4.2), tomcat 6 and spring 3.0.6. But I also upgraded hibernate from 3.2 to 3.6, but I forgot to remove the hibernate-entitymanager.jar (which is an old hibernate jar) from the classpath.
I had a very similar problem with Hibernate 4.x, Spring 3.x, JPA 2.x, and CXF 2.7.5. I removed the reference to the spring-jpa artifact in my maven POM file, and inserted your recommended snippet. Worked magic! I no longer see the exception. Thanks!

Resources