嗨,我尝试在这里找到一个 JEE8 安全 Web 应用程序示例:https ://github.com/swhp/javaee-soteria
我会将它安装在 Wildfly10 (jboss 7+) 中,带有 Cargo Maven 2 插件和 HSQL 数据库(而不是 Postgres)。与货物一起运行的应用程序:运行
所以我修改了一个 pom.xml,为 hsqldb 添加了插件和依赖项,如下所示:
<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>id.swhp</groupId>
<artifactId>javaee-soteria</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<!-- Security API Soteria -->
<dependency>
<groupId>org.glassfish.soteria</groupId>
<artifactId>javax.security.enterprise</artifactId>
<version>1.0</version>
</dependency>
<!-- Omnifaces, develop JSF never easier without Omnifaces -->
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.4.0</version>
</dependency>
</dependencies>
<build>
<finalName>javaee-soteria</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp/WEB-INF</directory>
<targetPath>WEB-INF</targetPath>
<includes>
<include>*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.5.0</version>
<configuration>
<container>
<containerId>wildfly10x</containerId>
<zipUrlInstaller>
<url>
http://download.jboss.org/wildfly/10.1.0.Final/wildfly-10.1.0.Final.zip
</url>
</zipUrlInstaller>
<dependencies>
<!--<dependency>-->
<!--<groupId>com.oracle</groupId>-->
<!--<artifactId>jdbc6</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
</dependencies>
</container>
<configuration>
<files>
<copy>
<file>${project.basedir}/src/main/jboss/configuration/</file>
<todir>
../../installs/wildfly-10.1.0.Final/wildfly-10.1.0.Final/standalone/configuration
</todir>
<configfile>true</configfile>
<overwrite>true</overwrite>
</copy>
<copy>
<file>${project.basedir}/src/main/jboss/configuration/</file>
<todir>../../configurations/wildfly10x/configuration</todir>
<configfile>true</configfile>
<overwrite>true</overwrite>
</copy>
<copy>
<file>${project.basedir}/src/main/jboss/modules/</file>
<todir>../../installs//wildfly-10.1.0.Final/wildfly-10.1.0.Final/modules/system/layers/base</todir>
<configfile>true</configfile>
<overwrite>true</overwrite>
</copy>
<copy>
<file>${project.basedir}/src/main/jboss/configuration/</file>
<todir>
../../installs/wildfly-10.1.0.Final/wildfly-10.1.0.Final/standalone/configuration
</todir>
<configfile>true</configfile>
<overwrite>true</overwrite>
</copy>
</files>
<properties>
<cargo.start.jvmargs>
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9000
-Xnoagent
-Djava.compiler=NONE
</cargo.start.jvmargs>
<cargo.jboss.modules.dir>modules</cargo.jboss.modules.dir>
<cargo.servlet.port>9090</cargo.servlet.port>
<cargo.jboss.management-http.port>9050</cargo.jboss.management-http.port>
<cargo.servlet.users>admin:admin</cargo.servlet.users>
</properties>
</configuration>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
</project>
我将配置文件(standalone.xml)和 hsqldb 驱动程序(jar)+ 相关 module.xml 复制到我的 jboss 目录中,并将插件配置为复制到 Wildfly 安装目录(在目标中):
myprojectdir\src\main\jboss\configuration\standalone.xml myprojectdir\src\main\jboss\modules\org\hsqldb\main\module.xml myprojectdir\src\main\jboss\modules\org\hsqldb\main\hsqldb- 2.4.0.jar
satandalone.xml:
<?xml version='1.0' encoding='UTF-8'?>
<server xmlns="urn:jboss:domain:4.2">
<extensions>
<extension module="org.jboss.as.clustering.infinispan"/>
<extension module="org.jboss.as.connector"/>
<extension module="org.jboss.as.deployment-scanner"/>
<extension module="org.jboss.as.ee"/>
<extension module="org.jboss.as.ejb3"/>
<extension module="org.jboss.as.jaxrs"/>
<extension module="org.jboss.as.jdr"/>
<extension module="org.jboss.as.jmx"/>
<extension module="org.jboss.as.jpa"/>
<extension module="org.jboss.as.jsf"/>
<extension module="org.jboss.as.logging"/>
<extension module="org.jboss.as.mail"/>
<extension module="org.jboss.as.naming"/>
<extension module="org.jboss.as.pojo"/>
<extension module="org.jboss.as.remoting"/>
<extension module="org.jboss.as.sar"/>
<extension module="org.jboss.as.security"/>
<extension module="org.jboss.as.transactions"/>
<extension module="org.jboss.as.webservices"/>
<extension module="org.jboss.as.weld"/>
<extension module="org.wildfly.extension.batch.jberet"/>
<extension module="org.wildfly.extension.bean-validation"/>
<extension module="org.wildfly.extension.io"/>
<extension module="org.wildfly.extension.request-controller"/>
<extension module="org.wildfly.extension.security.manager"/>
<extension module="org.wildfly.extension.undertow"/>
</extensions>
<system-properties>
<property name="spring.profiles.default" value="namingEnvironment:external"/>
<property name="spring.profiles.active" value="namingEnvironment:external"/>
</system-properties>
<management>
....
....
<subsystem xmlns="urn:jboss:domain:datasources:4.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection
url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<datasource jta="true" jndi-name="java:/jdbc/soteria" pool-name="SOTERIA" enabled="true" use-ccm="true">
<connection-url>jdbc:hsqldb:hsql://localhost:9001/SOTERIA</connection-url>
<driver-class>org.hsqldb.jdbc.JDBCDriver</driver-class>
<driver>hsqldb</driver>
<security>
<user-name>sa</user-name>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="hsqldb" module="org.hsqldb">
<datasource-class>org.hsqldb.jdbc.JDBCDataSource</datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
<subsystem xmlns="urn:jboss:domain:deployment-scanner:2.0">
.... (i can't copy all lines of code..)
</server>
模块.xml:
<module xmlns="urn:jboss:module:1.3" name="org.hsqldb">
<resources>
<resource-root path="hsqldb-2.4.0.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
当我运行命令“cargo:run”时,上面的 module.xml 和 hsqldb jar 被复制到
cargo\installs\wildfly-10.1.0.Final\wildfly-10.1.0.Final\modules\system\layers\base\org\hsqldb\main
但是,我得到了这个例外,我的错误是什么?谢谢!
[INFO] [talledLocalContainer] 15:01:53,427 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 33) WFLYCTL0013: Operation ("add") failed - address: ([
[INFO] [talledLocalContainer] ("subsystem" => "datasources"),
[INFO] [talledLocalContainer] ("jdbc-driver" => "hsqldb")
[INFO] [talledLocalContainer] ]) - failure description: "WFLYJCA0041: Failed to load module for driver [org.hsqldb]"
..
[INFO] [talledLocalContainer] 15:01:58,061 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) WFLYJCA0004: Deploying JDBC-compliant driver class org.hsqldb.jdbc.JDBCDriver (version 2.4)
[INFO] [talledLocalContainer] 15:01:58,108 INFO [org.jboss.weld.Version] (MSC service thread 1-4) WELD-000900: 2.3.5 (Final)
[INFO] [talledLocalContainer] 15:01:58,132 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) WFLYJCA0018: Started Driver service with driver-name = javaee-soteria.war_org.hsqldb.jdbc.JDBCDriver_2_4
[INFO] [talledLocalContainer] 15:01:58,495 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 62) WFLYCLINF0002: Started client-mappings cache from ejb container
[INFO] [talledLocalContainer] 15:01:58,558 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "javaee-soteria.war")]) - failure description: {
[INFO] [talledLocalContainer] "WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.jboss.java:jdbc.soteria"],
[INFO] [talledLocalContainer] "WFLYCTL0180: Services with missing/unavailable dependencies" => [
[INFO] [talledLocalContainer] "jboss.persistenceunit.\"javaee-soteria.war#soteria\" is missing [jboss.naming.context.java.jboss.java:jdbc.soteria]",
[INFO] [talledLocalContainer] "jboss.persistenceunit.\"javaee-soteria.war#soteria\".__FIRST_PHASE__ is missing [jboss.naming.context.java.jboss.java:jdbc.soteria]"
[INFO] [talledLocalContainer] ],
[INFO] [talledLocalContainer] "WFLYCTL0288: One or more services were unable to start due to one or more indirect dependencies not being available." => {
[INFO] [talledLocalContainer] "Services that were unable to start:" => [
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".CdiValidatorFactoryService",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".WeldStartService",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.AccountStore.START",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.AccountStore.WeldInstantiator",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.AccountStore.WeldInterceptorBindingsService",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.PbkdfGenerator.START",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.PbkdfGenerator.WeldInstantiator",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.PbkdfGenerator.WeldInterceptorBindingsService",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.SHAGenerator.START",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.SHAGenerator.WeldInstantiator",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.SHAGenerator.WeldInterceptorBindingsService",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.TokenScheduler.START",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.TokenScheduler.WeldInstantiator",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.TokenScheduler.WeldInterceptorBindingsService",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.TokenStore.START",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.TokenStore.WeldInstantiator",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.TokenStore.WeldInterceptorBindingsService",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"com.sun.faces.config.ConfigureListener\".START",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"com.sun.faces.config.ConfigureListener\".WeldInstantiator",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"id.swhp.javaee.soteria.application.servlet.AuthenticationFilter\".START",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"id.swhp.javaee.soteria.application.servlet.AuthenticationFilter\".WeldInstantiator",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"javax.faces.webapp.FacesServlet\".START",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"javax.faces.webapp.FacesServlet\".WeldInstantiator",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"javax.faces.webapp.FacetTag\".START",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"javax.faces.webapp.FacetTag\".WeldInstantiator",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV\".START",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV\".WeldInstantiator",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"javax.servlet.jsp.jstl.tlv.ScriptFreeTLV\".START",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"javax.servlet.jsp.jstl.tlv.ScriptFreeTLV\".WeldInstantiator",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"managed-bean.java.util.Date\".START",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"managed-bean.java.util.Date\".WeldInstantiator",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"org.jboss.weld.servlet.WeldInitialListener\".START",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"org.jboss.weld.servlet.WeldInitialListener\".WeldInstantiator",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"org.jboss.weld.servlet.WeldTerminalListener\".START",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"org.jboss.weld.servlet.WeldTerminalListener\".WeldInstantiator",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"org.omnifaces.ApplicationListener\".START",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".component.\"org.omnifaces.ApplicationListener\".WeldInstantiator",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".deploymentCompleteService",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".jndiDependencyService",
[INFO] [talledLocalContainer] "jboss.deployment.unit.\"javaee-soteria.war\".moduleDeploymentRuntimeInformationStart",
[INFO] [talledLocalContainer] "jboss.naming.context.java.module.javaee-soteria.javaee-soteria.env.\"id.swhp.javaee.soteria.business.account.boundary.AccountStore\".em",
[INFO] [talledLocalContainer] "jboss.naming.context.java.module.javaee-soteria.javaee-soteria.env.\"id.swhp.javaee.soteria.business.security.boundary.TokenScheduler\".em",
[INFO] [talledLocalContainer] "jboss.naming.context.java.module.javaee-soteria.javaee-soteria.env.\"id.swhp.javaee.soteria.business.security.boundary.TokenStore\".em",
[INFO] [talledLocalContainer] "jboss.undertow.deployment.default-server.default-host./javaee-soteria",
[INFO] [talledLocalContainer] "jboss.undertow.deployment.default-server.default-host./javaee-soteria.UndertowDeploymentInfoService"
[INFO] [talledLocalContainer] ],
[INFO] [talledLocalContainer] "Services that may be the cause:" => [
[INFO] [talledLocalContainer] "jboss.jdbc-driver.hsqldb",
[INFO] [talledLocalContainer] "jboss.naming.context.java.jboss.java:jdbc.soteria"
[INFO] [talledLocalContainer] ]
[INFO] [talledLocalContainer] }
[INFO] [talledLocalContainer] }
[INFO] [talledLocalContainer] 15:01:58,562 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
[INFO] [talledLocalContainer] ("subsystem" => "datasources"),
[INFO] [talledLocalContainer] ("data-source" => "SOTERIA")
[INFO] [talledLocalContainer] ]) - failure description: {
[INFO] [talledLocalContainer] "WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.hsqldb"],
[INFO] [talledLocalContainer] "WFLYCTL0180: Services with missing/unavailable dependencies" => [
[INFO] [talledLocalContainer] "jboss.driver-demander.java:/jdbc/soteria is missing [jboss.jdbc-driver.hsqldb]",
[INFO] [talledLocalContainer] "org.wildfly.data-source.SOTERIA is missing [jboss.jdbc-driver.hsqldb]"
[INFO] [talledLocalContainer] ]
[INFO] [talledLocalContainer] }
[INFO] [talledLocalContainer] 15:01:58,569 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
[INFO] [talledLocalContainer] ("subsystem" => "datasources"),
[INFO] [talledLocalContainer] ("data-source" => "SOTERIA")
[INFO] [talledLocalContainer] ]) - failure description: {
[INFO] [talledLocalContainer] "WFLYCTL0412: Required services that are not installed:" => [
[INFO] [talledLocalContainer] "jboss.jdbc-driver.hsqldb",
[INFO] [talledLocalContainer] "jboss.jdbc-driver.hsqldb"
[INFO] [talledLocalContainer] ],
[INFO] [talledLocalContainer] "WFLYCTL0180: Services with missing/unavailable dependencies" => [
[INFO] [talledLocalContainer] "jboss.driver-demander.java:/jdbc/soteria is missing [jboss.jdbc-driver.hsqldb]",
[INFO] [talledLocalContainer] "org.wildfly.data-source.SOTERIA is missing [jboss.jdbc-driver.hsqldb]",
[INFO] [talledLocalContainer] "org.wildfly.data-source.SOTERIA is missing [jboss.jdbc-driver.hsqldb]"
[INFO] [talledLocalContainer] ],
[INFO] [talledLocalContainer] "WFLYCTL0288: One or more services were unable to start due to one or more indirect dependencies not being available." => {
[INFO] [talledLocalContainer] "Services that were unable to start:" => [
[INFO] [talledLocalContainer] "jboss.data-source.reference-factory.SOTERIA",
[INFO] [talledLocalContainer] "jboss.naming.context.java.jdbc.soteria"
[INFO] [talledLocalContainer] ],
[INFO] [talledLocalContainer] "Services that may be the cause:" => [
[INFO] [talledLocalContainer] "jboss.jdbc-driver.hsqldb",
[INFO] [talledLocalContainer] "jboss.naming.context.java.jboss.java:jdbc.soteria"
[INFO] [talledLocalContainer] ]
[INFO] [talledLocalContainer] }
[INFO] [talledLocalContainer] }
[INFO] [talledLocalContainer] 15:01:58,616 INFO [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "javaee-soteria.war" (runtime-name : "javaee-soteria.war")
[INFO] [talledLocalContainer] 15:01:58,616 INFO [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "cargocpc.war" (runtime-name : "cargocpc.war")
[INFO] [talledLocalContainer] 15:01:58,621 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
[INFO] [talledLocalContainer] WFLYCTL0184: New missing/unsatisfied dependencies:
[INFO] [talledLocalContainer] service jboss.jdbc-driver.hsqldb (missing) dependents: [service org.wildfly.data-source.SOTERIA, service jboss.driver-demander.java:/jdbc/soteria]
[INFO] [talledLocalContainer] service jboss.naming.context.java.jboss.java:jdbc.soteria (missing) dependents: [service jboss.persistenceunit."javaee-soteria.war#soteria".__FIRST_PHASE__, service jboss.persistenceunit."javaee-soteria.war#soteria"]
[INFO] [talledLocalContainer]
[INFO] [talledLocalContainer] 15:01:58,828 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9050/management
这是我在 resources\META-INF 中的持久性文件描述符:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="soteria" transaction-type="JTA">
<jta-data-source>java:jdbc/soteria</jta-data-source>
<!-- TODO: parameterize this -->
<properties>
<property name="eclipselink.logging.level.sql" value="FINE"/>
<property name="eclipselink.logging.parameters" value="true"/>
<property name="eclipselink.logging.timestamp" value="true"/>
</properties>
</persistence-unit>
</persistence>