我有一个问题。我正在集成 EJB、JAX-RS、CDI、JPA 和数据源。当我将这些集成到 wildfly-swarm 中时,会出现一些无法正常工作的问题。
yaml.xml:
datasources:
jdbc-drivers:
com.mysql:
driver-class-name: com.mysql.jdbc.Driver
xa-datasource-class-name: com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
driver-module-name: com.mysql
data-sources:
PicketlinkDS:
driver-name: com.mysql
connection-url: jdbc:mysql://localhost:3306/testjpa
user-name: root
password: javacom2
jta : true
use-java-context: true
min-pool-size : 8
max-pool-size : 20
pool-prefill : true
connection-checker-class-name : org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker
background-validation : true
exception-sorter-class-name : org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter
connection-properties : CharacterEncoding/ UTF-8 UseUnicode/true
持久性.xml:
<persistence-unit name="picketlink" transaction-type="JTA">
<jta-data-source>java:jboss/datasources/PicketlinkDS
</jta-data-source>
<!-- 声明是否扫描jar文件中标注了@Enity类加入到上下文.若不扫描,则如下:(可选) -->
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.query.substitutions" value="true=1, false=0" />
<property name="hibernate.dialect.storage_enginet"
value="innodb" />
<!-- JBoss/Wildfly JTA Transaction -->
<property name="hibernate.transaction.jta.platform"
value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />
<property name="hibernate.cache.use_query_cache" value="false" />
<property name="hibernate.cache.use_second_level_cache"
value="false" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.hbm2ddl.import_files" value="initial_data.sql" />
<property name="hibernate.jdbc.batch_size" value="1000" />
<property name="hibernate.order_inserts" value="true" />
<property name="hibernate.order_updates" value="true" />
<property name="hibernate.connection.characterEncoding"
value="UTF-8" />
<property name="hibernate.current_session_context_class"
value="jta" />
<property name="wildfly.jpa.default-unit" value="true" />
</properties>
</persistence-unit>
主类:
ClassLoader cl = Main.class.getClassLoader();
URL stageConfig = cl.getResource("project-development.yml");
Swarm swarm = new Swarm().withConfig(stageConfig);
// Create one or more deployments
JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class);
deployment.addAsWebInfResource(new ClassLoaderAsset("META-INF/persistence.xml", Main.class.getClassLoader()), "classes/META-INF/persistence.xml");
// Add resource to deployment
//deployment.addClass(PmsPersonService.class);
deployment.addClass(Person.class);
// deployment.addClass(EntityManagerProvider.class);
deployment.addAsWebInfResource(new ClassLoaderAsset("META-INF/load.sql", Main.class.getClassLoader()), "classes/META-INF/load.sql");
deployment.addResource(RestApplication.class);
deployment.addResource(HelloWorldEndpoint.class);
deployment.addAllDependencies();
swarm.start();
swarm.deploy(deployment);
异常:“WFLYCTL0412:未安装的必需服务:”=>“jboss.naming.context.java.jboss.datasources.PicketlinkDS”],
想法,运行上如何处理这个异常?好着急!!!!!!