Problem with OpenEJB configuration

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with OpenEJB configuration

Przemek
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

Console_output.txt (21K) Download Attachment
JUnit_logs.txt (3K) Download Attachment
Console_output_2.txt (14K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem with OpenEJB configuration

exabrial12
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
Reply | Threaded
Open this post in threaded view
|

Re: Problem with OpenEJB configuration

Przemek
This post was updated on .
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:
<Resource id="MyApp/Cache" type="com.ibm.websphere.cache.DistributedMap" jndi="MyApp/CacheObject" class-name="com.myapp.cache.CacheManager" />
And now I'm getting following output:
INFO - ********************************************************************************
INFO - OpenEJB http://tomee.apache.org/
INFO - Startup: Fri Oct 19 11:03:02 CEST 2018
INFO - Copyright 1999-2015 (C) Apache OpenEJB/TomEE Project, All Rights Reserved.
INFO - Version: 4.7.5
INFO - Build date: 20170927
INFO - Build time: 12:02
INFO - ********************************************************************************
INFO - openejb.home = C:\myapp\myapp-B
INFO - openejb.base = C:\myapp\myapp-B
INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@20c48ef5
INFO - Succeeded in installing singleton service
INFO - Using 'openejb.altdd.prefix=test-'
INFO - openejb configuration file is 'C:\myapp\myapp-B\conf\openejb.xml'
INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Configuring Service(id=jdbc/MyApp-Oracle, type=Resource, provider-id=Default JDBC Database)
INFO - Configuring Service(id=MyApp/Cache, type=Resource, provider-id=MyApp/Cache)
INFO - Using 'openejb.deployments.classpath.exclude=.*\.jar'
INFO - Using 'openejb.deployments.classpath.filter.descriptors=true'
INFO - Found EjbModule in classpath: c:\myapp\myapp-B\target\classes
INFO - Found ClientModule in classpath: c:\myapp\myapp-B\target\test-classes
INFO - Found EjbModule in classpath: c:\myapp\myapp-BC\target\classes
INFO - Beginning load: c:\myapp\myapp-B\target\classes
INFO - AltDD ejb-jar.xml -> file:/c:/myapp/myapp-B/target/classes/META-INF/test-ejb-jar.xml
INFO - Beginning load: c:\myapp\myapp-B\target\test-classes
INFO - Beginning load: c:\myapp\myapp-BC\target\classes
INFO - Configuring enterprise application: C:\myapp\myapp-B\classpath.ear
INFO - Auto-deploying ejb PropertiesEJB: EjbDeployment(deployment-id=PropertiesEJB)
INFO - Auto-deploying ejb MyProcedureBean: EjbDeployment(deployment-id=MyStoredProcedureBean)
INFO - Auto-deploying ejb CacheManager: EjbDeployment(deployment-id=CacheManager)
INFO - Auto-deploying ejb SearchPageDataBean: EjbDeployment(deployment-id=SearchPageDataBean)
INFO - Auto-deploying ejb MyAppStatusGeneratorImpl: EjbDeployment(deployment-id=MyAppStatusGeneratorImpl)
INFO - Auto-deploying ejb InitialDataCommiter: EjbDeployment(deployment-id=InitialDataCommiter)
INFO - Auto-deploying ejb InterruptProcessResponseGeneratorImpl: EjbDeployment(deployment-id=InterruptProcessResponseGeneratorImpl)
INFO - Auto-deploying ejb CacheManager: EjbDeployment(deployment-id=CacheManager)
INFO - Auto-deploying ejb PropertiesAccessor: EjbDeployment(deployment-id=PropertiesAccessor)
INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
INFO - Auto-creating a container for bean PropertiesEJB: Container(type=STATELESS, id=Default Stateless Container)
INFO - Auto-linking resource-ref 'MyApp/Cache' in bean CacheManager to Resource(id=MyApp/Cache)
INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
INFO - Auto-creating a container for bean MyApp-EBA-B.Comp-729457898: Container(type=MANAGED, id=Default Managed Container)
INFO - Auto-linking resource-ref 'java:comp/env/jdbc/DB2' in bean MyApp-EBA-B.Comp-729457898 to Resource(id=jdbc/MyApp-Oracle)
INFO - Auto-linking resource-ref 'java:comp/env/MyApp/Cache' in bean CacheManager to Resource(id=MyApp/Cache)
INFO - Dumping Generated ejb-jar.xml to: C:\Users\lui\AppData\Local\Temp\ejb-jar-7457108007618284071MyApp-EBA-B.xml
INFO - Dumping Generated ejb-jar.xml to: C:\Users\lui\AppData\Local\Temp\ejb-jar-2819100474220163732MyApp-EBA-BC.xml
INFO - Unresolved ejb reference "java:comp/env/com.myapp.utilities.SearchPageDataBean/persistenceFactory" in bean "MyApp-EBA-B.Comp".  Will attempt resolution again at runtime.
INFO - Unresolved ejb reference "java:comp/env/com.myapp.business.InitialDataCommiter/cachePersistence" in bean "MyApp-EBA-B.Comp".  Will attempt resolution again at runtime.
INFO - Unresolved ejb reference "java:comp/env/com.myapp.ws.InterruptProcessResponseGeneratorImpl/persistenceFactory" in bean "MyApp-EBA-B.Comp".  Will attempt resolution again at runtime.
INFO - Unresolved ejb reference "java:comp/env/com.myapp.ws.MyAppStatusGeneratorImpl/persistenceFactory" in bean "MyApp-EBA-B.Comp".  Will attempt resolution again at runtime.
ERROR - FAIL ... PropertiesAccessorInterface:	@Stateless cannot be applied to an interface: com.myapp.domain.session.interfaces.PropertiesAccessorInterface
ERROR - Invalid EjbModule(name=MyApp-EBA-B, path=C:\myapp\myapp-B\target\classes)
ERROR - FAIL ... PropertiesAccessorInterface:	@Stateless cannot be applied to an interface: com.myapp.domain.session.interfaces.PropertiesAccessorInterface
ERROR - Invalid EjbModule(name=MyApp-EBA-BC, path=C:\myapp\myapp-BC\target\classes)
INFO - Set the 'openejb.validation.output.level' system property to VERBOSE for increased validation details.
WARN - Jar not loaded. classpath.ear.  Module failed validation. AppModule(name=classpath.ear)
INFO - Creating TransactionManager(id=Default Transaction Manager)
INFO - Creating SecurityService(id=Default Security Service)
INFO - Using 'java.security.auth.login.config=jar:file:/C:/mvnLocalRepo/org/apache/openejb/openejb-junit/4.7.5/openejb-junit-4.7.5.jar!/META-INF/openejb-test-login.config'
INFO - Creating Resource(id=jdbc/MyApp-Oracle)
INFO - Creating Resource(id=MyApp/Cache)
INFO - Creating Container(id=Default Stateless Container)
INFO - Creating Container(id=Default Managed Container)
INFO - Using directory C:\Users\lui\AppData\Local\Temp for stateful session passivation
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
@Stateless PersistanceFactoryObject implements PersistanceFactory
which is part of MyApp-D module? And what is more, for example SearchPageDataBean looks like that:
@Stateless
public class SearchPageDataBean implements SearchPageData {

	@EJB
	private PersistanceFactory persistenceFactory;

        // some code
}
I have no idea what I'm doing wrong... Knowing my luck, it's something trivial or very hard...

EDIT:
When I removed @Stateless annotation for PropertiesAccessorInterface then I receive this:
INFO - ********************************************************************************
INFO - OpenEJB http://tomee.apache.org/
INFO - Startup: Fri Oct 19 15:29:34 CEST 2018
INFO - Copyright 1999-2015 (C) Apache OpenEJB/TomEE Project, All Rights Reserved.
INFO - Version: 4.7.5
INFO - Build date: 20170927
INFO - Build time: 12:02
INFO - ********************************************************************************
INFO - openejb.home = C:\myapp\myapp-B
INFO - openejb.base = C:\myapp\myapp-B
INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@7a7fbab6
INFO - Succeeded in installing singleton service
INFO - openejb configuration file is 'C:\myapp\myapp-B\conf\openejb.xml'
INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Configuring Service(id=jdbc/MyApp-Oracle, type=Resource, provider-id=Default JDBC Database)
INFO - Configuring Service(id=CacheManager, type=Resource, provider-id=CacheManager)
INFO - Using 'openejb.deployments.classpath.exclude=.*\.jar'
INFO - Using 'openejb.deployments.classpath.filter.descriptors=true'
INFO - Found EjbModule in classpath: c:\myapp\myapp-B\target\classes
INFO - Found ClientModule in classpath: c:\myapp\myapp-B\target\test-classes
INFO - Found EjbModule in classpath: c:\myapp\myapp-bc\target\classes
INFO - Beginning load: c:\myapp\myapp-B\target\classes
INFO - Beginning load: c:\myapp\myapp-B\target\test-classes
INFO - Beginning load: c:\myapp\myapp-bc\target\classes
INFO - Configuring enterprise application: C:\myapp\myapp-B\classpath.ear
INFO - Auto-deploying ejb PropertiesEJB: EjbDeployment(deployment-id=PropertiesEJB)
INFO - Auto-deploying ejb MyProcedureBean: EjbDeployment(deployment-id=MyProcedureBean)
INFO - Auto-deploying ejb CacheManager: EjbDeployment(deployment-id=CacheManager)
INFO - Auto-deploying ejb SearchPageDataBean: EjbDeployment(deployment-id=SearchPageDataBean)
INFO - Auto-deploying ejb MyAppStatusGeneratorImpl: EjbDeployment(deployment-id=MyAppStatusGeneratorImpl)
INFO - Auto-deploying ejb InitialDataCommiter: EjbDeployment(deployment-id=InitialDataCommiter)
INFO - Auto-deploying ejb InterruptProcessResponseGeneratorImpl: EjbDeployment(deployment-id=InterruptProcessResponseGeneratorImpl)
INFO - Auto-deploying ejb CacheManager: EjbDeployment(deployment-id=CacheManager)
INFO - Auto-deploying ejb PropertiesAccessor: EjbDeployment(deployment-id=PropertiesAccessor)
INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
INFO - Auto-creating a container for bean PropertiesEJB: Container(type=STATELESS, id=Default Stateless Container)
INFO - Auto-linking resource-ref 'MyApp/Cache' in bean CacheManager to Resource(id=CacheManager)
INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
INFO - Auto-creating a container for bean MyApp-EBA-B.Comp2017345524: Container(type=MANAGED, id=Default Managed Container)
INFO - Auto-linking resource-ref 'java:comp/env/jdbc/DB2' in bean MyApp-EBA-B.Comp2017345524 to Resource(id=jdbc/MyApp-Oracle)
INFO - Auto-linking resource-ref 'java:comp/env/MyApp/Cache' in bean CacheManager to Resource(id=CacheManager)
INFO - Unresolved ejb reference "java:comp/env/com.myapp.utilities.SearchPageDataBean/persistenceFactory" in bean "MyApp-EBA-B.Comp".  Will attempt resolution again at runtime.
INFO - Unresolved ejb reference "java:comp/env/com.myapp.business.InitialDataCommiter/cachePersistence" in bean "MyApp-EBA-B.Comp".  Will attempt resolution again at runtime.
INFO - Unresolved ejb reference "java:comp/env/com.myapp.ws.InterruptProcessResponseGeneratorImpl/persistenceFactory" in bean "MyApp-EBA-B.Comp".  Will attempt resolution again at runtime.
INFO - Unresolved ejb reference "java:comp/env/com.myapp.ws.MyAppStatusGeneratorImpl/persistenceFactory" in bean "MyApp-EBA-B.Comp".  Will attempt resolution again at runtime.
INFO - Unresolved ejb reference "java:comp/env/com.myapp.MyTestClassImplIntegrationTest/myappStatusGeneratorImpl" in bean "c:\myapp\myapp-B\target\test-classes".  Will attempt resolution again at runtime.
INFO - Enterprise application "C:\myapp\myapp-B\classpath.ear" loaded.
INFO - Creating TransactionManager(id=Default Transaction Manager)
INFO - Creating SecurityService(id=Default Security Service)
INFO - Using 'java.security.auth.login.config=jar:file:/C:/mvnLocalRepo/org/apache/openejb/openejb-junit/4.7.5/openejb-junit-4.7.5.jar!/META-INF/openejb-test-login.config'
INFO - Creating Resource(id=jdbc/MyApp-Oracle)
INFO - Creating Resource(id=CacheManager)
INFO - Creating Container(id=Default Stateless Container)
INFO - Creating Container(id=Default Managed Container)
INFO - Using directory C\Users\lui\AppData\Local\Temp for stateful session passivation
INFO - Assembling app: C:\myapp\myapp-B\classpath.ear
INFO - Jndi(name=PropertiesEJBLocalBean) --> Ejb(deployment-id=PropertiesEJB)
INFO - Jndi(name=global/classpath.ear/MyApp-EBA-B/PropertiesEJB!com.myapp.business.session.PropertiesEJB) --> Ejb(deployment-id=PropertiesEJB)
INFO - Jndi(name=global/classpath.ear/MyApp-EBA-B/PropertiesEJB) --> Ejb(deployment-id=PropertiesEJB)
INFO - Jndi(name=CacheManagerLocalBean) --> Ejb(deployment-id=CacheManager)
INFO - Jndi(name=global/classpath.ear/MyApp-EBA-B/CacheManager!com.myapp.cache.CacheManager) --> Ejb(deployment-id=CacheManager)
INFO - Jndi(name=global/classpath.ear/MyApp-EBA-B/CacheManager) --> Ejb(deployment-id=CacheManager)
INFO - Jndi(name=PropertiesAccessorLocal) --> Ejb(deployment-id=PropertiesAccessor)
INFO - Jndi(name=global/classpath.ear/MyApp-EBA-B/PropertiesAccessor!com.myapp.domain.session.interfaces.PropertiesAccessorInterface) --> Ejb(deployment-id=PropertiesAccessor)
INFO - Jndi(name=global/classpath.ear/MyApp-EBA-B/PropertiesAccessor) --> Ejb(deployment-id=PropertiesAccessor)
INFO - Jndi(name=SearchPageDataBeanLocal) --> Ejb(deployment-id=SearchPageDataBean)
INFO - Jndi(name=global/classpath.ear/MyApp-EBA-B/SearchPageDataBean!com.myapp.utilities.SearchPageData) --> Ejb(deployment-id=SearchPageDataBean)
INFO - Jndi(name=global/classpath.ear/MyApp-EBA-B/SearchPageDataBean) --> Ejb(deployment-id=SearchPageDataBean)
INFO - Jndi(name=InitialDataCommiterLocalBean) --> Ejb(deployment-id=InitialDataCommiter)
INFO - Jndi(name=global/classpath.ear/MyApp-EBA-B/InitialDataCommiter!com.myapp.business.InitialDataCommiter) --> Ejb(deployment-id=InitialDataCommiter)
INFO - Jndi(name=global/classpath.ear/MyApp-EBA-B/InitialDataCommiter) --> Ejb(deployment-id=InitialDataCommiter)
INFO - Jndi(name=MyAppStatusGeneratorImplLocal) --> Ejb(deployment-id=MyAppStatusGeneratorImpl)
INFO - Jndi(name=global/classpath.ear/MyApp-EBA-B/MyAppStatusGeneratorImpl!com.myapp.ws.MyAppStatusGenerator) --> Ejb(deployment-id=MyAppStatusGeneratorImpl)
INFO - Jndi(name=global/classpath.ear/MyApp-EBA-B/MyAppStatusGeneratorImpl) --> Ejb(deployment-id=MyAppStatusGeneratorImpl)
ERROR - Jndi name could not be bound; it may be taken by another ejb.  Jndi(name=openejb/Deployment/CacheManager/com.myapp.cache.CacheManager!LocalBeanHome)
INFO - Undeploying app: C:\myapp\myapp-B\classpath.ear
INFO - Using 'openjpa.Log=org.apache.openejb.openjpa.JULOpenJPALogFactory'
INFO - Undeployed app: C:\myapp\myapp-B\classpath.ear
ERROR - Application could not be deployed:  C:\myapp\myapp-B\classpath.ear
org.apache.openejb.OpenEJBException: Creating application failed: C:\myapp\myapp-B\classpath.ear: Unable to bind business remote deployment in jndi.
	at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:853)
	at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:685)
	at org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(Assembler.java:576)
	at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:467)
	at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:151)
	at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:68)
	at org.apache.openejb.OpenEJB.init(OpenEJB.java:309)
	at org.apache.openejb.OpenEJB.init(OpenEJB.java:289)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
	at java.lang.reflect.Method.invoke(Method.java:508)
	at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
	at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:98)
	at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:62)
	at org.apache.openejb.core.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:46)
	at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:695)
	at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:324)
	at javax.naming.InitialContext.init(InitialContext.java:255)
	at javax.naming.InitialContext.<init>(InitialContext.java:227)
	at org.apache.openejb.junit.context.OpenEjbTestContext.getInitialContext(OpenEjbTestContext.java:161)
	at org.apache.openejb.junit.context.OpenEjbTestContext.configureTest(OpenEjbTestContext.java:122)
	at org.apache.openejb.junit.context.ContextWrapperStatement.evaluate(ContextWrapperStatement.java:37)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.apache.openejb.junit.OpenEjbRunner.run(OpenEjbRunner.java:119)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: org.apache.openejb.OpenEJBRuntimeException: Unable to bind business remote deployment in jndi.
	at org.apache.openejb.assembler.classic.JndiBuilder.bind(JndiBuilder.java:448)
	at org.apache.openejb.assembler.classic.JndiBuilder.build(JndiBuilder.java:92)
	at org.apache.openejb.assembler.classic.Assembler.initEjbs(Assembler.java:1307)
	at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:776)
	... 38 more
Caused by: javax.naming.NameAlreadyBoundException: openejb/Deployment/CacheManager/com.myapp.cache.CacheManager!LocalBeanHome
	at org.apache.openejb.assembler.classic.JndiBuilder.bind(JndiBuilder.java:661)
	at org.apache.openejb.assembler.classic.JndiBuilder.bind(JndiBuilder.java:436)
	... 41 more
Reply | Threaded
Open this post in threaded view
|

Re: Problem with OpenEJB configuration

Matthew Broadhead-2
In reply to this post by Przemek
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

Reply | Threaded
Open this post in threaded view
|

Re: Problem with OpenEJB configuration

Przemek
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