I have this simple service class:
@ApplicationScoped
@Transactional
public class MyService {
public String myTransactionalMethod(){
return "hello";
}
}
With this simple test class:
@RunWithApplicationComposer
@Classes(cdi = true, value = MyService.class)
class MyServiceTest {
@Inject MyService myService;
@Test
void myTransactionalMethod() {
Assertions.assertDoesNotThrow(() ->myService.myTransactionalMethod());
}
}
However, when i try to run it i get this error:
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: unable to load properties from jar:file:/home/antonio/.m2/repository/org/jboss/narayana/jta/narayana-jta/5.11.2.Final/narayana-jta-5.11.2.Final.jar!/jbossts-properties.xml
at com.arjuna.common.internal.util.propertyservice.BeanPopulator.getNamedInstance(BeanPopulator.java:90)
at com.arjuna.common.internal.util.propertyservice.BeanPopulator.getDefaultInstance(BeanPopulator.java:53)
at com.arjuna.ats.jta.cdi.NarayanaTransactionManager.lambda$new$0(NarayanaTransactionManager.java:150)
at com.arjuna.ats.jta.cdi.NarayanaTransactionManager.getDelegate(NarayanaTransactionManager.java:240)
at com.arjuna.ats.jta.cdi.NarayanaTransactionManager.<init>(NarayanaTransactionManager.java:178)
at com.arjuna.ats.jta.cdi.NarayanaTransactionManager.<init>(NarayanaTransactionManager.java:150)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.apache.webbeans.inject.InjectableConstructor.doInjection(InjectableConstructor.java:72)
at org.apache.webbeans.portable.InjectionTargetImpl.newInstance(InjectionTargetImpl.java:201)
at org.apache.webbeans.portable.InjectionTargetImpl.produce(InjectionTargetImpl.java:184)
at org.apache.webbeans.portable.AbstractProducer.produce(AbstractProducer.java:134)
at org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:124)
at org.apache.webbeans.component.ManagedBean.create(ManagedBean.java:66)
at org.apache.webbeans.context.creational.BeanInstanceBag.create(BeanInstanceBag.java:76)
at org.apache.webbeans.context.AbstractContext.getInstance(AbstractContext.java:159)
at org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:101)
at org.apache.webbeans.intercept.ApplicationScopedBeanInterceptorHandler.getContextualInstance(ApplicationScopedBeanInterceptorHandler.java:65)
at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:71)
at com.arjuna.ats.jta.cdi.NarayanaTransactionManager$$OwbNormalScopeProxy0.getTransaction(com/arjuna/ats/jta/cdi/NarayanaTransactionManager.java)
at com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorBase.intercept(TransactionalInterceptorBase.java:83)
at com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorRequired.intercept(TransactionalInterceptorRequired.java:47)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.webbeans.component.InterceptorBean.intercept(InterceptorBean.java:136)
at org.apache.webbeans.intercept.InterceptorInvocationContext.proceed(InterceptorInvocationContext.java:65)
What can be the cause? Why is it even mentioning Narayana in the first place? Shouldn't I be using Apache Geronimo? Also, this should be a Unit test and for this reason i should ignore all the transactional decorations anyway.
This is what I'm using:
This is the pom.xml
<properties>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<junit.version>5.8.2</junit.version>
<mockito.version>4.2.0</mockito.version>
<tomee.version>8.0.8</tomee.version>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.6.2.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.27</version>
</dependency>
<dependency>
<groupId>org.apache.bval</groupId>
<artifactId>bval-jsr</artifactId>
<version>2.0.5</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>8.0.1</version>
<scope>provided</scope>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>ch.vorburger.mariaDB4j</groupId>
<artifactId>mariaDB4j</artifactId>
<version>2.5.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>rocks.limburg.cdimock</groupId>
<artifactId>cdimock</artifactId>
<version>1.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-testing</artifactId>
<version>5.6.2.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomee</groupId>
<artifactId>openejb-junit5</artifactId>
<version>${tomee.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomee</groupId>
<artifactId>openejb-mockito</artifactId>
<version>${tomee.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>shareboard</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<warName>${artifactId}</warName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<disableXmlReport>true</disableXmlReport>
<useFile>false</useFile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<configLocation>google_checks.xml</configLocation>
</configuration>
</plugin>
</plugins>
</reporting>
Also, the entire TomEE8.0.8/lib
folder is included in the classpath
The Application Composer shouldn't read any external configuration file, so they shouldn't be an issue.
What could be the reason? This kind of tests worked before. Something in the classpath must have changed but I really can't explain what could possibly have changed.
I solved the problem by removing the hibernate-testing
dependency. I don't have any technical explaination for it unfortunately
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.