You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Przemysław Furmańczyk <fu...@gmail.com> on 2018/10/18 16:09:27 UTC
Problem with OpenEJB configuration
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
Re: Problem with OpenEJB configuration
Posted by Przemek <fu...@gmail.com>.
Hi,
Thanks for your reply.
Unfortunately, I can't really share with this, because it is company project
and what I described is just an example. And what is more, it is really big
output.
I added to *openejb.xml* new resource for my cache:
And now I'm getting following output:
The fail message about /PropertiesAccessorInterface/ is right. We have an
interface with /@Stateless /annotation. But I can't understand the message
about *"Unresolved ejb reference"*, especially when these classes has been
auto-deployed (*"Auto-deploying ejb"*). Could it be because of that which
is part of MyApp-D module? And what is more, for example SearchPageDataBean
looks like that:
I have no idea what I'm doing wrong... Knowing my luck, it's something
trivial or very hard...
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Re: Problem with OpenEJB configuration
Posted by exabrial12 <ex...@gmail.com>.
Very strange :) Can you start the jvm with "-verbose:class" and attach the
output? I'm curious what's being loaded.
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Re: Problem with OpenEJB configuration
Posted by Przemek <fu...@gmail.com>.
It's from MyApp-BC module. And it comes from our custom library, which
already contains this DistributedMap.
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Re: Problem with OpenEJB configuration
Posted by Matthew Broadhead <ma...@nbmlaw.co.uk.INVALID>.
which package is it getting com.ibm.websphere.cache.DistributedMap from?
On 18/10/2018 18:09, Przemysław Furmańczyk wrote:
> 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>
>
> 2. Inside of root folder for this module, I've created /conf/ folder
> with *openejb.xml*, where I defined as a Resource my DB connection.
> 3. Created a file *application-client.xml** in
> /src/test/resources/META-INF/ with content:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <application-client/>
>
> 4. 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
> }
> }
>
> 5. 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