Myfaces 应用程序的 Weblogic 12c 部署

Weblogic 12c Deployment of Myfaces Application

我创建了一个测试应用程序来帮助将 Web 应用程序从 weblogic 10.3.6 移植到 Weblogic 12C (12.1.3)。不幸的是,由于此应用程序使用 myFaces,我在部署时遇到了问题。根据文档,它应该能够支持覆盖捆绑的 JSF 实现,但我仍然 运行 进入以下错误:

    weblogic.application.ModuleException: java.lang.IllegalStateException: Could not find backup for factory javax.faces.application.ApplicationFactory. 
    at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
    at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
    at weblogic.application.internal.flow.ModuleStateDriver.next(ModuleStateDriver.java:233)
    at weblogic.application.internal.flow.ModuleStateDriver.next(ModuleStateDriver.java:228)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
    Truncated. see log file for complete stacktrace
Caused By: java.lang.IllegalStateException: Could not find backup for factory javax.faces.application.ApplicationFactory. 
    at javax.faces.FactoryFinderInstance.getFactory(FactoryFinderInstance.java:561)
    at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:283)
    at org.apache.myfaces.context.servlet.FacesContextImplBase.getApplication(FacesContextImplBase.java:153)
    at org.apache.myfaces.context.servlet.FacesContextImplBase.getELContext(FacesContextImplBase.java:204)
    at javax.faces.component.UIViewRoot.setLocale(UIViewRoot.java:1488)
    Truncated. see log file for complete stacktrace

这是相关文件。这又是一个虚拟的 Hello World 应用程序。

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>com.pdm</groupId>
  <artifactId>PDM_TEST_WEBAPP</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>

  <name>PDM_TEST_WEBAPP Maven Webapp</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
      <dependency>
          <groupId>org.apache.myfaces.core</groupId>
          <artifactId>myfaces-api</artifactId>
          <version>2.0.18</version>
      </dependency>
      <dependency>
          <groupId>org.apache.myfaces.core</groupId>
          <artifactId>myfaces-impl</artifactId>
          <version>2.0.18</version>
      </dependency>
  </dependencies>

  <build>
    <finalName>PDM_TEST_WEBAPP</finalName>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
        <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.7.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.20.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-war-plugin</artifactId>
          <version>3.2.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>

Weblogic.xml:

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">
    <container-descriptor>
        <session-monitoring-enabled>true</session-monitoring-enabled>
    </container-descriptor>
    <jsp-descriptor>
        <page-check-seconds>0</page-check-seconds>
        <verbose>true</verbose>
    </jsp-descriptor>
    <container-descriptor>
        <prefer-application-packages>
            <package-name>javax.faces.*</package-name>
            <package-name>com.sun.faces.*</package-name>
            <package-name>com.bea.faces.*</package-name>
        </prefer-application-packages>

        <prefer-application-resources>
            <resource-name>javax.faces.*</resource-name>
            <resource-name>com.sun.faces.*</resource-name>
            <resource-name>com.bea.faces.*</resource-name>
            <resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name>
            <resource-name>META-INF/services/com.sun.faces.*</resource-name>
        </prefer-application-resources>
    </container-descriptor>
</weblogic-web-app>

index.jsp:

<html>
<body>
<h2>Hello World!</h2>
</body>
</html>

我忽略了 weblogic.xml 中的第一个容器描述符。正确的weblogic.xml应该是这样的:

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">
    <container-descriptor>
        <session-monitoring-enabled>true</session-monitoring-enabled>
        <prefer-application-packages>
            <package-name>javax.faces.*</package-name>
            <package-name>com.sun.faces.*</package-name>
            <package-name>com.bea.faces.*</package-name>
        </prefer-application-packages>
        <prefer-application-resources>
            <resource-name>javax.faces.*</resource-name>
            <resource-name>com.sun.faces.*</resource-name>
            <resource-name>com.bea.faces.*</resource-name>
            <resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name>
            <resource-name>META-INF/services/com.sun.faces.*</resource-name>
        </prefer-application-resources>
    </container-descriptor>

    <jsp-descriptor>
        <page-check-seconds>0</page-check-seconds>
        <verbose>true</verbose>
    </jsp-descriptor>
</weblogic-web-app>