我有一个叫做“数据库”的项目,它是另一个项目"WEB“的模块,我需要为这个”数据库“项目创建单元测试,但是我很难让payara工作。当我尝试在WildFly 10容器上开始单元测试时,我可以让它工作。但是现在在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)
...我认为这些依赖应该足够了,但我确实遗漏了一些东西.
这是我在payara的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-Resourcees.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");有人能帮我吗?
编辑
好的,所以我发现这是依赖问题。我的依赖之一是使用番石榴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最后
编辑2
在我切换到5.181版本的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.SynchronizationRunnerBaseSynchronizationRunnerTimer类:
@Singleton
@Startup
@Lock(LockType.READ)
public class SynchronizationRunnerTimer extends SynchronizationRunnerBase
{synchronizationRunner类:
@Stateless
public class SynchronizationRunner extends SynchronizationRunnerBase implements ManagedSchedule
{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)这真的很奇怪,因为我找不到关于这个错误的太多信息,所以我不知道该搜索什么。
发布于 2018-03-05 15:03:26
这是一个已知的问题,在Payara 5,been 2,已经修复了这里。它将于本月晚些时候在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注释的,但是它从SynchronizationRunnerBase继承了@Stateless。这是导致错误的原因,因为这两个作用域不兼容,bean可以是Stateless或Singleton,但不能两者兼而有之。从其中之一移除范围注释将允许其工作,如Singleton或Stateless-scoped bean。
https://stackoverflow.com/questions/49071239
复制相似问题