将WAR部署到JBoss失败,因为它调用了打包在EAR中的SAR [英] WAR deployment to JBoss fails because it calls a SAR packaged in an EAR

查看:177
本文介绍了将WAR部署到JBoss失败,因为它调用了打包在EAR中的SAR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将JBoss服务档案(SAR)和WAR与Maven一起打包在EAR中,以便部署到JBoss.我遇到的问题是,在此服务器上运行的另一个独立WAR在JBoss启动时调用了上述SAR提供的服务.由于JBoss在包含SAR的EAR之前 部署了独立的WAR,因此独立的WAR会引发错误,因为它所调用的服务尚未部署.

I'm packaging a JBoss service archive (SAR) and WAR together in an EAR with Maven for deployment to JBoss. The problem I have is that another standalone WAR running on this server calls a service provided by the aforementioned SAR on JBoss startup. Because JBoss deploys the standalone WAR before the EAR containing the SAR, the standalone WAR throws errors because the service it's calling has not been deployed yet.

是否有办法让JBoss首先部署EAR?那是正确的方法吗?

Is there a way to get JBoss to deploy the EAR first? Is that even the correct approach?

一种解决方法是先手动部署EAR,然后部署调用的WAR,但我不想依靠手动部署每个EAR,因为有时JBoss会简单地重新启动.

One workaround would be to manually deploy the EAR first, then deploy the calling WAR, but I don't want to rely on deploying each manually because sometimes JBoss will simply be restarted.

推荐答案

最适合我的解决方案是更改包装.我没有像最初那样将SAR和WAR打包在EAR中,而是将WAR打包在SAR中.

The solution that worked for me was to change the packaging. Instead of packaging the SAR and WAR in an EAR as I was doing originally, I packaged the WAR in the SAR.

.ear文件在.sar文件下方部署了多个优先级并且鉴于.sar旨在扩展JBoss并默认情况下具有较高的部署优先级,因此我推断出降低.sar优先级的结果可能会带来意想不到的后果.以我为例,服务器上另一个调用.sar提供的服务的Web应用程序开始出现故障.

.ear files get deployed several priorities below .sar files and given the fact that a .sar is intended to extend JBoss and is given a high deploy priority by default, I extrapolate that the results of lowering a .sar's priority can have unexpected consequences. In my case, another web application on the server calling the service provided by the .sar started failing.

要将.war与.sar打包在一起,我使用了maven-dependency-plugin:

To package the .war in with the .sar, I used the maven-dependency-plugin:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-installed</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>com.company</groupId>
                                <artifactId>artifact-id</artifactId>
                                <type>war</type>
                                <version>1.0.0-BUILD-SNAPSHOT</version>
                            </artifactItem>
                        </artifactItems>
                        <outputDirectory>${project.build.directory}/${project.name}-${project.version}</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>

这篇关于将WAR部署到JBoss失败,因为它调用了打包在EAR中的SAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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