10

I have a vanilla spring boot app that consists of the following 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>xxx.alexius</groupId>
    <artifactId>myapp</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>my app</name>
<description>Core Application Platform</description>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.2.2.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.7</java.version>
</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-data-mongodb</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-mobile</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-social-facebook</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-social-twitter</artifactId>
    </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>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.4-1201-jdbc41</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <compilerArgument>-Xlint:all</compilerArgument>
                <showWarnings>true</showWarnings>
                <showDeprecation>true</showDeprecation>
            </configuration>
        </plugin>
    </plugins>
</build>

When I deploy this to a Tomcat everything works fine but when I try to deploy this on a Glassfish 4.1 server I get the following error

SEVERE:   Class [ liquibase/integration/spring/SpringLiquibase ] not found. Error while loading [ class org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration ]
SEVERE:   Exception while deploying the app [platform]
SEVERE:   Exception during lifecycle processing
java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy

Any ideas on what is going wrong? Is it a Spring or Glassfish bug?

Alexius DIAKOGIANNIS
  • 2,465
  • 2
  • 21
  • 32
  • is http://mvnrepository.com/artifact/org.liquibase/liquibase-core/3.2.2 in your classpath? – px5x2 Apr 03 '15 at 11:48
  • Well its not its my pom so probably not but the spring-boot should have all dependencies needed in its pom. The rest of the project just an empty project and has no extra code. Just need to deploy it with no functionality so I can start working on it. – Alexius DIAKOGIANNIS Apr 03 '15 at 11:56
  • execute mvn dependency:tree to see whether liquibase is in your classpath. – px5x2 Apr 03 '15 at 11:57
  • Spring Boot does some checking which classes are available on the class path to determine which auto configuration to apply. For this it tries to load classes and catches the `ClassNotFoundExceptions`. So I would guess that either that mechanism doesn't work in GlassFish (not sure why it should) or glass fish is broken or includes other classes which interfere with class detections or auto config. – M. Deinum Apr 03 '15 at 12:02
  • 1
    I added the dependency `org.liquibase liquibase-core 3.3.2` and now I get `SEVERE: Exception while deploying the app [platform] SEVERE: Exception during lifecycle processing java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy` – Alexius DIAKOGIANNIS Apr 03 '15 at 12:37

1 Answers1

14

It looks like this a bug in Glassfish: GLASSFISH-21265

You can try to get around that by adding metadata-complete="true" in your web.xml like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" 
         metadata-complete="true"
         xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
</web-app>

The metadata-complete="true" indicates that the JAR files in /WEB-INF/lib doesn't need to be scanned for Servlet 3.0 specific annotations, but the webapp's own classes will still be scanned.

See also:

Community
  • 1
  • 1
unwichtich
  • 13,712
  • 4
  • 53
  • 66
  • I try OK with version 1.x. But when I try with Spring Boot 2.x. It don't work. Is Glassfish Server good for Spring Boot? – Tien Nguyen Mar 19 '20 at 07:42
  • 1
    at the moment I have issues deploying Spring Boot 2 application to Glassfish 4.1.2 - probably they boil down to the fact that Glassfish uses older Jackson libraries that interfere with those that Maven/Spring Boot pack into the WAR. probably should switch to Glassfish 5, which is not an option for me – hello_earth May 12 '20 at 10:53