无法在Glassfish 4.1上部署弹簧引导应用程序 [英] Unable to deploy Spring Boot App on Glassfish 4.1

查看:306
本文介绍了无法在Glassfish 4.1上部署弹簧引导应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个Spring Boot应用程序(webservice soap)。一切都可以,应用程序通过Spring Boot中的集成tomcat运行良好。
当我尝试打包并部署到Glassfish 4.1 ia奇怪的错误。



我的maven配置:

 <?xml version =1.0encoding =UTF-8?> 
< project xmlns =http://maven.apache.org/POM/4.0.0xmlns: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>
< parent>
<! - 您自己的应用程序应该继承自spring-boot-starter-parent - >
< groupId> org.springframework.boot< / groupId>
< artifactId> spring-boot-starter-parent< / artifactId>
< version> 1.3.0.RELEASE< / version>
< / parent>
< artifactId> MyWS< / artifactId>
< groupId> fr.companie< / groupId>
< name> myws< / name>
< description>弹簧引导数据JPA项目< / description>
< version> 1.3< / version>
< organization>
< name> some org< / name>
< / organization>

< packaging> $ {packaging.type}< / packaging>

< properties>
< maven.compiler.source> 1.7< /maven.compiler.source>
< maven.compiler.target> 1.7< /maven.compiler.target>
< / properties>

< dependencies>
<依赖关系>
< groupId> org.springframework.boot< / groupId>
< artifactId> spring-boot-starter-data-jpa< / artifactId>
< / dependency>
<依赖关系>
< groupId> org.springframework.boot< / groupId>
< artifactId> spring-boot-starter-web< / artifactId>
< / dependency>
<依赖关系>
< groupId> org.springframework.boot< / groupId>
< artifactId> spring-boot-starter-test< / artifactId>
< scope> test< / scope>
< / dependency>

<! - 用于glassfish bug一个mettre dans profil prod - >
<依赖关系>
< groupId> org.springframework.boot< / groupId>
< artifactId> spring-boot-starter-freemarker< / artifactId>
< / dependency>
<依赖关系>
< groupId> org.springframework.boot< / groupId>
< artifactId> spring-boot-starter-velocity< / artifactId>
< / dependency>





<! - 将Spring与JAX-WS(cxf)集成 - >
<依赖关系>
< groupId> org.apache.cxf< / groupId>
< artifactId> cxf-rt-frontend-jaxws< / artifactId>
< version> 3.1.4< / version>
< / dependency>
<依赖关系>
< groupId> org.apache.cxf< / groupId>
< artifactId> cxf-rt-transports-http< / artifactId>
< version> 3.1.4< / version>
< / dependency>

<依赖关系>
< groupId> commons-codec< / groupId>
< artifactId> commons-codec< / artifactId>
< version> 1.10< / version>
< / dependency>
<依赖关系>
< groupId> com.oracle< / groupId>
< artifactId> ojdbc6< / artifactId>
< version> 11.2.0.4< / version>
< / dependency>

< / dependencies>


<个人资料>
<个人资料>
< id> production< / id>
<属性>
< packaging.type> war< /packaging.type>
< / properties>
<依赖关系>
<依赖关系>
< groupId> org.springframework.boot< / groupId>
< artifactId> spring-boot-starter-tomcat< / artifactId>
< scope>已提供< / scope>
< / dependency>

< / dependencies>
< build>
< finalName> $ {project.name}< / finalName>
< plugins>
< plugin>
< artifactId> maven-war-plugin< / artifactId>
< configuration>
< packagingExcludes> ** / *。sql< / packagingExcludes>
< / configuration>
< / plugin>
< / plugins>
< / build>
< / profile>

<个人资料>
< id> developmentpement< / id>
< activate>
< activeByDefault> true< / activeByDefault>
< / activation>
<属性>
< packaging.type> jar< /packaging.type>
< / properties>
< build>
< plugins>
< plugin>
< groupId> org.springframework.boot< / groupId>
< artifactId> spring-boot-maven-plugin< / artifactId>
< / plugin>
< / plugins>
< / build>
< / profile>
< / profiles>
< / project>

部署中的错误:

 远程失败:部署期间发生错误:
加载应用程序时异常:java.lang.IllegalStateException:
ContainerBase.addChild:start:org.apache.catalina.LifecycleException :org.apache.catalina.LifecycleException:
org.springframework.context.ApplicationContextException:无法启动嵌入式容器;
嵌套异常是org.springframework.beans.factory.BeanCreationException:
创建名称为org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration $ DispatcherServletConfiguration的bean时出错:
注入自动连线依赖项失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:
无法自动连线字段:private org.springframework.boot.autoconfigure.web.ServerProperties
org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration $ DispatcherServletConfiguration.server;
嵌套异常是org.springframework.beans.factory.BeanCreationException:在类路径资源(org / springframework / boot / autoconfigure / web / ServerPropertiesAutoConfiguration.class)中定义名称为'serverProperties'
时创建的错误:
bean的初始化失败;嵌套异常是java.lang.NoClassDefFoundError:
无法初始化类org.jboss.logging.LoggerProviders。有关详细信息,请参阅server.log。
命令部署失败。

我尝试添加jboss日志依赖关系和log4j sl4j,所以一个依赖关系没有成功.... :(



帮助:)!

解决方案

错误消息隐藏了hibernate 5和jboss日志记录之间的不兼容性。



问题是弹簧启动提供的jboss日志记录版本(3.3.0。最终版本被覆盖在modules目录下的glassfish库(3.1.3-GA)中的旧版本。



解决方案是添加webapp的WEB-INF文件夹下的glassfish-web.xml文件,具有以下内容(如 http:/ /stackoverflow.com/a/38439108 )。

 <?xml version =1.0encoding = UTF-8\" >?; 
<!DOCTYPE glassfish-web-app PUBLIC - // GlassFish.org//DTD GlassFish应用服务器3.1 Servlet 3.0 // ENhttp://glassfish.org/dtds/glassfish-web-app_3_0 -1.dtd>
< glassfish-web-app>
< class-loader delegate =false/>
< / glassfish-web-app>

确保加载项目库而不是服务器库。在那个变化之后,春天开机项目完美无瑕地运行在玻璃鱼上。


I have created a Spring Boot application (webservice soap). Everything is ok and application works well trough the integrated tomcat in Spring Boot. When i try to package in a war and deploy to Glassfish 4.1 i a strange error.

My maven configuration:

<?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>
    <parent>
        <!-- Your own application should inherit from spring-boot-starter-parent -->
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.0.RELEASE</version>
    </parent>
    <artifactId>MyWS</artifactId>
    <groupId>fr.companie</groupId>
    <name>myws</name>
    <description>Spring Boot Data JPA Project</description>
    <version>1.3</version>
    <organization>
        <name>some org</name>
    </organization>

    <packaging>${packaging.type}</packaging>

    <properties>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    </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>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- for glassfish bug A mettre dans profil prod -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-freemarker</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-velocity</artifactId>
        </dependency>





        <!-- integrate Spring with JAX-WS (cxf) -->
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>3.1.4</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>3.1.4</version>
        </dependency>

        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.10</version>
        </dependency>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.4</version>
        </dependency>

    </dependencies>


    <profiles>
        <profile>
            <id>production</id>
            <properties>
                <packaging.type>war</packaging.type>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                    <scope>provided</scope>
                </dependency>

            </dependencies>
            <build>
                <finalName>${project.name}</finalName>
                <plugins>
                    <plugin>
                        <artifactId>maven-war-plugin</artifactId>
                        <configuration>
                            <packagingExcludes>**/*.sql</packagingExcludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>developpement</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <packaging.type>jar</packaging.type>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

And the error in deployment:

remote failure: Error occurred during deployment: 
Exception while loading the app : java.lang.IllegalStateException: 
ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: 
org.springframework.context.ApplicationContextException: Unable to start embedded container;
 nested exception is org.springframework.beans.factory.BeanCreationException: 
 Error creating bean with name 'org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletConfiguration': 
 Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: 
 Could not autowire field: private org.springframework.boot.autoconfigure.web.ServerProperties 
 org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletConfiguration.server; 
 nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverProperties'
 defined in class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class]: 
 Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: 
 Could not initialize class org.jboss.logging.LoggerProviders. Please see server.log for more details.
Command deploy failed.

I have tried to add jboss logging dependencies and log4j sl4j and so one dependencies without success .... :(

Help :) !

解决方案

In my case this error message was hiding an incompatibility between the versions of hibernate 5 and jboss-logging.

The problem was that the jboss-logging version provided by spring boot (3.3.0.Final) was being overridden by an older version already included in the glassfish libraries (3.1.3-GA), under the "modules" directory.

The solution was to add a "glassfish-web.xml" file under the "WEB-INF" folder of the webapp, with the following content (as suggested in http://stackoverflow.com/a/38439108).

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
     <class-loader delegate="false"/>
</glassfish-web-app>

This ensures the loading of the project libraries instead of the server ones. After that change, the spring boot project run on glassfish flawlessly.

这篇关于无法在Glassfish 4.1上部署弹簧引导应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆