I try to use a Vaadin 14 application as a dependency for a Spring Boot Project. The Vaadin project uses a single View and an embedded Tomcat and runs fine. pom.xml of the project:
...
<groupId>my.package</groupId>
<artifactId>my-artifact</artifactId>
...
...
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
...
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
<exclusions>
<!-- Excluding so that webjars are not included. -->
<exclusion>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<version>2.6.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>2.6.6</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.6.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-testbench</artifactId>
<scope>test</scope>
</dependency>
...
<build>
<defaultGoal>spring-boot:run</defaultGoal>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- Clean build and startup time for Vaadin apps sometimes may exceed
the default Spring Boot's 30sec timeout. -->
<configuration>
<wait>500</wait>
<maxAttempts>240</maxAttempts>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
So I basically tried to add a classifier to the spring-boot-maven-plugin of the application like stated here.
And when I run mvn install I get the two jars as I expect.
Now, I create a new Spring Application and import the dependency in the pom.xml:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>my.package</groupId>
<artifactId>my-artifact</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Now, when I try to run the app I get this error message:
Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'formContentFilter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.filter.OrderedFormContentFilter]: Factory method 'formContentFilter' threw exception; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.fasterxml.jackson.datatype.jsr310.JavaTimeModule]: Unresolvable class definition; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase
Is it even possible to have a Vaadin project as a dependency? If yes, what I am missing - can someone help me out?
Spring Boot applications have a different JAR layout and cannot be used as dependencies.
Related
I'm trying to add liquibase-mongodb dependency to my spring-boot project
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-jdbc</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-mongodb</artifactId>
<version>4.18.0</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.8.1</version>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
<jvmArguments>-Dfile.encoding=UTF8</jvmArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>4.17.2</version>
<configuration>
<outputDefaultSchema>true</outputDefaultSchema>
</configuration>
</plugin>
</plugins>
</build>
I'm getting the error with the start of my app:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: liquibase.util.StringUtil
I don't use the StringUtil in my project and I don't understand the reason. What must it be and how to solve it?
I am trying to connect to minio server by using minio client in spring boot. Getting this error:
An attempt was made to call a method that does not exist. The attempt
was made from the following location:
io.minio.S3Base.<clinit>(S3Base.java:104)
The following method did not exist:
okhttp3.RequestBody.create([BLokhttp3/MediaType;)Lokhttp3/RequestBody;
The method's class, okhttp3.RequestBody, is available from the
following locations:
jar:file:/home/user/.m2/repository/com/squareup/okhttp3/okhttp/3.14.4/okhttp-3.14.4.jar!/okhttp3/RequestBody.class
It was loaded from the following location:
file:/home/user/.m2/repository/com/squareup/okhttp3/okhttp/3.14.4/okhttp-3.14.4.jar
Action:
Correct the classpath of your application so that it contains a
single, compatible version of okhttp3.RequestBody
Process finished with exit code 0
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>com.tigerit.tigerhrm</groupId>
<artifactId>tigerit-hrm-api</artifactId>
<version>beta-1.4.0</version>
<!--<packaging>jar</packaging>-->
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.RELEASE</version>
<!-- <!– https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent –>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>-->
</parent>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<other lib versions here>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
//some_dependecies are removed to reduce the file size
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${logger.version}</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.minio/minio-->
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.3.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.14.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources</outputDirectory>
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I am using java 8.
I tried without com.squareup.okhttp3 dependency added in the pom.xml file too. Not working for both cases.
Solution:
Try overriding the okhttp3.version property in your pom and set it to a newer version of the com.squareup.okhttp3:okhttp dependency (4.10.0 works for me). Or just explicitly set this dependency yourself.
Or rather, if at all feasible, try updating your starter-parent version (not sure if this would work with java 8 though).
Reasoning:
The reason for maven (or, in my case, gradle) fetching an older version of okhttp library is the unfortunate pinning of this particular library version in spring boot dependencies in versions before 2.7:
<okhttp3.version>3.14.9</okhttp3.version>
In 2.7 they changed it to 4.9.3.
After deploying my spring boot on google cloud platform app engine 'standard', and then try to visit the website I get Error: Server Error in browser. Then I visit the log on google cloud I get error:
"logMessage": "org.eclipse.jetty.annotations.ServletContainerInitializersStarter doStart: \norg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to open JDBC Connection for DDL execution\n\tat
I tried to change the datasourceurl multiple time, but still not succeeded yet.
My properties file:
spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp
database=mysql
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://google/myBlog?cloudSqlInstance=reviewcontainerblog&socketFactory=com.google.cloud.sql.mysql.SocketFactory
spring.datasource.username=user
spring.datasource.password=password
#JPA
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.database-platform=org.hibernate.dialect.MySQL57InnoDBDialect
my pom file :
<?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>
<packaging>war</packaging>
<groupId>com.reviewcontainer</groupId>
<artifactId>ReviewContainer</artifactId>
<version>0.0.3-SNAPSHOT</version>
<name>ReviewContainer</name>
<description>Review Container is Blog App</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<start-class>com.reviewcontainer.Application</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<!--Exclude the Tomcat dependency-->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-el</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-autoconfigure -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<!--tomcat embed jasper help REST to be converted to JSP-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
<version>8.0.16</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.webjars/jquery -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.3.1-1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.webjars/bootstrap -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>4.2.1</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.cloud.sql/mysql-socket-factory -->
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory</artifactId>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<!--Spring JDBC, Cloud GCP SQL Starter -->
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-jdbc -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>2.1.5.RELEASE</version>
</dependency>
</dependencies>
<build>
<finalName>ReviewContainer</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<mainClass>${start-class}</mainClass>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>2.0.0</version>
<configuration>
<deploy.projectId>reviewcontainer</deploy.projectId>
<deploy.version>rc-003-snapshot</deploy.version>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archiveClasses>true</archiveClasses>
<webResources>
<resource>
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
<filtering>true</filtering>
<targetPath>WEB-INF</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</project>
"logMessage": "org.eclipse.jetty.annotations.ServletContainerInitializersStarter doStart: \norg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to open JDBC Connection for DDL execution\n\tat
I believe your problem is located on properties file:
spring.datasource.url=jdbc:mysql://google/myBlog?cloudSqlInstance=reviewcontainerblog&socketFactory=com.google.cloud.sql.mysql.SocketFactory
If you check here on google's community tutorial and at Google Cloud Platform's Github page on "Creating the JDBC URL" :
spring.datasource.url=jdbc:mysql://google/petclinic?cloudSqlInstance=INSTANCE_CONNECTION_NAME&socketFactory=com.google.cloud.sql.mysql.SocketFactory
jdbc:mysql://google/<DATABASE_NAME>?cloudSqlInstance=<INSTANCE_CONNECTION_NAME>&socketFactory=com.google.cloud.sql.mysql.SocketFactory&useSSL=false&user=<MYSQL_USER_NAME>&password=<MYSQL_USER_PASSWORD>
So, it is the Instance Connection Name and NOT the instance name. You can check this documentation from Google community tutorials which is quick helpful even if is for Flexible environment. Try it and let me know.
You can also check this article which provides some other workaround on how to connect to CloudSQL from your Spring Application
I am new to Apache Spark. I am trying to execute simple spring boot application using Spark but I am getting the exception.
ERROR ApplicationMaster: User class threw exception:
java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication
However, i am able to execute this project perfectly file from my Eclipse IDE.It is executing the soul which I have kept.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency> <!-- Spark -->
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>1.4.0</version>
</dependency>
<dependency> <!-- Spark SQL -->
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.10</artifactId>
<version>1.4.0</version>
</dependency>
<dependency> <!-- Spark SQL -->
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-scala_2.10</artifactId>
<version>2.6.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
And my main spring boot class is
#SpringBootApplication
public class SparkS3Application {
public static void main(String[] args) {
SpringApplication.run(SparkS3Application.class, args);
System.out.println(" *************************** called *******************");
}
}
I added the required dependency in my spark submit command only using --jars "jar path,another jar path". You need to provide all the jars comma separated after
--jars.
Second thing is try to execute this in spark 2.0 I was using park 1.6 and i was facing issue but it is working perfectly fine with spark 2.0.
Hope this will help you guys..
I modified some code in my current web project to add Spring transaction management. Everything works just fine when I deploy it in Eclipse or even when I call a "Maven clean" and a "Maven install" in my workspace. However when my continuous integration server (jenkins) tries to redeploy it on my distant server I get a java.lang.VerifyError and it fails:
maven-glassfish-plugin:2.1:deploy (default-cli) # myApp --- [INFO] asadmin --host localhost --port 4848 --user admin --passwordfile C:\Windows\TEMP\mgfp2047875868831547735.tmp --interactive=false --echo=true --terse=true deploy --name myApp --force=false --precompilejsp=false --verify=false --enabled=true --generatermistubs=false --availabilityenabled=false --keepreposdir=false --keepfailedstubs=false --logReportedErrors=true --upload=false --help=false C:\.jenkins\workspace\First_deploy\target\myApp-0.0.1.war
[ERROR] com.sun.enterprise.admin.cli.CommandException: remote failure: Exception while loading the app : java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'analysisDAO': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Post-processing of the FactoryBean's object failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.methodSecurityMetadataSourceAdvisor': Cannot resolve reference to bean 'org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource#0': Cannot create inner bean '(inner bean)' of type [org.springframework.security.access.prepost.PrePostAnnotationSecurityMetadataSource] while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot create inner bean '(inner bean)' of type [org.springframework.security.access.expression.method.ExpressionBasedAnnotationAttributeFactory] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve reference to bean 'expressionHandler' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'expressionHandler' defined in ServletContext resource [/WEB-INF/spring/security-config.xml]: Cannot resolve reference to bean 'projectPermissionEvaluator' while setting bean property 'permissionEvaluator'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'projectPermissionEvaluator': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: public fr.services.interfaces.IProjectService fr.services.security.ProjectPermissionEvaluator.projectService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'projectService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: public fr.services.interfaces.IProjectRightsService fr.services.impl.ProjectService.projectRightService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'projectRightService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: public fr.dao.IDAOFactory fr.services.impl.ProjectRightService.daoFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myAppDAOFactory': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'agriculturalToolDao' defined in ServletContext resource [/WEB-INF/spring/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.VerifyError: Expecting a stackmap frame at branch target 43 in method fr.model.application.Projet.equals(Ljava/lang/Object;)Z at offset 4
I use a jdk1.7 (I checked on my server and it's still the right JDK which is in the environment variables), maven and Glassfish. Here is my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>means</groupId>
<artifactId>means</artifactId>
<version>0.0.1</version>
<packaging>war</packaging>
<profiles>
<profile>
<id>mavenplugin-server</id>
<activation>
<property>
<name>environment</name>
<value>server</value>
</property>
</activation>
<properties>
<glassfish.home>C:\MEANS\Glassfish\glassfish</glassfish.home>
<glassfish.adminPort>4848</glassfish.adminPort>
<glassfish.httpPort>8080</glassfish.httpPort>
<glassfish.httpsPort>8443</glassfish.httpsPort>
</properties>
</profile>
<profile>
<id>mavenplugin-server-production</id>
<activation>
<property>
<name>environment</name>
<value>server-production</value>
</property>
</activation>
<properties>
<glassfish.home>C:\MEANS\Glassfish\glassfish</glassfish.home>
<glassfish.adminPort>4949</glassfish.adminPort>
<glassfish.httpPort>8282</glassfish.httpPort>
<glassfish.httpsPort>8553</glassfish.httpsPort>
</properties>
</profile>
<profile>
<id>mavenplugin-local</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<glassfish.home>C:\MEANS\Glassfish\glassfish</glassfish.home>
<glassfish.adminPort>4848</glassfish.adminPort>
<glassfish.httpPort>8080</glassfish.httpPort>
<glassfish.httpsPort>8443</glassfish.httpsPort>
</properties>
</profile>
</profiles>
<properties>
<org.springframework.version>3.0.5.RELEASE</org.springframework.version>
<eclipselink.version>2.4.0</eclipselink.version>
</properties>
<repositories>
<repository>
<id>EclipseLink Repo</id>
<url>http://download.eclipse.org/rt/eclipselink/maven.repo</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.release</id>
<name>EBR Spring Release Repository</name>
<url>http:// repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>EBR External Release Repository</name>
<url>http:// repository.springsource.com/maven/bundles/external</url>
</repository>
</repositories>
<build>
<sourceDirectory>src</sourceDirectory>
<outputDirectory>build2</outputDirectory>
<testSourceDirectory>src/test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<webXml>${basedir}\WebContent\WEB-INF\web.xml</webXml>
<warSourceExcludes>${basedir}\WebContent\*</warSourceExcludes>
<resource>
<excludes>
<directory>${basedir}/WebContent</directory>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<webResources>
<resource>
<directory>${basedir}\src\fr</directory>
<targetPath>WEB-INF\classes\fr</targetPath>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>${basedir}\build2\fr</directory>
<targetPath>WEB-INF\classes\fr</targetPath>
</resource>
<resource>
<directory>${basedir}/WebContent/WEB-INF/</directory>
<targetPath>WEB-INF/</targetPath>
<includes>
<include>dispatcher-servlet.xml</include>
</includes>
<excludes>
<exclude>log4j.properties</exclude>
</excludes>
</resource>
<resource>
<directory>${basedir}/WebContent/WEB-INF/</directory>
<targetPath>WEB-INF/</targetPath>
<includes>
<include>dispatcher-servlet.xml</include>
</includes>
</resource>
<resource>
<directory>${basedir}/WebContent/WEB-INF/</directory>
<targetPath>WEB-INF/classes/</targetPath>
<includes>
<include>log4j.properties</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/META-INF</directory>
<targetPath>WEB-INF/classes/META-INF/</targetPath>
<includes>
<include>persistence.xml</include>
</includes>
</resource>
<resource>
<directory>${basedir}/WebContent/</directory>
<targetPath></targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.1</version>
<configuration>
<argLine>-XX:-UseSplitVerifier</argLine>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.glassfish.maven.plugin</groupId>
<artifactId>maven-glassfish-plugin</artifactId>
<version>2.1</version>
<configuration>
<user>admin</user>
<echo>true</echo>
<adminPassword>means2012!</adminPassword>
<glassfishDirectory>${glassfish.home}</glassfishDirectory>
<components>
<component>
<name>${project.artifactId}</name>
<artifact>${project.build.directory}/${project.build.finalName}.war</artifact>
</component>
</components>
<domain>
<name>${project.artifactId}</name>
<adminPort>${glassfish.adminPort}</adminPort>
<httpPort>${glassfish.httpPort}</httpPort>
<httpsPort>${glassfish.httpsPort}</httpsPort>
</domain>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.11</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.11</version>
</dependency>
<!-- <dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.6.2</version>
</dependency>
-->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>${eclipselink.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.core</artifactId>
<version>${eclipselink.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>${eclipselink.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen</artifactId>
<version>${eclipselink.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>${eclipselink.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.sdo</artifactId>
<version>${eclipselink.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.oracle</artifactId>
<version>${eclipselink.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<!-- <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-asm</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Alpha1</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>maven-glassfish-plugin</artifactId>
<version>1.0-alpha-4</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>3.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-aspects</artifactId>
<version>3.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>3.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</project>
I tried to add the maven-surefire-plugin as indicated in this post: How do I get unit test to run in java 7: java.lang.VerifyError: Expecting a stackmap frame at branch target but without success... As I'm not a maven expert, it's extremely difficult to find out what is wrong in my configuration so any help would be greatly appreciated! Thanks in advance
Judging from what I'm seeing in your stack trace, I believe the application is unable to connect to the database or an LDAP. This causes the autowiring of one of the beans to fail which then cascades over into the other beans.
Ensure that the application can properly connect to any external resources required by the beans.
AFAIK, AspectJ support Java 7 only from version 1.7.0 and upwards.
You may try to upgrade your AspectJ versions from 1.6.11 to 1.7.3 (which is the lastest available).
I found your question searching for that exception related to openCSV 2.3 and Java 7. In my case the exception was thrown when instantiating by reflection a class with references to opencsv classes. Maybe you have a similar problem. I resolved mine switching to jcsv
Just in case it might help somebody some day, I solved this problem and everything works again with my app now...
The problem came from the glassfish installation so it had nothing to do with my code (even if this weird "VerrifyError" pointed out some code line). I found out that if I deployed it on another glassfish it worked so I re-installed my Glassfish server and my problem was solved! Too bad I spent more than a week on that... Thanks for your help anyway!
I have resolved this issue by changing application class loader to "PARENT LAST".
Application-->Enterprise Application --> --classloader mode =PARENT LAST