DefermentNL
DefermentNL

Reputation: 23

IDE fails to run spring boot invalid constant type 18

I'm currently refactoring some code parts of our backend to java 8 streams. Here i make usage of lambda's.

When i try to run the application inside my IDE i get the following error

When i run the code with the maven builder it works fine, only when i run the application inside IntelliJ it crashes. I've read somewhere else it could be my javassist. I tried excluding these from other dependencies i use, but no results :( Another topic said i have to put hamcrest dependencies on top of the pom , didn't work either..

What am i missing?

Caused by: java.lang.RuntimeException: Error while reading file:/...path to project/target/classes/
    at org.hibernate.ejb.packaging.NativeScanner.getFilesInJar(NativeScanner.java:195) ~[hibernate-entitymanager-4.2.8.Final.jar:4.2.8.Final]
    at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:506) ~[hibernate-entitymanager-4.2.8.Final.jar:4.2.8.Final]
    at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:861) ~[hibernate-entitymanager-4.2.8.Final.jar:4.2.8.Final]
    ... 23 common frames omitted
Caused by: java.io.IOException: invalid constant type: 18
    at javassist.bytecode.ConstPool.readOne(ConstPool.java:1113) ~[javassist-3.15.0-GA.jar:na]
    at javassist.bytecode.ConstPool.read(ConstPool.java:1056) ~[javassist-3.15.0-GA.jar:na]
    at javassist.bytecode.ConstPool.<init>(ConstPool.java:150) ~[javassist-3.15.0-GA.jar:na]
    at javassist.bytecode.ClassFile.read(ClassFile.java:765) ~[javassist-3.15.0-GA.jar:na]
    at javassist.bytecode.ClassFile.<init>(ClassFile.java:109) ~[javassist-3.15.0-GA.jar:na]
    at org.hibernate.ejb.packaging.AbstractJarVisitor.checkAnnotationMatching(AbstractJarVisitor.java:246) ~[hibernate-entitymanager-4.2.8.Final.jar:4.2.8.Final]
    at org.hibernate.ejb.packaging.AbstractJarVisitor.executeJavaElementFilter(AbstractJarVisitor.java:212) ~[hibernate-entitymanager-4.2.8.Final.jar:4.2.8.Final]
    at org.hibernate.ejb.packaging.AbstractJarVisitor.addElement(AbstractJarVisitor.java:173) ~[hibernate-entitymanager-4.2.8.Final.jar:4.2.8.Final]
    at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(ExplodedJarVisitor.java:126) ~[hibernate-entitymanager-4.2.8.Final.jar:4.2.8.Final]
    at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(ExplodedJarVisitor.java:134) ~[hibernate-entitymanager-4.2.8.Final.jar:4.2.8.Final]
    at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(ExplodedJarVisitor.java:134) ~[hibernate-entitymanager-4.2.8.Final.jar:4.2.8.Final]
    at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(ExplodedJarVisitor.java:134) ~[hibernate-entitymanager-4.2.8.Final.jar:4.2.8.Final]
    at org.hibernate.ejb.packaging.ExplodedJarVisitor.doProcessElements(ExplodedJarVisitor.java:92) ~[hibernate-entitymanager-4.2.8.Final.jar:4.2.8.Final]
    at org.hibernate.ejb.packaging.AbstractJarVisitor.getMatchingEntries(AbstractJarVisitor.java:149) ~[hibernate-entitymanager-4.2.8.Final.jar:4.2.8.Final]
    at org.hibernate.ejb.packaging.NativeScanner.getFilesInJar(NativeScanner.java:192) ~[hibernate-entitymanager-4.2.8.Final.jar:4.2.8.Final]
    ... 25 common frames omitted

My pom:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.0.BUILD-SNAPSHOT</version>
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>

</properties>

<repositories>
...
</repositories>
<pluginrepositories>
...
</pluginrepositories>

<dependencies>
    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-api-mockito</artifactId>
        <version>1.6.4</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <artifactId>javassist</artifactId>
                <groupId>org.javassist</groupId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-module-junit4</artifactId>
        <version>1.6.4</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-all</artifactId>
        <version>1.3</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <artifactId>javassist</artifactId>
                <groupId>org.javassist</groupId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.16.6</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
        <version>1.3.5.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>1.3.5.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.codehaus.sonar-plugins.java</groupId>
        <artifactId>sonar-jacoco-listeners</artifactId>
        <version>1.2</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>javax.transaction</groupId>
        <artifactId>jta</artifactId>
        <version>1.1</version>
    </dependency>
    <!-- http://mvnrepository.com/artifact/org.postgresql/postgresql -->
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.4.1208</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.2.8.Final</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.2.8.Final</version>
    </dependency>

    <dependency>
        <groupId>org.javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.20.0-GA</version>
    </dependency>

<build>
    <plugins>
        <plugin>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok-maven-plugin</artifactId>
            <version>1.16.6.1</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>delombok</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

my dependency tree:

[INFO] +- org.powermock:powermock-api-mockito:jar:1.6.4:test
[INFO] |  +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] |  |  \- org.objenesis:objenesis:jar:2.1:test
[INFO] |  +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] |  \- org.powermock:powermock-api-support:jar:1.6.4:test
[INFO] |     +- org.powermock:powermock-core:jar:1.6.4:test
[INFO] |     \- org.powermock:powermock-reflect:jar:1.6.4:test
[INFO] +- org.powermock:powermock-module-junit4:jar:1.6.4:test
[INFO] |  +- junit:junit:jar:4.12:test
[INFO] |  \- org.powermock:powermock-module-junit4-common:jar:1.6.4:test
[INFO] +- org.hamcrest:hamcrest-all:jar:1.3:test
[INFO] +- org.projectlombok:lombok:jar:1.16.6:compile
[INFO] +- org.springframework.boot:spring-boot-starter-thymeleaf:jar:1.3.5.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:1.4.0.BUILD-SNAPSHOT:compile
[INFO] |  |  +- org.springframework.boot:spring-boot:jar:1.4.0.BUILD-SNAPSHOT:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:1.4.0.BUILD-SNAPSHOT:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:1.4.0.BUILD-SNAPSHOT:compile
[INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.1.7:compile
[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.1.7:compile
[INFO] |  |  |  +- org.slf4j:jul-to-slf4j:jar:1.7.21:compile
[INFO] |  |  |  \- org.slf4j:log4j-over-slf4j:jar:1.7.21:compile
[INFO] |  |  \- org.yaml:snakeyaml:jar:1.17:runtime
[INFO] |  +- org.thymeleaf:thymeleaf-spring4:jar:2.1.5.RELEASE:compile
[INFO] |  |  +- org.thymeleaf:thymeleaf:jar:2.1.5.RELEASE:compile
[INFO] |  |  |  +- ognl:ognl:jar:3.0.8:compile
[INFO] |  |  |  \- org.unbescape:unbescape:jar:1.1.0.RELEASE:compile
[INFO] |  |  \- org.slf4j:slf4j-api:jar:1.7.21:compile
[INFO] |  \- nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:jar:1.4.0:compile
[INFO] |     \- org.codehaus.groovy:groovy:jar:2.4.7:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.3.5.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.4.0.BUILD-SNAPSHOT:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.4:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.4:compile
[INFO] |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.4:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-validation:jar:1.4.0.BUILD-SNAPSHOT:compile
[INFO] |  |  \- org.hibernate:hibernate-validator:jar:5.2.4.Final:compile
[INFO] |  |     +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] |  |     \- com.fasterxml:classmate:jar:1.3.1:compile
[INFO] |  +- org.springframework:spring-web:jar:4.3.2.BUILD-SNAPSHOT:compile
[INFO] |  |  +- org.springframework:spring-aop:jar:4.3.2.BUILD-SNAPSHOT:compile
[INFO] |  |  +- org.springframework:spring-beans:jar:4.3.2.BUILD-SNAPSHOT:compile
[INFO] |  |  \- org.springframework:spring-context:jar:4.3.2.BUILD-SNAPSHOT:compile
[INFO] |  \- org.springframework:spring-webmvc:jar:4.3.2.BUILD-SNAPSHOT:compile
[INFO] |     \- org.springframework:spring-expression:jar:4.3.2.BUILD-SNAPSHOT:compile
[INFO] +- org.codehaus.sonar-plugins.java:sonar-jacoco-listeners:jar:1.2:test
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.4.0.BUILD-SNAPSHOT:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-aop:jar:1.4.0.BUILD-SNAPSHOT:compile
[INFO] |  |  \- org.aspectj:aspectjweaver:jar:1.8.9:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.4.0.BUILD-SNAPSHOT:compile
[INFO] |  |  +- org.apache.tomcat:tomcat-jdbc:jar:8.5.4:compile
[INFO] |  |  |  \- org.apache.tomcat:tomcat-juli:jar:8.5.4:compile
[INFO] |  |  \- org.springframework:spring-jdbc:jar:4.3.2.BUILD-SNAPSHOT:compile
[INFO] |  +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] |  +- org.springframework.data:spring-data-jpa:jar:1.10.2.RELEASE:compile
[INFO] |  |  +- org.springframework.data:spring-data-commons:jar:1.12.2.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-orm:jar:4.3.2.BUILD-SNAPSHOT:compile
[INFO] |  |  +- org.springframework:spring-tx:jar:4.3.2.BUILD-SNAPSHOT:compile
[INFO] |  |  \- org.slf4j:jcl-over-slf4j:jar:1.7.21:compile
[INFO] |  \- org.springframework:spring-aspects:jar:4.3.2.BUILD-SNAPSHOT:compile
[INFO] +- javax.transaction:jta:jar:1.1:compile
[INFO] +- org.postgresql:postgresql:jar:9.4.1208:compile
[INFO] +- org.hibernate:hibernate-core:jar:4.2.8.Final:compile
[INFO] |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.1.Final:compile
[INFO] |  +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO] |  \- org.hibernate.common:hibernate-commons-annotations:jar:4.0.2.Final:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:4.2.8.Final:compile
[INFO] +- org.javassist:javassist:jar:3.20.0-GA:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.6.5:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.6.0:compile
[INFO] |  \- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
[INFO] +- com.fasterxml:jackson-xml-databind:jar:0.6.2:compile
[INFO] |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile
[INFO] |  |  \- org.codehaus.jackson:jackson-core-asl:jar:1.9.2:compile
[INFO] |  +- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile
[INFO] |  \- org.codehaus.woodstox:stax2-api:jar:3.1.0:compile
[INFO] |     \- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] +- com.mashape.unirest:unirest-java:jar:1.4.9:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.3.6:compile
[INFO] |  +- org.apache.httpcomponents:httpcore:jar:4.4.5:compile
[INFO] |  \- commons-codec:commons-codec:jar:1.10:compile
[INFO] +- org.apache.httpcomponents:httpasyncclient:jar:4.0.2:compile
[INFO] |  \- org.apache.httpcomponents:httpcore-nio:jar:4.3.2:compile
[INFO] +- org.apache.httpcomponents:httpmime:jar:4.3.6:compile
[INFO] +- org.json:json:jar:20140107:compile
[INFO] +- org.webjars:bootstrap:jar:3.3.6:compile
[INFO] |  \- org.webjars:jquery:jar:1.11.1:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.4.0.BUILD-SNAPSHOT:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:1.4.0.BUILD-SNAPSHOT:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.4.0.BUILD-SNAPSHOT:test
[INFO] |  +- com.jayway.jsonpath:json-path:jar:2.2.0:test
[INFO] |  |  \- net.minidev:json-smart:jar:2.2.1:test
[INFO] |  |     \- net.minidev:accessors-smart:jar:1.1:test
[INFO] |  |        \- org.ow2.asm:asm:jar:5.0.3:test
[INFO] |  +- org.assertj:assertj-core:jar:2.4.1:test
[INFO] |  +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] |  +- org.skyscreamer:jsonassert:jar:1.3.0:test
[INFO] |  +- org.springframework:spring-core:jar:4.3.2.BUILD-SNAPSHOT:compile
[INFO] |  \- org.springframework:spring-test:jar:4.3.2.BUILD-SNAPSHOT:test
[INFO] +- commons-io:commons-io:jar:2.4:test

Upvotes: 1

Views: 2817

Answers (1)

M. Deinum
M. Deinum

Reputation: 125038

Your pom is a bit of a mess as you are managing things that Spring Boot already manages. Next to that you are mixing 2 versions of a framework something you should never do (regardless the framework).

  1. Don't mix 1.3.5 and 1.4.0 versions of jars of Spring Boot
  2. Spring Boot manages hibernate just define the version you want to use.
  3. I prefer test dependencies to come last (and I suggest using the spring-boot-starter-test dependency instead as that also manages dependencies).
  4. Remove the hibernate and javassist dependencies (as those are managed for you)
  5. I would suggest using Mockito instead of Powermock (but that is imho and personal preference).
  6. Spring Boot also manages the postgres version so you can remove the version tag (as well as from the spring-boot dependencies you have).

Your pom should look something like this.

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    <hibernate.version>4.2.8.Final</hibernate.version>
    <powermock.version>1.6.4</powermock.version>
</properties>

Then in your dependencies do some cleaning.

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.16.6</version>
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</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-data-jpa</artifactId>
</dependency>

<!-- http://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>        
</dependency>

<!-- Dependencies for Test -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>
<dependency>    
    <groupId>org.codehaus.sonar-plugins.java</groupId>
    <artifactId>sonar-jacoco-listeners</artifactId>
    <version>1.2</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.powermock</groupId>
    <artifactId>powermock-api-mockito</artifactId>
    <version>${powermock.version}</version>
    <scope>test</scope>  
</dependency>

<dependency>
    <groupId>org.powermock</groupId>
    <artifactId>powermock-module-junit4</artifactId>
    <version>${powermock.version}</version>
    <scope>test</scope>
</dependency>

Upvotes: 3

Related Questions