Przemysław Furmańczyk
2018-10-18 16:09:27 UTC
Good afternoon,
I have troubles with configuring OpenEJB with our application. My project
contains multiple modules. Let's say it looks like that:
- MyApp â enterprise application to be used as deployable unit,
- MyApp-B â EJB module with service facade implementations and resource
access components to integrate external resources,
- MyApp-BC â EJB client module containing all service facade interfaces
and the domain model,
- MyApp-UI â web application providing the user interface,
- MyApp-WS â web application exposing web services endpoints for service
facades,
- MyApp-D â module storing DAOs,
- MyApp-RWS â module storing REST web services.
I wanted to start with module B as a main place for configuration (module
MyApp-BC will be probably the main one). And what I did here is:
1. I put in *pom.xml* these extra dependencies:
<dependency>
<groupId>com.myapp</groupId>
<artifactId>MyApp-BC</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-junit</artifactId>
<version>4.7.5</version>
<exclusions>
<exclusion>
<artifactId>slf4j-jdk14</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-jee</artifactId>
<version>4.7.5</version>
</dependency>
1. Inside of root folder for this module, I've created *conf* folder
with *openejb.xml*, where I defined as a Resource my DB connection.
2. Created a file *application-client.xml** in
*src/test/resources/META-INF* with content:
<?xml version="1.0" encoding="UTF-8"?>
<application-client/>
1. And under *src/main/test* directory created new test:
@ContextConfig(properties = {
@Property("java.naming.factory.initial=org.apache.openejb.core.LocalInitialContextFactory"),
@Property("openejb.deployments.classpath.exclude=.*\\.jar"),
// @Property("openejb.tempclassloader.skip=annotations"),
// @Property("openejb.altdd.prefix=test-"),
@Property("openejb.deployments.classpath.filter.descriptors=true") })
@RunTestAs("Authenticated")
@RunWith(OpenEjbRunner.class)
@LocalClient
public class MyTestClassImplIntegrationTest {
@EJB
private MyTestClassImpl myTestClassImpl;
@Test
public void testMethod() {
// some code for test method
}
}
1. The multiple *@Property* annotations I took from our inside
guideline. The commented one, I get from trying to find solution on
internet. For @Property("openejb.altdd.prefix=test-") I've created
duplicated file of mine *ejb-jar.xml*. In both *ejb-jar* files I have
something like that:
<session>
<ejb-name>CacheManager</ejb-name>
<ejb-class>com.myapp.cache.CacheManager</ejb-class>
<resource-ref>
<res-ref-name>MyApp/Cache</res-ref-name>
<res-type>com.ibm.websphere.cache.DistributedMap</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</session>
The *CacheManager* class is located in MyApp-BC module.
When I try to run the test in Eclipse I get the error from
*Console_output.txt* and *JUnit_logs.txt*
So I tried to remove <ejb-class>com.myapp.cache.CacheManager</ejb-class> from
both *ejb-jar* files, but then I receive this error: *Console_output_2.txt*
Am I missing something or OpenEJB just doesnât work with DistributedMap
from IBM?
I would really appreciate your help.
Best regards,
Przemek
I have troubles with configuring OpenEJB with our application. My project
contains multiple modules. Let's say it looks like that:
- MyApp â enterprise application to be used as deployable unit,
- MyApp-B â EJB module with service facade implementations and resource
access components to integrate external resources,
- MyApp-BC â EJB client module containing all service facade interfaces
and the domain model,
- MyApp-UI â web application providing the user interface,
- MyApp-WS â web application exposing web services endpoints for service
facades,
- MyApp-D â module storing DAOs,
- MyApp-RWS â module storing REST web services.
I wanted to start with module B as a main place for configuration (module
MyApp-BC will be probably the main one). And what I did here is:
1. I put in *pom.xml* these extra dependencies:
<dependency>
<groupId>com.myapp</groupId>
<artifactId>MyApp-BC</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-junit</artifactId>
<version>4.7.5</version>
<exclusions>
<exclusion>
<artifactId>slf4j-jdk14</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-jee</artifactId>
<version>4.7.5</version>
</dependency>
1. Inside of root folder for this module, I've created *conf* folder
with *openejb.xml*, where I defined as a Resource my DB connection.
2. Created a file *application-client.xml** in
*src/test/resources/META-INF* with content:
<?xml version="1.0" encoding="UTF-8"?>
<application-client/>
1. And under *src/main/test* directory created new test:
@ContextConfig(properties = {
@Property("java.naming.factory.initial=org.apache.openejb.core.LocalInitialContextFactory"),
@Property("openejb.deployments.classpath.exclude=.*\\.jar"),
// @Property("openejb.tempclassloader.skip=annotations"),
// @Property("openejb.altdd.prefix=test-"),
@Property("openejb.deployments.classpath.filter.descriptors=true") })
@RunTestAs("Authenticated")
@RunWith(OpenEjbRunner.class)
@LocalClient
public class MyTestClassImplIntegrationTest {
@EJB
private MyTestClassImpl myTestClassImpl;
@Test
public void testMethod() {
// some code for test method
}
}
1. The multiple *@Property* annotations I took from our inside
guideline. The commented one, I get from trying to find solution on
internet. For @Property("openejb.altdd.prefix=test-") I've created
duplicated file of mine *ejb-jar.xml*. In both *ejb-jar* files I have
something like that:
<session>
<ejb-name>CacheManager</ejb-name>
<ejb-class>com.myapp.cache.CacheManager</ejb-class>
<resource-ref>
<res-ref-name>MyApp/Cache</res-ref-name>
<res-type>com.ibm.websphere.cache.DistributedMap</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</session>
The *CacheManager* class is located in MyApp-BC module.
When I try to run the test in Eclipse I get the error from
*Console_output.txt* and *JUnit_logs.txt*
So I tried to remove <ejb-class>com.myapp.cache.CacheManager</ejb-class> from
both *ejb-jar* files, but then I receive this error: *Console_output_2.txt*
Am I missing something or OpenEJB just doesnât work with DistributedMap
from IBM?
I would really appreciate your help.
Best regards,
Przemek