我有这个名为"数据库"它是另一个项目的模块" WEB"我需要为这个"数据库"创建UNIT测试。项目,但我努力使payara工作。当我尝试在WildFly 10容器上启动UNIT测试时,我可以使它工作。但现在在payara,我坚持这个错误:
B�e 02, 2018 3:14:07 ODP. com.sun.enterprise.v3.server.AppServerStartup proceedTo
SEVERE: Shutdown required
MultiException stack 1 of 1
MultiException stack 1 of 2
java.lang.NoSuchMethodError: com.google.common.collect.Platform.newFastestQueue(I)Ljava/util/Queue;
at com.google.common.collect.EvictingQueue.<init>(EvictingQueue.java:54)
at com.google.common.collect.EvictingQueue.create(EvictingQueue.java:65)
...
我认为这些依赖应该足够了,但我肯定错过了一些东西......
这是我付钱的POM
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.3.0.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
...
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
</dependency>
<dependency>
<groupId>fish.payara.extras</groupId>
<artifactId>payara-embedded-all</artifactId>
<version>5.Beta2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>fish.payara.arquillian</groupId>
<artifactId>arquillian-payara-server-4-embedded</artifactId>
<version>1.0.Beta2</version>
</dependency>
像这样的Arquillian.xml:
<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<container qualifier="glassfish-embedded" default="true">
<configuration>
<property name="bindHttpPort">7070</property>
<property name="resourcesXml">src/test/resources/glassfish-resources.xml</property>
</configuration>
</container>
</arquillian>
和glassfish-resources.xml一样:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Resource Definitions //EN"
"http://www.sun.com/software/appserver/dtds/sun-resources_1_4.dtd">
<resources>
<jdbc-resource pool-name="IDM_test_mem"
jndi-name="jboss/datasources/IDM_test_mem"/>
<jdbc-connection-pool name="IDM_test_mem"
res-type="javax.sql.DataSource"
datasource-classname="org.h2.jdbcx.JdbcDataSource">
<property name="user" value="sa"/>
<property name="password" value="sa"/>
<property name="url" value="jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;INIT=CREATE SCHEMA IF NOT EXISTS test"/>
</jdbc-connection-pool>
</resources>
我在我的测试类中创建了WebArchive,如下所示:
return ShrinkWrap.create(WebArchive.class, "testIDM.war")
//adding classes
.....
//Resources
.addAsResource("test-persistence.xml", "META-INF/persistence.xml")
.addAsResource("beans.xml", "META-INF/beans.xml")
.addAsResource("activiti.cfg.xml", "activiti.cfg.xml")
.addAsWebInfResource("glassfish-resources.xml")
.addAsManifestResource("META-INF/services/org.activiti.cdi.spi.ProcessEngineLookup", "META-INF/services/org.activiti.cdi.spi.ProcessEngineLookup");
有人能帮助我吗?
修改
好的,所以我发现这是依赖性问题。我的一个依赖是使用GUAVA 13,所以我把它放在排除,但后来我有另外一个我无法解决的例外
SEVERE: Init exception A MultiException has 7 exceptions. They are:
1. org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl(requiredType=JavaEEContextUtil,parent=WeldDeployer,qualifiers={},position=-1,optional=false,self=false,unqualified=null,1597268821)
2. java.lang.IllegalArgumentException: While attempting to resolve the dependencies of org.glassfish.weld.WeldDeployer errors were found
3. java.lang.IllegalStateException: Unable to perform operation: resolve on org.glassfish.weld.WeldDeployer
4. java.lang.IllegalArgumentException: While attempting to resolve the dependencies of org.glassfish.weld.services.JCDIServiceImpl errors were found
5. java.lang.IllegalStateException: Unable to perform operation: resolve on org.glassfish.weld.services.JCDIServiceImpl
6. java.lang.IllegalArgumentException: While attempting to resolve the dependencies of com.sun.enterprise.web.WebContainer errors were found
7. java.lang.IllegalStateException: Unable to perform operation: resolve on com.sun.enterprise.web.WebContainer
即使尝试了如何在堆栈上解决它的例子,但没有结果。 任何答案或建议都会有所帮助。
我正在使用:
Java 8
Hibernate 5.2.2.Final
编辑2
我切换到版本5.181-SNAPSHOT的payara。似乎有另外一个例外(2是正确的)
第一:
java.lang.IllegalStateException: org.xml.sax.SAXNotRecognizedException: Feature 'http://javax.xml.XMLConstants/feature/secure-processing' is not recognized.
at com.sun.xml.bind.v2.util.XmlFactory.createParserFactory(XmlFactory.java:143)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.getXMLReader(UnmarshallerImpl.java:154)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:291)
......
和第二名:
java.lang.IllegalStateException: Unable to perform operation: post construct on fish.payara.microprofile.metrics.MetricsService
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:393)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:487)
at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:305)
at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:89)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2126)
......
编辑3
好的,编辑2中的问题是XERCES版本错误,我已升级到新版本,然后我收到此错误:
SEVERE: Exception while loading the app : javax.ejb.CreateException: Initialization failed for Singleton SynchronizationRunnerTimer
javax.ejb.CreateException: Initialization failed for Singleton SynchronizationRunnerTimer
at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:564)
at com.sun.ejb.containers.AbstractSingletonContainer.access$000(AbstractSingletonContainer.java:78)
.......
Caused by: java.lang.NullPointerException
at org.glassfish.weld.services.JCDIServiceImpl.createInterceptorInstance(JCDIServiceImpl.java:397)
at com.sun.ejb.containers.BaseContainer.createEjbInterceptors(BaseContainer.java:1799)
at com.sun.ejb.containers.BaseContainer.createEmptyContextAndInterceptors(BaseContainer.java:1694)
at com.sun.ejb.containers.BaseContainer.createEjbInstanceAndContext(BaseContainer.java:1708)
... 123 more
检查更多日志信息我可以找到这一行:
SEVERE: The annotation symbol defined in super-class is not compatible with Session ejb SynchronizationRunnerTimer.
symbol: TYPE location: class cz.autocont.idm.synchronization.SynchronizationRunnerBase
class SynchronizationRunnerTimer:
@Singleton
@Startup
@Lock(LockType.READ)
public class SynchronizationRunnerTimer extends SynchronizationRunnerBase
{
class synchronizationRunner:
@Stateless
public class SynchronizationRunner extends SynchronizationRunnerBase implements ManagedSchedule
{
class SynchronizationRunnerBase:
@Stateless
public class SynchronizationRunnerBase
{
编辑4
好的,我已经解决了我的注释问题。但是现在我又收到了另一个错误。
B�e 07, 2018 1:44:22 ODP. org.glassfish.kernel.event.EventsImpl send
WARNING: Exception while dispatching an event
org.glassfish.api.invocation.InvocationException
at org.glassfish.api.invocation.InvocationManagerImpl.postInvoke(InvocationManagerImpl.java:178)
at org.glassfish.weld.WeldDeployer.processApplicationLoaded(WeldDeployer.java:522)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:426)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:333)
at com.sun.enterprise.v3.server.ApplicationLifecycle.prepare(ApplicationLifecycle.java:493)
这真的很奇怪,因为我找不到这个错误,所以我不知道该搜索什么。
答案 0 :(得分:2)
Payara 5.Beta2中的已知问题已修复here。它将于本月晚些时候在Payara 5.181发布。通过将您的pom中的Payara版本更改为5.181-SNAPSHOT
,您可以使用包含此修复程序的快照,每晚使用最新版本。
您可能需要通过添加
将快照存储库添加到您的pom<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
编辑:
对于您的EJB错误,这是因为SynchronizationRunnerTimer
使用@Singleton
进行了注释,但它从@Stateless
继承了SynchronizationRunnerBase
。这是导致错误的原因,因为两个范围不兼容,bean可以是Stateless
或Singleton
,但不能同时是两者。从其中一个中删除范围注释将允许它作为Singleton
或Stateless
范围内的bean工作。