Spring Boot dependencies DateTime serialize error - json

Well, after more than a week of looking for answers, debugging etc. I'm here to ask for help.
Case:
I want to display a LocalDateTime field with format "yyyy-MM-dd'T'HH:mm:ss", I've read about support for this using jackson-datatype-jsr310, however when including jsr310 dependency I get this exception thrown anywhere there's a DateTime type:
java.lang.NoSuchMethodError: com.fasterxml.jackson.datatype.jsr310.ser.JSR310FormattedSerializerBase.findFormatOverrides(Lcom/fasterxml/jackson/databind/SerializerProvider;Lcom/fasterxml/jackson/databind/BeanProperty;Ljava/lang/Class;)Lcom/fasterxml/jackson/annotation/JsonFormat$Value;
I've read that it has to do with version incompatibility with spring and jackson-datatype-jsr310 so I'm managing all my dependencies with spring-boot-dependencies; I even surfed into the artifact's pom and effectively jackson-datatype-jsr310 is listed there, now before you suggest removing jsr310 dependency, let me say I've already tried that and whenever I do that I can't register JavaTimeModule in my ObjectMapper, and if I don't register the module I get the DateTime object serialized in a very unconventional way (no format, just an object with properties for days, minutes months year etc). I've tried playing with different properties in the ObjectMapper configuration and nothing has got rid of that error but removing jsr310 dependency, I've also tried different versions of that dependency and nothing works. Please help me out.
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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.faintness</groupId>
<artifactId>FaintnessOnlineStore</artifactId>
<packaging>war</packaging>
<version>1</version>
<name>FaintnessOnlineStore Maven Webapp</name>
<url>http://maven.apache.org</url>
<!-- PROPERTIES -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- <springsecurity.version>4.0.1.RELEASE</springsecurity.version>-->
<plugin.war.warName>${project.build.finalName}</plugin.war.warName>
<maven.test.skip>true</maven.test.skip>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.4.6.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<!-- all spring security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<!-- <version>${springsecurity.version}</version> -->
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<!-- <version>${springsecurity.version}</version> -->
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<!-- <version>${springsecurity.version}</version> -->
</dependency>
<!-- basic spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<!-- <version>4.3.7.RELEASE</version> -->
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<!-- <version>4.3.7.RELEASE</version> -->
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<!-- <version>4.3.7.RELEASE</version> -->
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<!-- <version>4.3.7.RELEASE</version> -->
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<!-- <version>4.3.7.RELEASE</version> -->
</dependency>
<!-- spring web -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<!-- <version>4.3.7.RELEASE</version> -->
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<!-- <version>4.3.7.RELEASE</version> -->
</dependency>
<dependency>
<groupId>org.springframework.mobile</groupId>
<artifactId>spring-mobile-device</artifactId>
<!-- <version>1.1.5.RELEASE</version> -->
</dependency>
<!-- mysql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
</dependency>
<!-- Serialization -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<!-- <version>${jackson.version}</version> -->
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-csv</artifactId>
<!-- <version>${jackson.dataformat.csv.version}</version> -->
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<!-- <version>3.6.8.Final</version> -->
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.7.0</version>
</dependency>
<!-- JUnit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<!-- <version>4.3.7.RELEASE</version> -->
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<!-- <version>5.2.4.Final</version> -->
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<!-- <version>3.0.1-b08</version> -->
</dependency>
<!-- extra -->
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.6</version>
</dependency>
<!-- Support for LocalDateTime and ZonedDateTime data conversion in SQL -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-java8</artifactId>
<!-- <version>5.0.4.Final</version> -->
</dependency>
</dependencies>
<build>
<finalName>FaintnessOnlineStore</finalName>
<!-- PLUGINS -->
<plugins>
<!-- configure WAR stuff etc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
<warName>${plugin.war.warName}</warName>
</configuration>
</plugin>
<!-- this is important!! -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- jboss plugin important too!! -->
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.9.Final</version>
<configuration>
<filename>${project.artifactId}-${project.version}.ear</filename>
<port>8999</port> <!-- you change it following what you have on your server config -->
<filename>${plugin.war.warName}.${project.packaging}</filename>
</configuration>
</plugin>
</plugins>
</build>
</project>
ObjectMapper
package com.pier.config;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
#Component
public class SpecObjectMapper extends ObjectMapper{
public SpecObjectMapper(){
registerModule(new JavaTimeModule() );
configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,true)
.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false)
.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE);
}
}
WebConfiguration
package com.pier.config;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.PropertySource;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.mobile.device.DeviceWebArgumentResolver;
import org.springframework.mobile.device.site.SitePreferenceWebArgumentResolver;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.ServletWebArgumentResolverAdapter;
#EnableWebMvc
#Configuration
#ComponentScan(basePackages={"com.pier.controllers.*", "com.pier.config, com.pier.model.security", "com.pier.rest,com.pier.security.*"})
public class WebConfiguration extends WebMvcConfigurerAdapter {
#Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/pages/**")
.addResourceLocations("/pages/");
}
#Override
public void addArgumentResolvers(
List<HandlerMethodArgumentResolver> argumentResolvers) {
// Adding Spring mobile argument resolvers
argumentResolvers.add(
new ServletWebArgumentResolverAdapter(
new DeviceWebArgumentResolver()));
argumentResolvers.add(
new ServletWebArgumentResolverAdapter(
new SitePreferenceWebArgumentResolver()));
}
#Autowired
SpecObjectMapper domainMapper;
#Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters)
{
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setObjectMapper(domainMapper);
converters.add(converter);
super.configureMessageConverters(converters);
}
}
The entity to serialize
#Entity
#Table(name="PROMOTION")
public class Promotion implements ObjectModel<Long>{
#Id
#GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
#Column(name="DISPLAY_NAME",length=30)
#Size(min=5,max=30)
private String displayName;
#Column(name = "START_DATE")
#Type(type="org.hibernate.type.ZonedDateTimeType")
private ZonedDateTime startDate;
#Column(name = "END_DATE")
#Type(type="org.hibernate.type.ZonedDateTimeType")
private ZonedDateTime endDate;
Update:
I got another clue and got this on the console: ModuleClassLoader for Module "com.fasterxml.jackson.core.jackson-databind:main" from local module loader #15b3e5b (finder: local module finder #61ca2dfa (roots: C:\Users\PC\EAP-7.0.0\modules,C:\Users\PC\EAP-7.0.0\modules\system\layers\base))
So now I know what's going on, the version is outdated in jboss modules, I need to exclude it or find a way to load it from my classpath rather than the module.

Okay I finally got it thanks to Jboss docs and this answer: How to exclude Jackson on WildFly 9, I hope this helps in case someone runs into the same issue. (this was on Jboss EAP 7, I seriously think they should upgrade their jackson version)
Refer to Class loading and Modules Jboss EAP 7 on section 3.4 to exclude a module.
My jboss-deployment-structure looks like this:
<deployment>
<exclusions>
<module name="com.fasterxml.jackson.core.jackson-core" />
<module name="com.fasterxml.jackson.core.jackson-databind" />
<module name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider" />
<module name="org.jboss.resteasy.resteasy-jackson2-provider" />
</exclusions>
</deployment>

The current (non-accepted) answer is what finally fixed it for me, but I thought I would include a more updated version:
I was attempting to use Jackson 2.9.5 and was getting the noSuchMethodError exception as well. After stumbling across this answer I finally found out that I had to exclude these modules.
Here is what my jboss-deployment-structure.xml file looks like. Note that this is within the /src/main/webapp/WEB-INF folder.
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclusions>
<module name="com.fasterxml.jackson.core.jackson-core"/>
<module name="com.fasterxml.jackson.core.jackson-databind"/>
<module name="com.fasterxml.jackson.core.jackson-annotations"/>
<module name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider"/>
<module name="org.jboss.resteasy.resteasy-jackson-provider"/>
<module name="org.jboss.resteasy.resteasy-jackson2-provider"/>
</exclusions>
</deployment>
</jboss-deployment-structure>

Related

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured (MySQL)

I'm working on a Spring Boot(+JPA/Hibernate) application using MySQL. Running it, I get this:
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
This is my application.properties file (the last one is used for injecting in the other module):
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/mydbtest
spring.datasource.username=root
spring.datasource.password=123123
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
rest.url=http://localhost:8080/api/v1/users
My main class:
#SpringBootApplication
public class RunApp {
public static void main(String[] args) {
SpringApplication.run(RunApp.class, args);
}
Dependencies:
<dependencies>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.7.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.7.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.29</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.persistence/javax.persistence-api -->
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
What should I do to solve this?
You can try the driver class: spring.datasource.driver-class-name=com.mysql.jdbc.Driver
The reason was that the packaging attribute was pom. So I changed that into war
<packaging>war</packaging>
And it worked.

DataSource error with Springboot

I have an issue when running a spring boot project of mine:
I am using Vaadin for UI and Maven for dependecies. The Database is a MySQL one and I have followed the instructions from (https://spring.io/guides/gs/accessing-data-mysql/) closely.
Description:
Parameter 0 of constructor in
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
required a bean of type 'javax.sql.DataSource' that could not be
found.
- Bean method 'dataSource' not loaded because #ConditionalOnProperty (spring.datasource.jndi-name) did not find property 'jndi-name'
- Bean method 'dataSource' not loaded because #ConditionalOnBean (types: org.springframework.boot.jta.XADataSourceWrapper;
SearchStrategy: all) did not find any beans
Action:
Consider revisiting the conditions above or defining a bean of type
'javax.sql.DataSource' in your configuration.
With --debug:
Full auto-configuration report (too long for this post)
https://pastebin.com/DEsAkpLi
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>ethereum</groupId>
<artifactId>TradeSafe</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>TradeSafe</name>
<description>TradeSafe WebService</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.web3j</groupId>
<artifactId>web3j-spring-boot-starter</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>8.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</repository>
<repository>
<id>org.jboss.repository.releases</id>
<name>JBoss Maven Release Repository</name>
<url>https://repository.jboss.org/nexus/content/repositories/releases</url>
</repository>
</repositories>
</project>
TradeLayout.java
package ethereum.tradesafe;
import java.util.List;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.ui.GridLayout;
#SpringComponent
public class TradeLayout extends GridLayout{
#Autowired
private TradeRepo repo;
#PostConstruct
void init() {
update();
}
private void setTrades(List<Trade> trades) {
removeAllComponents();
trades.forEach(trade-> addComponent(new TradeItemLayout(trade)));
}
public Object add(Trade trade) {
repo.save(trade);
update();
return null;
}
private void update() {
setTrades((List<Trade>) repo.findAll());
}
}
TradeRepo.java
package ethereum.tradesafe;
import org.springframework.data.repository.CrudRepository;
public interface TradeRepo extends CrudRepository<Trade, Long>{
}
application.properties
spring.jpa.hibernate.ddl-auto=none
spring.datasource.url=jdbc:mysql://nottheproblem/db_tradesafe
spring.datasource.username=nottheproblem
spring.datasource.password=nottheproblem
Try to add #Repository annotation above the TradeRepo, and also rename it to TradeRepository
Solved this error by adding (missing in my case) maven dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

Spring boot, mvc, hibernate and mysql configuration - sessionFactory error

I am new in spring boot. I want to configure spring boot with mysql, hibernate, jpa and jsp. When i want to start it i gen an error: "Error creating bean with name 'sessionFactory' etc.", more in stacktrace:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/budget/configs/DatabaseConfig.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Class name must not be null
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1583) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:732) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
at com.budget.HomeBudgetApplication.main(HomeBudgetApplication.java:15) [classes/:na]
Caused by: java.lang.IllegalArgumentException: Class name must not be null
at org.springframework.util.Assert.notNull(Assert.java:115) ~[spring-core-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.util.ClassUtils.convertClassNameToResourcePath(ClassUtils.java:960) ~[spring-core-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.scanPackages(LocalSessionFactoryBuilder.java:282) ~[spring-orm-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:434) ~[spring-orm-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1642) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
... 16 common frames omitted
pom.xml `4.0.0
<groupId>com.budget</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>homeBudget</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-el</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate.javax.persistence/hibernate-jpa-2.1-api -->
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<packaging>war</packaging>
`
HomeBudgetApplication.java
#Configuration
#EnableAutoConfiguration()
#ComponentScan({"com.budget.*"})
public class HomeBudgetApplication {
public static void main(String[] args) {
SpringApplication.run(HomeBudgetApplication.class, args);
}
}
DatabaseConfig.java
#Configuration
#ComponentScan("com.budget.*")
#EnableWebMvc
#EnableTransactionManagement
#PropertySource("classpath:application.properties")
public class DatabaseConfig extends WebMvcConfigurerAdapter {
#Autowired
private Environment env;
#Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(env.getProperty("spring.datasource.driverClassName"));
dataSource.setUrl(env.getProperty("spring.datasource.url"));
dataSource.setUsername(env.getProperty("spring.datasource.username"));
dataSource.setPassword(env.getProperty("spring.datasource.password"));
return dataSource;
}
#Bean
public LocalSessionFactoryBean sessionFactory() {
LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
sessionFactoryBean.setDataSource(dataSource());
sessionFactoryBean.setPackagesToScan(env.getProperty("com.budget.*"));
sessionFactoryBean.setHibernateProperties(hibProperties());
return sessionFactoryBean;
}
private Properties hibProperties() {
Properties properties = new Properties();
properties.put("spring.jpa.database-platform", env.getProperty("spring.jpa.database-platform"));
properties.put("spring.jpa.hibernate.ddl-auto", env.getProperty("spring.jpa.hibernate.ddl-auto"));
properties.put("spring.jpa.show-sql", env.getProperty("spring.jpa.show-sql"));
return properties;
}
#Bean
public HibernateTransactionManager transactionManager() {
HibernateTransactionManager transactionManager = new HibernateTransactionManager();
transactionManager.setSessionFactory(sessionFactory().getObject());
return transactionManager;
}
#Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/jsp/");
resolver.setSuffix(".jsp");
return resolver;
}
}
application.properties
'spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url = jdbc:mysql://localhost:3306/budget
spring.datasource.username=marcin
spring.datasource.password=marcin123
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
entitymanager.packages.to.scan=com.budget'
First use the framework and not work around the framework. You also state you want to use Spring Boot and JPA but your configuraiton shows you are trying very hard not to use Spring Boot and that you don't use JPA but plain hibernate.
First remove your DatabaseConfig. (Yes remove it).
Move your HomeBudgetApplication to com.bugdet and remove all annotations and replace with a simple #SpringBootApplication.
#SpringBootApplication
public class HomeBudgetApplication {
public static void main(String[] args) {
SpringApplication.run(HomeBudgetApplication.class, args);
}
}
In your application.properties add spring.mvc.view properties to have the InternalResourceViewResolver automatically configured. ALso remove the entitymanager.packages.to.scan as that is added for you already.
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url = jdbc:mysql://localhost:3306/budget
spring.datasource.username=marcin
spring.datasource.password=marcin123
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
Everything else will be configured by Spring Boot. It will detect your web, jpa and transactions and will automatically configure it.
If you have any repository etc. based on SessionFactory replace it to work on the EntityManager instead.
You scan the packages twice on HomeBudgetApplication and DatabasebaseConfig.
Delete componenet scan on DatabasebaseConfig.
Good luck
<beans:bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<beans:property name="driverClassName" value="${jdbc.driverClassName}" />
<beans:property name="url" value="${jdbc.databaseurl}" />
<beans:property name="username" value="${jdbc.username}" />
<beans:property name="password" value="${jdbc.password}" />
</beans:bean>
<beans:bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<beans:property name="dataSource" ref="dataSource" />
<beans:property name="packagesToScan" value="com.kdkce.erp.entity" />
<beans:property name="hibernateProperties">
<beans:props>
<beans:prop key="hibernate.format.sql">true</beans:prop>
<beans:prop key="hibernate.hbm2ddl.auto">update</beans:prop>
<beans:prop key="hibernate.show_sql">true</beans:prop>
</beans:props>
</beans:property>
</beans:bean>
<properties>
<java-version>1.8</java-version>
<org.springframework-version>4.2.2.RELEASE</org.springframework-version>
<org.aspectj-version>1.6.10</org.aspectj-version>
<org.slf4j-version>1.6.6</org.slf4j-version>
<hibernate-version>5.0.2.Final</hibernate-version>
<spring-security-version>3.2.8.RELEASE</spring-security-version>
<mysql-version>5.1.9</mysql-version>
</properties>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-version}</version>
</dependency>
<!-- new dependency added for spring jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate-version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate-version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-orm -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.8.8</version>
</dependency>
<!-- Spring Security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring-security-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring-security-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${spring-security-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>${spring-security-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.1</version>
</dependency>

Apache Camel is waiting for namespace handlers

I am trying to implement Apache Camel router for message signatures as described on the Apache Cookbook there:
https://github.com/CamelCookbook/camel-cookbook-examples/blob/master/camel-cookbook-security/src/main/resources/META-INF/spring/signatures-context.xml
I am using Karaf 5.7.0 (Part of Talend ESB) and Camel 2.12.1
The camel-crypto bundle have dependency on "spring-crypto-utils" (http://springcryptoutils.com/) thas has been added to Blueprint configuration according to the Camel Cookbook example.
There is my blueprint config:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xmlns:crypt="http://springcryptoutils.com/schema/crypt"
default-activation="eager"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://cxf.apache.org/blueprint/jaxws http://cxf.apache.org/schemas/blueprint/jaxws.xsd
http://springcryptoutils.com/schema/crypt http://springcryptoutils.com/schema/crypt.xsd
">
<cm:property-placeholder persistent-id="mock.jms"
update-strategy="reload" placeholder-prefix="jms:${">
<cm:default-properties>
<cm:property name="broker" value="tcp://localhost:61616" />
<cm:property name="destinationstd" value="stdlog" />
<cm:property name="destinationsat" value="satlog" />
</cm:default-properties>
</cm:property-placeholder>
<!-- Camel route -->
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="jms:${broker}" />
</bean>
<bean id="processor" class="mock.jms.Processor" />
<crypt:keystore id="keyStore"
location="classpath:keystore.jks"
password="keystorePassword"/>
<crypt:keystore id="trustStore"
location="classpath:truststore.jks"
password="truststorePassword"/>
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri="activemq:topic:stdlog" />
<log message="MessageId: ${in.header.JMSMessageID}"/>
<!-- <to uri="log:cz.icz.kbe?level=ERROR"/> -->
<to uri="log:cz.icz.kbe?showHeaders=true test"/>
<choice>
<when>
<simple>${body} regex '(?is).*EventMarker.*:.*Audit.*'</simple>
<bean ref="processor" />
<to uri="activemq:topic:satlog" />
</when>
</choice>
</route>
</camelContext>
<!-- End Camel route -->
</blueprint>
I am trying to implement very simple Camel route that filters messages from ActiveMQ that fits to the provided regex and add SHA1WithRSA signature to the message header (camel-crypto functionality) but when I simply added tags to load keystore content (this keystores will be later used for signatures) the bundle cannot start and hangs in GracePeriod with log message:
2015-06-02 18:25:35,172 | INFO | Refresh Packages | e.aries.blueprint.container.BlueprintContainerImpl 307 | 11 - org.apache.aries.blueprint.core - 1.2.0 | Bundle jms is waiting for namespace handlers [http://springcryptoutils.com/schema/crypt]
It seems that camel cannot find namespace handler for "springcryptoutils" namespace. The code compiles correctly and correctly generates bundle, the problem occurs during deployment in karaf (manual deployment using /deploy folder). The karaf does not complain with dependencies of my bundle, the karaf command "headers" does not show anything suspiscious:
karaf#trun> headers 292
JMS Mock (292)
--------------
Manifest-Version = 1.0
Created-By = Apache Maven Bundle Plugin
Bnd-LastModified = 1433262312090
Build-Jdk = 1.8.0_40
Built-By = belunek
Tool = Bnd-2.4.0.201411031534
Bundle-Blueprint = OSGI-INF/blueprint/jms.cli.xml
Bundle-ManifestVersion = 2
Bundle-SymbolicName = jms
Bundle-Version = 1.0.0
Bundle-Name = JMS Mock
Export-Package =
mock.jms;version=1.0.0,
mock.jms.cli;version=1.0.0
Import-Package =
org.apache.felix.gogo.commands;version="[0.10,1)",
org.apache.karaf.shell.console;version="[2.3,3)",
com.fasterxml.jackson.databind;version="[2.2,3)",
javax.jms,
org.apache.activemq,
org.apache.activemq.camel.component,
org.apache.camel;version="[2.12,3)",
org.osgi.service.blueprint;version="[1.0.0,2.0.0)",
org.slf4j,
org.apache.felix.service.command;status=provisional;version="[0.10,1)"
Please any ideas where the problem is?
Edited:
I installed all necessary bundles by simple puttng jars into karaf deploy directory. The goal was to install camel-crypto and all dependecies required by this bundle.
Theres is list of aditional deployed JARs:
activemq-camel-5.7.0.jar
bcpg-jdk15on-1.52.jar
bcprov-jdk15on-1.52.jar
camel-crypto-2.12.1.jar
spring-crypto-utils-1.4.0.jar
There is complete POM listing - contains some non necessary parts due to my tries and fails
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mock.jms</groupId>
<artifactId>jms</artifactId>
<version>1.0.0</version>
<packaging>bundle</packaging>
<name>JMS Mock</name>
<properties>
<osgi.version>4.3.1</osgi.version>
<bundle-plugin.version>2.4.0</bundle-plugin.version>
<karaf.version>2.3.1</karaf.version>
<activemq.version>5.7.0</activemq.version>
<camel.version>2.12.1</camel.version>
<jackson.version>2.2.2</jackson.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>${osgi.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>${osgi.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.console</artifactId>
<version>${karaf.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.commands</artifactId>
<version>${karaf.version}</version>
<scope>provided</scope>
</dependency>
<!--suppress NonOsgiMavenDependency -->
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>${activemq.version}</version>
<scope>provided</scope>
</dependency>
<!--suppress NonOsgiMavenDependency -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel.version}</version>
<scope>provided</scope>
</dependency>
<!--suppress NonOsgiMavenDependency -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-crypto</artifactId>
<version>${camel.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>${camel.version}</version>
<scope>provided</scope>
</dependency>
<!--suppress NonOsgiMavenDependency -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-xmlsecurity</artifactId>
<version>${camel.version}</version>
<type>bundle</type>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jasypt</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-security</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>4.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.0.0.RELEASE</version>
</dependency>
<!--suppress NonOsgiMavenDependency -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
<scope>provided</scope>
</dependency>
<!--suppress NonOsgiMavenDependency -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<scope>provided</scope>
</dependency>
<!--suppress NonOsgiMavenDependency -->
<dependency>
<groupId>com.google.code.spring-crypto-utils</groupId>
<artifactId>spring-crypto-utils</artifactId>
<version>1.4.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<version>${bundle-plugin.version}</version>
<dependencies>
<dependency>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bndlib</artifactId>
<version>2.4.0</version>
</dependency>
</dependencies>
<configuration>
<instructions>
<_nouses>true</_nouses>
<_noee>true</_noee>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.name}</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
<Import-Package>
org.apache.felix.service.command,
org.apache.felix.gogo.commands,
org.apache.karaf.shell.console,
*
</Import-Package>
<Export-Package>
mock.jms*;version=${project.version}
</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

Arquillian: Attempted to register the same Observer, ServerSetupObserver multiple times

I am trying to configure arquillian with wildfly but am the following Getting error in the process of running test:
java.lang.RuntimeException: Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:165).......
Caused by: java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
...........
Caused by: java.lang.RuntimeException: Could not create new instance of class org.jboss.arquillian.core.impl.ManagerImpl
at org.jboss.arquillian.core.spi.SecurityActions.newInstance(SecurityActions.java:165)
at .................
Caused by: java.lang.reflect.InvocationTargetException: null
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 ...............
Caused by: java.lang.RuntimeException: Could not create and process manager
at org.jboss.arquillian.core.impl.ManagerImpl.<init>(ManagerImpl.java:105)......
Caused by: java.lang.IllegalArgumentException: Attempted to register the same Observer: org.jboss.as.arquillian.container.ServerSetupObserver multiple times, please check classpath for conflicting jar versions
at org.jboss.arquillian.core.impl.ManagerImpl$2.observer(ManagerImpl.java:354)
at org.jboss.arquillian.core.impl.loadable.LoadableExtensionLoader$1.observer(LoadableExtensionLoader.java:101)
at org.jboss.as.arquillian.container.CommonContainerExtension.register(CommonContainerExtension.java:41)
at org.jboss.as.arquillian.container.remote.RemoteContainerExtension.register(RemoteContainerExtension.java:33)
pom.xml
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- maven-compiler-plugin -->
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
<!-- build details -->
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
<build_version>${project.version}</build_version>
<build_number>00001</build_number>
<!-- dependency version variables -->
<struts2.version>2.3.24</struts2.version>
<hibernate.version>4.3.9.Final</hibernate.version>
<resteasy.version>3.0.11.Final</resteasy.version>
<apache.common.version>3.3.2</apache.common.version>
<junit-version>4.12</junit-version>
<arquillian-version>1.1.8.Final</arquillian-version>
<arquillian-transaction-version>1.0.1.Final</arquillian-transaction-version>
<arquillian-wildfly-version>8.2.0.Final</arquillian-wildfly-version>
</properties>
<repositories>
<repository>
<id>JBoss Repository</id>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-7.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- -JUNIT-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
</dependency>
<!-- Arquillian itself-->
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${arquillian-version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<!-- this is in an extention to arquillian it is optional-->
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-transaction-bom</artifactId>
<version>${arquillian-transaction-version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- this is container adapter for wildfly-->
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-embedded</artifactId>
<version>${arquillian-wildfly-version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>1.1.8.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-embedded</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-transaction-jta</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core</artifactId>
<version>1.1.5.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.4</version>
<scope>test</scope>
</dependency>
<!-- struts 2 dependencies -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>
<!-- Import the CDI API -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-cdi-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.2</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<!-- Import the Common Annotations API (JSR-250) -->
<dependency>
<groupId>org.jboss.spec.javax.annotation</groupId>
<artifactId>jboss-annotations-api_1.2_spec</artifactId>
</dependency>
<!-- Import the Servlet API -->
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<!-- Jboss weld -->
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core</artifactId>
<version>2.2.2.Final</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>fms</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.0.0.Final</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugin</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<!-- An optional Arquillian testing profile that executes tests in your
Wildfly instance -->
<!-- This profile will start a new Wildfly instance, and execute the
test, shutting it down when done -->
<!-- Run with: mvn clean test -Parq-wildfly-managed -->
<id>arq-wildfly-managed</id>
<dependencies>
<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<version>1.0.0.Alpha5</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
<profile>
<!-- An optional Arquillian testing profile that executes tests in a remote
Wildfly instance -->
<!-- Run with: mvn clean test -Parq-wildfly-remote -->
<id>arq-wildfly-remote</id>
<dependencies>
<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-remote</artifactId>
<version>1.0.0.Alpha5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>development</id>
<properties>
<env>development</env>
<fms.restws.url>http://localhost:8080/fms/rs/json</fms.restws.url>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<env>prod</env>
<fms.restws.url>http://prodserver:8080/fms/rs/json</fms.restws.url>
</properties>
</profile>
</profiles>
GreeterTest.java
#RunWith(Arquillian.class) public class GreeterTest {
#Inject
Greeter greeter;
#Deployment
public static Archive<?> createDeployment() {
return ShrinkWrap.create(WebArchive.class, "fms-tes.war")
.addClass(Greeter.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
#Test
public void should_create_greeting() throws Exception {
Assert.assertEquals("Hello, Earthling!",greeter.createGreeting("Earthling"));
greeter.greet(System.out, "Earthling");
} }
Remove the dependencyManagement and dependency definition for org.wildfly:wildfly-arquillian-container-embedded. You have setup profiles using the org.wildfly.arquillian:xxxx adaptors as well. They are technically very similar but are intended for two different versions of the WildFly server. Being based on the same code base they both attempt to register the same observers.