1

我正在尝试将 aSecurityContext注入会话 bean。该容器是在 OpenJDK 11 上运行的开箱即用的独立 Wildfly 15.0.1 应用程序服务器。

当我尝试部署该应用程序时,我得到以下信息:

WELD-001408: Unsatisfied dependencies for type SecurityContext with qualifiers @Default

对于上下文,我目前正在尝试模仿java-ee-kickoff-app 的某些部分,它完美地部署在 Wildfly 15.0.1 上。我检查了整个项目以查看声明安全上下文的位置,但无济于事,所以我有点迷失......

作为参考,这是我的代码:

import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.security.enterprise.SecurityContext;

@Named
@SessionScoped
public class ExampleBean implements Serializable {

  @Inject
  private SecurityContext securityContext;

}

/WEB-INF/bean.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans
  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/beans_1_1.xsd"
  version="1.2"
  bean-discovery-mode="all">
</beans>

/WEB-INF/jboss-web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web
  PUBLIC "-//JBoss//DTD JBOSS 5.0//EN"
  "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd">
<jboss-web>
  <security-domain>jaspitest</security-domain>
  <context-root>/</context-root>
</jboss-web>

/WEB-INF/web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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_4_0.xsd"
  version="4.0">

  <display-name>Example</display-name>

  <context-param>
    <param-name>org.omnifaces.FACES_VIEWS_SCAN_PATHS</param-name>
    <param-value>/*.xhtml</param-value>
  </context-param>

  <servlet>
    <servlet-name>facesServlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>facesServlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>

  <filter-mapping>
    <filter-name>localeFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <session-config>
    <cookie-config>
      <http-only>true</http-only>
    </cookie-config>
    <tracking-mode>COOKIE</tracking-mode>
  </session-config>

  <welcome-file-list>
    <welcome-file>home</welcome-file>
  </welcome-file-list>

  <error-page>
    <error-code>400</error-code>
    <location>/WEB-INF/errorpages/400.xhtml</location>
  </error-page>
  <error-page>
    <error-code>403</error-code>
    <location>/WEB-INF/errorpages/404.xhtml</location>
  </error-page>
  <error-page>
    <error-code>404</error-code>
    <location>/WEB-INF/errorpages/404.xhtml</location>
  </error-page>
  <error-page>
    <error-code>500</error-code>
    <location>/WEB-INF/errorpages/500.xhtml</location>
  </error-page>
  <error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/WEB-INF/errorpages/expired.xhtml</location>
  </error-page>

</web-app>

最后是我的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.example</groupId>
  <artifactId>example</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <packaging>war</packaging>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  </properties>

  <build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
          <release>11</release>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>

    <dependency>
      <groupId>org.glassfish</groupId>
      <artifactId>javax.faces</artifactId>
      <version>2.3.5</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-api</artifactId>
      <version>8.0</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.omnifaces</groupId>
      <artifactId>omnifaces</artifactId>
      <version>3.2</version>
    </dependency>
    <dependency>
      <groupId>org.omnifaces</groupId>
      <artifactId>omnisettings</artifactId>
      <version>0.1</version>
    </dependency>
    <dependency>
      <groupId>org.omnifaces</groupId>
      <artifactId>omniutils</artifactId>
      <version>0.11</version>
    </dependency>

    <dependency>
      <groupId>org.primefaces</groupId>
      <artifactId>primefaces</artifactId>
      <version>6.2</version>
    </dependency>

  </dependencies>

</project>
4

1 回答 1

2

至少IdentityStore必须提供一个。一旦完成,问题就会消失并且应用程序能够部署。

于 2019-02-25T16:42:37.533 回答