使用 Maven 在 WebLogic 12.1.3 上构建和部署 JAX-RS 2.0 应用程序时出现问题

Problems building and deploying JAX-RS 2.0 app on WebLogic 12.1.3 with Maven

我们在 WebLogic 12.1.3 上有一个应用程序 运行,我们想向它添加一些 JAX-RS 2.0 服务。我们使用 Maven 构建和部署到服务器(使用 weblogic-maven-plugin)。

要在服务器上安装 JAX-RS 2.0,我按照此处给出的步骤操作:

https://docs.oracle.com/middleware/1213/wls/RESTF/use-jersey20-ri.htm#RESTF297

一切似乎都很好。安装过程中没有给出错误或警告,库在 WebLogic 管理控制台中可见。

但是现在当我这样做时 "mvn clean install" 我得到了这个:

<Nov 23, 2016 2:39:00 PM CET> <Error> <J2EE> <BEA-160187> <weblogic.appc failed to compile the application. Recompile with the -verbose option for more details about the issue.>
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 26.655s
    [INFO] Finished at: Wed Nov 23 14:28:21 CET 2016
    [INFO] Final Memory: 65M/872M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal com.oracle.weblogic:weblogic-maven-plugin:12.1.3-0-0:appc (wls-appc) on project our-awesome-app: weblogic.utils.compiler.ToolFailureException: Unresolved WebApp library references defined in weblogic.xml, of module 'our-awesome-app.war' [Extension-Name: jax-rs, Specification-Version: 2, Implementation-Version: 2.5.1, exact-match: false]
    [ERROR] at weblogic.servlet.tools.WARModule.initWebAppLibraryManager(WARModule.java:449)
    [ERROR] at weblogic.servlet.tools.WARModule.processLibraries(WARModule.java:492)
    [ERROR] at weblogic.servlet.tools.WARModule.compile(WARModule.java:274)
    [ERROR] at weblogic.application.compiler.ToolsModuleWrapper.compile(ToolsModuleWrapper.java:107)
    (goes on and on...)

使用“-verbose”选项编译不会呈现更多信息。

我已经尽我所能彻底搜索 Whosebug,但我似乎无法找到这个问题的解释或解决方案。

以下是(我相信)我们pom.xml的相关部分:

    <plugin>
                    <!-- This is the configuration for the weblogic-maven-plugin -->
                    <groupId>com.oracle.weblogic</groupId>
                    <artifactId>weblogic-maven-plugin</artifactId>
                    <version>12.1.3-0-0</version>
                    <configuration>
                        <middlewareHome>${wls-admin-middleware-home}</middlewareHome>
                        <adminurl>${wls-admin-url}</adminurl>
                        <user>${wls-admin-user}</user>
                        <password>${wls-admin-password}</password>
                        <source>${project.build.directory}/${project.build.finalName}.${project.packaging}</source>
                        <targets>${wls-admin-targets}</targets>
                        <name>${project.build.finalName}</name>
                        <domainHome>${wls-admin-domain-home}</domainHome>
                        <securityModel>DDOnly</securityModel>
                    </configuration>
                    <executions>
                        <execution>
                            <id>wls-appc</id>
                            <phase>package</phase>
                            <goals>
                                <goal>appc</goal>
                            </goals>
                            <configuration />
                        </execution>
                        <execution>
                            <id>wls-wlst-start-server</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>start-server</goal>
                            </goals>
                            <configuration>
                            </configuration>
                        </execution>
                        <execution>
                            <id>wls-deploy</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>deploy</goal>
                            </goals>
                            <configuration>
                                <securityModel>DDOnly</securityModel>
                            </configuration>
                        </execution>
                        <execution>
                            <id>wls-start-app</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>start-app</goal>
                            </goals>
                            <configuration />
                        </execution>
                    </executions>
                </plugin>
...
<dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>

这是我们的 weblogic.xml:

<wls:library-ref>
      <wls:library-name>jax-rs</wls:library-name>
      <wls:specification-version>2.0</wls:specification-version>
      <wls:implementation-version>2.5.1</wls:implementation-version>
    </wls:library-ref>

如果任何对 WebLogic 有更多经验和知识的人能指出我的解决方案,我将不胜感激。我以前主要使用 JBoss 和 Glassfish,这让我非常头疼,因为我从未在这些应用程序服务器上经历过类似的事情。

解决了。 library-ref 进入 META-INF/weblogic-application.xml,而不是 WEB-INF/weblogic.xml.

发生这种情况是因为在尝试 pre-compile war 和 wls-appc 时缺少那些库引用。

那些共享库必须在编译时位于类路径中。

您可能缺少 JAX-RS 2.0 库。按照这个来安装它:进入你的服务器,点击安装新的 Application/Library,然后 select 路径到 Oracle-> Middleware-> wlserver-> common-> deployable-libraries 和 select JAX-RS 2.0.war 库。它对我有用