Michal Heneš
Michal Heneš

Reputation: 310

Arquillian Payara (Glassfish) Embedded won't start

I have this project called "Database" and it's module of another project "WEB" and I need to create UNIT tests for this "Database" project but I'm struggling to make payara to work. When I tried start UNIT tests on WildFly 10 Container I could make it work. But now on payara I'm stuck on this error:

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)
    ...

I'd assume that these dependencies should be enough, but certainly I'm missing something...

this is my POM for payara

<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 like this:

<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>

And glassfish-resources.xml like this:

<?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>

I'm creating WebArchive in my test class like this:

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");

Could anybody help me ?


EDIT

Ok, so I found out that it was dependency problem. One of my dependency was using GUAVA 13, so I put it into exclusions, but then I've got another exceptions that I cannot solve

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

Even tried examples how to solve it here on stack, but no results. Any answer or suggestion would help.

I am using:
Java 8
Hibernate 5.2.2.Final


EDIT 2

After I switched to version 5.181-SNAPSHOT of payara. there seems to be another exceptions (2 to be correct)
1st:

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)
......

and 2nd:

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)
......


EDIT 3

Ok, the problem in EDIT 2 was wrong version of XERCES, I've upgraded to newer version and then I got this error:

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

Checking further log info I can find this line:

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
{

EDIT 4

Ok, I have solved my Annotation problem. However now I'm getting another error.

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)

It is really strange because I cannot find much about this error, so I don't know what to search.

Upvotes: 2

Views: 1160

Answers (1)

Jonathan Coustick
Jonathan Coustick

Reputation: 1157

This is a known issue in Payara 5.Beta2 that has been fixed here. It will be released in Payara 5.181 later this month. You can use a snapshot containing the fix by using latest nightly by changing in Payara version in your pom to 5.181-SNAPSHOT.

You may need to add the snapshots repository to your pom by adding

<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>

EDIT:

For your EJB error, that is because SynchronizationRunnerTimer is annotated with @Singleton but it inherits @Stateless from SynchronizationRunnerBase. This is what is causing the error as the two scopes are not compatible, a bean can be either Stateless or Singleton, but not both. Removing the scope annotation from one of them will allow it to work, as either a Singleton or Stateless-scoped bean.

Upvotes: 2

Related Questions