You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Mansour Al Akeel <ma...@gmail.com> on 2014/10/13 07:40:29 UTC
Multiple persistence.xml in different jars
I am writing unit tests. The unit test include multiple jars, each of
them has JPA entities and persistence.xml file. Each file has it's own
Persistence Context.
The JPA entities in jar B references some entities in jar file A. I
need to load both persistence.xml.
Is there a way to instruct openejb container to scan for other
persistence.xml in different jars ??
Re: Multiple persistence.xml in different jars
Posted by Romain Manni-Bucau <rm...@gmail.com>.
both versions are not compatible so surely it is ;)
Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau
2014-10-15 1:49 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
> I will try to locate the file you mentioned "scan.xml" and have a look.
> There could be many possibilities. The one that comes to my mind is
> the two versions of OpenEJB jars.
> Since I am working with Maven plugin, the plugin references openejb
> 4.7.1 and the project I have has openejb as a dependency.
> When we execute the mojo, both jars are added to the classpath. I am
> not sure if this is the issue, but suspicious to me.
>
>
>
> On Tue, Oct 14, 2014 at 7:09 PM, Romain Manni-Bucau
> <rm...@gmail.com> wrote:
>> 2014-10-15 1:06 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>> upgrading to 4.7.1 resolved the problem, but now back again to a
>>> problem I saw earlier.
>>>
>>> Oct 14, 2014 6:59:22 PM org.apache.openejb.OpenEJB$Instance <init>
>>> SEVERE: OpenEJB has encountered a fatal error and cannot be started:
>>> The Assembler encountered an unexpected error while attempting to
>>> build the container system.
>>> java.lang.NoClassDefFoundError:
>>> org/perfectjpattern/jee/integration/dao/AbstractJpaManagedBaseDao
>>> at java.lang.ClassLoader.defineClass1(Native Method)
>>> at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
>>> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
>>> at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
>>> at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
>>> at java.security.AccessController.doPrivileged(Native Method)
>>> at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
>>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:205)
>>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:79)
>>> at org.apache.xbean.finder.archive.JarArchive.loadClass(JarArchive.java:84)
>>> at org.apache.xbean.finder.archive.CompositeArchive.loadClass(CompositeArchive.java:58)
>>> at org.apache.openejb.config.FinderFactory$DebugArchive.loadClass(FinderFactory.java:282)
>>> at org.apache.xbean.finder.AnnotationFinder$ClassInfo.get(AnnotationFinder.java:1453)
>>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:563)
>>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:512)
>>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:1406)
>>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:442)
>>> at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:356)
>>>
>>>
>>> The class IS in the class path, and available to the current project
>>> as maven dependency. I am not sure why I am getting this error, and
>>> has been stuck with it.
>>> A work around could be is to disable scanning for EJBs and allow only
>>> one EJB to be discovered.
>>> Is there a way to do this ?
>>>
>>
>> scan.xml would do it but weird the issue pops up like it, is it
>> possible openejb is in a lower classloader or
>> ParentClassLoaderFinder.Helper.get() is wrong?
>>
>>>
>>> On Tue, Oct 14, 2014 at 11:13 AM, Romain Manni-Bucau
>>> <rm...@gmail.com> wrote:
>>>> Maybe try a more recent version cause we changed several things and
>>>> some of them were impacting in maven environment.
>>>>
>>>>
>>>> Romain Manni-Bucau
>>>> @rmannibucau
>>>> http://www.tomitribe.com
>>>> http://rmannibucau.wordpress.com
>>>> https://github.com/rmannibucau
>>>>
>>>>
>>>> 2014-10-14 17:06 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>> No. I am using openejb embedded 4.6.0
>>>>>
>>>>>
>>>>> On Tue, Oct 14, 2014 at 10:43 AM, Romain Manni-Bucau
>>>>> <rm...@gmail.com> wrote:
>>>>>> asm4? you are not on tomee 1.7?
>>>>>>
>>>>>>
>>>>>> Romain Manni-Bucau
>>>>>> @rmannibucau
>>>>>> http://www.tomitribe.com
>>>>>> http://rmannibucau.wordpress.com
>>>>>> https://github.com/rmannibucau
>>>>>>
>>>>>>
>>>>>> 2014-10-14 16:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>>>> Thank you Romain.
>>>>>>> The target/classes was in the class path, but the size of the url array was 0.
>>>>>>>
>>>>>>> This was helpful. I am getting another error, that I was not able to understand.
>>>>>>>
>>>>>>> SEVERE: FATAL ERROR: Unknown error in Assembler. Please send the
>>>>>>> following stack trace and this message to users@openejb.apache.org :
>>>>>>> java.lang.IllegalArgumentException
>>>>>>> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
>>>>>>> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
>>>>>>> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
>>>>>>> at org.apache.openejb.util.AnnotationFinder.readClassDef(AnnotationFinder.java:297)
>>>>>>> at org.apache.openejb.util.AnnotationFinder.find(AnnotationFinder.java:163)
>>>>>>> at org.apache.openejb.config.DeploymentLoader.checkAnnotations(DeploymentLoader.java:1871)
>>>>>>> at org.apache.openejb.config.DeploymentLoader.discoverModuleType(DeploymentLoader.java:1782)
>>>>>>> at org.apache.openejb.config.DeploymentsResolver.processUrls(DeploymentsResolver.java:388)
>>>>>>> at org.apache.openejb.config.DeploymentsResolver.loadFromClasspath(DeploymentsResolver.java:301)
>>>>>>> at org.apache.openejb.config.ConfigurationFactory.getModulesFromClassPath(ConfigurationFactory.java:647)
>>>>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:524)
>>>>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:575)
>>>>>>> at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:429)
>>>>>>> at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:408)
>>>>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:148)
>>>>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
>>>>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:296)
>>>>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:276)
>>>>>>>
>>>>>>>
>>>>>>> I will continue digging.
>>>>>>>
>>>>>>> Thank you a lot.
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Oct 14, 2014 at 2:20 AM, Romain Manni-Bucau
>>>>>>> <rm...@gmail.com> wrote:
>>>>>>>> Hi
>>>>>>>>
>>>>>>>> we have a mojo like it
>>>>>>>> http://svn.apache.org/repos/asf/tomee/tomee/trunk/maven/openejb-embedded-maven-plugin/
>>>>>>>>
>>>>>>>> I think you miss target/classes in your loader
>>>>>>>>
>>>>>>>>
>>>>>>>> Romain Manni-Bucau
>>>>>>>> @rmannibucau
>>>>>>>> http://www.tomitribe.com
>>>>>>>> http://rmannibucau.wordpress.com
>>>>>>>> https://github.com/rmannibucau
>>>>>>>>
>>>>>>>>
>>>>>>>> 2014-10-14 6:37 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>>>>>> Romain,
>>>>>>>>> It was my fault. I was loading the persistence context using openjpa.
>>>>>>>>> However, switched to OpenEJB to allow scanning for the persistence.xml
>>>>>>>>> in other jars. The problem is the current jar has some EJBs. I am
>>>>>>>>> loading them from maven mojo. In a way, it's similar to unit testing.
>>>>>>>>>
>>>>>>>>> protected void setupClassPath() throws MalformedURLException,
>>>>>>>>> DependencyResolutionRequiredException
>>>>>>>>> {
>>>>>>>>>
>>>>>>>>> synchronized (this)
>>>>>>>>> {
>>>>>>>>> if (classLoader != null)
>>>>>>>>> return;
>>>>>>>>> }
>>>>>>>>> synchronized (this)
>>>>>>>>> {
>>>>>>>>> List<URL> urls = new ArrayList<URL>();
>>>>>>>>>
>>>>>>>>> List<String> paths = new LinkedList<String>();
>>>>>>>>>
>>>>>>>>> List<String> compilePath = mavenProject.getCompileClasspathElements();
>>>>>>>>>
>>>>>>>>> List<String> testPath = mavenProject.getTestClasspathElements();
>>>>>>>>>
>>>>>>>>> List<String> runtimePath = mavenProject.getRuntimeClasspathElements();
>>>>>>>>>
>>>>>>>>> List<String> systemPath = mavenProject.getSystemClasspathElements();
>>>>>>>>>
>>>>>>>>> List<Dependency> dependencies = mavenProject.getCompileDependencies();
>>>>>>>>>
>>>>>>>>> this.merge(paths, compilePath);
>>>>>>>>> this.merge(paths, testPath);
>>>>>>>>> this.merge(paths, runtimePath);
>>>>>>>>> this.merge(paths, systemPath);
>>>>>>>>>
>>>>>>>>> getLog().info("Scanning ... ");
>>>>>>>>>
>>>>>>>>> for (Object object : paths)
>>>>>>>>> {
>>>>>>>>> String path = (String) object;
>>>>>>>>>
>>>>>>>>> getLog().info("Adding " + path + " to classpath");
>>>>>>>>>
>>>>>>>>> urls.add(new File(path).toURL());
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> ClassLoader parent = Thread.currentThread().getContextClassLoader();
>>>>>>>>>
>>>>>>>>> parent = this.getClass().getClassLoader();
>>>>>>>>>
>>>>>>>>> ClassLoader contextClassLoader =
>>>>>>>>> URLClassLoader.newInstance(urls.toArray(new URL[0]), parent);
>>>>>>>>>
>>>>>>>>> Thread.currentThread().setContextClassLoader(contextClassLoader);
>>>>>>>>>
>>>>>>>>> return;
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> .....
>>>>>>>>>
>>>>>>>>> properties.put(Context.INITIAL_CONTEXT_FACTORY,
>>>>>>>>> "org.apache.openejb.client.LocalInitialContextFactory");
>>>>>>>>>
>>>>>>>>> // properties.put(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
>>>>>>>>> properties.put("openejb.validation.output.level", "VERBOSE");
>>>>>>>>>
>>>>>>>>> properties.put("jdbc/dataSource", "new://Resource?type=DataSource");
>>>>>>>>> properties.put("jdbc/dataSource.JdbcDriver", this.driver);
>>>>>>>>> properties.put("jdbc/dataSource.JdbcUrl", this.url);
>>>>>>>>> properties.put("jdbc/dataSource.UserName", this.username);
>>>>>>>>> properties.put("jdbc/dataSource.Password", this.password);
>>>>>>>>>
>>>>>>>>> properties.setProperty("javax.persistence.transactionType",
>>>>>>>>> "RESOURCE_LOCAL");
>>>>>>>>>
>>>>>>>>> Context ctx;
>>>>>>>>> try
>>>>>>>>> {
>>>>>>>>>
>>>>>>>>> ctx = new InitialContext(properties);
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> The problem I am facing now, is that not all the dependencies are
>>>>>>>>> available for OpenEJB:
>>>>>>>>>
>>>>>>>>> Oct 13, 2014 10:15:36 PM org.apache.openejb.OpenEJB$Instance <init>
>>>>>>>>> SEVERE: OpenEJB has encountered a fatal error and cannot be started:
>>>>>>>>> The Assembler encountered an unexpected error while attempting to
>>>>>>>>> build the container system.
>>>>>>>>> java.lang.NoClassDefFoundError:
>>>>>>>>> org/perfectjpattern/jee/integration/dao/AbstractJpaManagedBaseDao
>>>>>>>>> at java.lang.ClassLoader.defineClass1(Native Method)
>>>>>>>>> at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
>>>>>>>>> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
>>>>>>>>> at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
>>>>>>>>> at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
>>>>>>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
>>>>>>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
>>>>>>>>> at java.security.AccessController.doPrivileged(Native Method)
>>>>>>>>> at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
>>>>>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
>>>>>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
>>>>>>>>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:180)
>>>>>>>>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:74)
>>>>>>>>> at org.apache.xbean.finder.archive.JarArchive.loadClass(JarArchive.java:84)
>>>>>>>>> at org.apache.xbean.finder.archive.CompositeArchive.loadClass(CompositeArchive.java:58)
>>>>>>>>> at org.apache.openejb.config.FinderFactory$DebugArchive.loadClass(FinderFactory.java:139)
>>>>>>>>> at org.apache.xbean.finder.AnnotationFinder$ClassInfo.get(AnnotationFinder.java:1425)
>>>>>>>>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:540)
>>>>>>>>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:489)
>>>>>>>>> at org.apache.openejb.config.FinderFactory$ModuleLimitedFinder.findMetaAnnotatedClasses(FinderFactory.java:291)
>>>>>>>>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:1391)
>>>>>>>>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:436)
>>>>>>>>> at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:351)
>>>>>>>>> at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:396)
>>>>>>>>> at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:938)
>>>>>>>>> at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:799)
>>>>>>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:531)
>>>>>>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:575)
>>>>>>>>> at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:429)
>>>>>>>>> at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:408)
>>>>>>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:148)
>>>>>>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
>>>>>>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:296)
>>>>>>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:276)
>>>>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>>>>>>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>>>>>>> at java.lang.reflect.Method.invoke(Method.java:606)
>>>>>>>>> at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
>>>>>>>>> at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:96)
>>>>>>>>> at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:60)
>>>>>>>>> at org.apache.openejb.core.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:44)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> I am not sure if adding dependencies to OpenEJB class works using
>>>>>>>>>
>>>>>>>>> Thread.currentThread().setContextClassLoader(contextClassLoader);
>>>>>>>>>
>>>>>>>>> Thank you.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Mon, Oct 13, 2014 at 7:10 AM, Romain Manni-Bucau
>>>>>>>>> <rm...@gmail.com> wrote:
>>>>>>>>>> not for war and classpath apps (only for ears)
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Romain Manni-Bucau
>>>>>>>>>> @rmannibucau
>>>>>>>>>> http://www.tomitribe.com
>>>>>>>>>> http://rmannibucau.wordpress.com
>>>>>>>>>> https://github.com/rmannibucau
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> 2014-10-13 13:07 GMT+02:00 Andy Gumbrecht <ag...@tomitribe.com>:
>>>>>>>>>>> Could this be related the '*openejb.finder.module-scoped=true*' property?
>>>>>>>>>>>
>>>>>>>>>>> Andy.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On 13/10/2014 08:39, Romain Manni-Bucau wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> Hi
>>>>>>>>>>>>
>>>>>>>>>>>> it should do out of the box,can you share more details/code?
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Romain Manni-Bucau
>>>>>>>>>>>> @rmannibucau
>>>>>>>>>>>> http://www.tomitribe.com
>>>>>>>>>>>> http://rmannibucau.wordpress.com
>>>>>>>>>>>> https://github.com/rmannibucau
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> 2014-10-13 7:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>>>>>>>>>>
>>>>>>>>>>>>> I am writing unit tests. The unit test include multiple jars, each of
>>>>>>>>>>>>> them has JPA entities and persistence.xml file. Each file has it's own
>>>>>>>>>>>>> Persistence Context.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> The JPA entities in jar B references some entities in jar file A. I
>>>>>>>>>>>>> need to load both persistence.xml.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Is there a way to instruct openejb container to scan for other
>>>>>>>>>>>>> persistence.xml in different jars ??
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Andy Gumbrecht
>>>>>>>>>>> https://twitter.com/AndyGeeDe
>>>>>>>>>>> http://www.tomitribe.com
>>>>>>>>>>>
Re: Multiple persistence.xml in different jars
Posted by Mansour Al Akeel <ma...@gmail.com>.
I will try to locate the file you mentioned "scan.xml" and have a look.
There could be many possibilities. The one that comes to my mind is
the two versions of OpenEJB jars.
Since I am working with Maven plugin, the plugin references openejb
4.7.1 and the project I have has openejb as a dependency.
When we execute the mojo, both jars are added to the classpath. I am
not sure if this is the issue, but suspicious to me.
On Tue, Oct 14, 2014 at 7:09 PM, Romain Manni-Bucau
<rm...@gmail.com> wrote:
> 2014-10-15 1:06 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>> upgrading to 4.7.1 resolved the problem, but now back again to a
>> problem I saw earlier.
>>
>> Oct 14, 2014 6:59:22 PM org.apache.openejb.OpenEJB$Instance <init>
>> SEVERE: OpenEJB has encountered a fatal error and cannot be started:
>> The Assembler encountered an unexpected error while attempting to
>> build the container system.
>> java.lang.NoClassDefFoundError:
>> org/perfectjpattern/jee/integration/dao/AbstractJpaManagedBaseDao
>> at java.lang.ClassLoader.defineClass1(Native Method)
>> at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
>> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
>> at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
>> at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
>> at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
>> at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:205)
>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:79)
>> at org.apache.xbean.finder.archive.JarArchive.loadClass(JarArchive.java:84)
>> at org.apache.xbean.finder.archive.CompositeArchive.loadClass(CompositeArchive.java:58)
>> at org.apache.openejb.config.FinderFactory$DebugArchive.loadClass(FinderFactory.java:282)
>> at org.apache.xbean.finder.AnnotationFinder$ClassInfo.get(AnnotationFinder.java:1453)
>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:563)
>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:512)
>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:1406)
>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:442)
>> at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:356)
>>
>>
>> The class IS in the class path, and available to the current project
>> as maven dependency. I am not sure why I am getting this error, and
>> has been stuck with it.
>> A work around could be is to disable scanning for EJBs and allow only
>> one EJB to be discovered.
>> Is there a way to do this ?
>>
>
> scan.xml would do it but weird the issue pops up like it, is it
> possible openejb is in a lower classloader or
> ParentClassLoaderFinder.Helper.get() is wrong?
>
>>
>> On Tue, Oct 14, 2014 at 11:13 AM, Romain Manni-Bucau
>> <rm...@gmail.com> wrote:
>>> Maybe try a more recent version cause we changed several things and
>>> some of them were impacting in maven environment.
>>>
>>>
>>> Romain Manni-Bucau
>>> @rmannibucau
>>> http://www.tomitribe.com
>>> http://rmannibucau.wordpress.com
>>> https://github.com/rmannibucau
>>>
>>>
>>> 2014-10-14 17:06 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>> No. I am using openejb embedded 4.6.0
>>>>
>>>>
>>>> On Tue, Oct 14, 2014 at 10:43 AM, Romain Manni-Bucau
>>>> <rm...@gmail.com> wrote:
>>>>> asm4? you are not on tomee 1.7?
>>>>>
>>>>>
>>>>> Romain Manni-Bucau
>>>>> @rmannibucau
>>>>> http://www.tomitribe.com
>>>>> http://rmannibucau.wordpress.com
>>>>> https://github.com/rmannibucau
>>>>>
>>>>>
>>>>> 2014-10-14 16:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>>> Thank you Romain.
>>>>>> The target/classes was in the class path, but the size of the url array was 0.
>>>>>>
>>>>>> This was helpful. I am getting another error, that I was not able to understand.
>>>>>>
>>>>>> SEVERE: FATAL ERROR: Unknown error in Assembler. Please send the
>>>>>> following stack trace and this message to users@openejb.apache.org :
>>>>>> java.lang.IllegalArgumentException
>>>>>> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
>>>>>> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
>>>>>> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
>>>>>> at org.apache.openejb.util.AnnotationFinder.readClassDef(AnnotationFinder.java:297)
>>>>>> at org.apache.openejb.util.AnnotationFinder.find(AnnotationFinder.java:163)
>>>>>> at org.apache.openejb.config.DeploymentLoader.checkAnnotations(DeploymentLoader.java:1871)
>>>>>> at org.apache.openejb.config.DeploymentLoader.discoverModuleType(DeploymentLoader.java:1782)
>>>>>> at org.apache.openejb.config.DeploymentsResolver.processUrls(DeploymentsResolver.java:388)
>>>>>> at org.apache.openejb.config.DeploymentsResolver.loadFromClasspath(DeploymentsResolver.java:301)
>>>>>> at org.apache.openejb.config.ConfigurationFactory.getModulesFromClassPath(ConfigurationFactory.java:647)
>>>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:524)
>>>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:575)
>>>>>> at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:429)
>>>>>> at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:408)
>>>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:148)
>>>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
>>>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:296)
>>>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:276)
>>>>>>
>>>>>>
>>>>>> I will continue digging.
>>>>>>
>>>>>> Thank you a lot.
>>>>>>
>>>>>>
>>>>>> On Tue, Oct 14, 2014 at 2:20 AM, Romain Manni-Bucau
>>>>>> <rm...@gmail.com> wrote:
>>>>>>> Hi
>>>>>>>
>>>>>>> we have a mojo like it
>>>>>>> http://svn.apache.org/repos/asf/tomee/tomee/trunk/maven/openejb-embedded-maven-plugin/
>>>>>>>
>>>>>>> I think you miss target/classes in your loader
>>>>>>>
>>>>>>>
>>>>>>> Romain Manni-Bucau
>>>>>>> @rmannibucau
>>>>>>> http://www.tomitribe.com
>>>>>>> http://rmannibucau.wordpress.com
>>>>>>> https://github.com/rmannibucau
>>>>>>>
>>>>>>>
>>>>>>> 2014-10-14 6:37 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>>>>> Romain,
>>>>>>>> It was my fault. I was loading the persistence context using openjpa.
>>>>>>>> However, switched to OpenEJB to allow scanning for the persistence.xml
>>>>>>>> in other jars. The problem is the current jar has some EJBs. I am
>>>>>>>> loading them from maven mojo. In a way, it's similar to unit testing.
>>>>>>>>
>>>>>>>> protected void setupClassPath() throws MalformedURLException,
>>>>>>>> DependencyResolutionRequiredException
>>>>>>>> {
>>>>>>>>
>>>>>>>> synchronized (this)
>>>>>>>> {
>>>>>>>> if (classLoader != null)
>>>>>>>> return;
>>>>>>>> }
>>>>>>>> synchronized (this)
>>>>>>>> {
>>>>>>>> List<URL> urls = new ArrayList<URL>();
>>>>>>>>
>>>>>>>> List<String> paths = new LinkedList<String>();
>>>>>>>>
>>>>>>>> List<String> compilePath = mavenProject.getCompileClasspathElements();
>>>>>>>>
>>>>>>>> List<String> testPath = mavenProject.getTestClasspathElements();
>>>>>>>>
>>>>>>>> List<String> runtimePath = mavenProject.getRuntimeClasspathElements();
>>>>>>>>
>>>>>>>> List<String> systemPath = mavenProject.getSystemClasspathElements();
>>>>>>>>
>>>>>>>> List<Dependency> dependencies = mavenProject.getCompileDependencies();
>>>>>>>>
>>>>>>>> this.merge(paths, compilePath);
>>>>>>>> this.merge(paths, testPath);
>>>>>>>> this.merge(paths, runtimePath);
>>>>>>>> this.merge(paths, systemPath);
>>>>>>>>
>>>>>>>> getLog().info("Scanning ... ");
>>>>>>>>
>>>>>>>> for (Object object : paths)
>>>>>>>> {
>>>>>>>> String path = (String) object;
>>>>>>>>
>>>>>>>> getLog().info("Adding " + path + " to classpath");
>>>>>>>>
>>>>>>>> urls.add(new File(path).toURL());
>>>>>>>> }
>>>>>>>>
>>>>>>>> ClassLoader parent = Thread.currentThread().getContextClassLoader();
>>>>>>>>
>>>>>>>> parent = this.getClass().getClassLoader();
>>>>>>>>
>>>>>>>> ClassLoader contextClassLoader =
>>>>>>>> URLClassLoader.newInstance(urls.toArray(new URL[0]), parent);
>>>>>>>>
>>>>>>>> Thread.currentThread().setContextClassLoader(contextClassLoader);
>>>>>>>>
>>>>>>>> return;
>>>>>>>> }
>>>>>>>> }
>>>>>>>>
>>>>>>>> .....
>>>>>>>>
>>>>>>>> properties.put(Context.INITIAL_CONTEXT_FACTORY,
>>>>>>>> "org.apache.openejb.client.LocalInitialContextFactory");
>>>>>>>>
>>>>>>>> // properties.put(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
>>>>>>>> properties.put("openejb.validation.output.level", "VERBOSE");
>>>>>>>>
>>>>>>>> properties.put("jdbc/dataSource", "new://Resource?type=DataSource");
>>>>>>>> properties.put("jdbc/dataSource.JdbcDriver", this.driver);
>>>>>>>> properties.put("jdbc/dataSource.JdbcUrl", this.url);
>>>>>>>> properties.put("jdbc/dataSource.UserName", this.username);
>>>>>>>> properties.put("jdbc/dataSource.Password", this.password);
>>>>>>>>
>>>>>>>> properties.setProperty("javax.persistence.transactionType",
>>>>>>>> "RESOURCE_LOCAL");
>>>>>>>>
>>>>>>>> Context ctx;
>>>>>>>> try
>>>>>>>> {
>>>>>>>>
>>>>>>>> ctx = new InitialContext(properties);
>>>>>>>>
>>>>>>>>
>>>>>>>> The problem I am facing now, is that not all the dependencies are
>>>>>>>> available for OpenEJB:
>>>>>>>>
>>>>>>>> Oct 13, 2014 10:15:36 PM org.apache.openejb.OpenEJB$Instance <init>
>>>>>>>> SEVERE: OpenEJB has encountered a fatal error and cannot be started:
>>>>>>>> The Assembler encountered an unexpected error while attempting to
>>>>>>>> build the container system.
>>>>>>>> java.lang.NoClassDefFoundError:
>>>>>>>> org/perfectjpattern/jee/integration/dao/AbstractJpaManagedBaseDao
>>>>>>>> at java.lang.ClassLoader.defineClass1(Native Method)
>>>>>>>> at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
>>>>>>>> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
>>>>>>>> at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
>>>>>>>> at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
>>>>>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
>>>>>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
>>>>>>>> at java.security.AccessController.doPrivileged(Native Method)
>>>>>>>> at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
>>>>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
>>>>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
>>>>>>>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:180)
>>>>>>>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:74)
>>>>>>>> at org.apache.xbean.finder.archive.JarArchive.loadClass(JarArchive.java:84)
>>>>>>>> at org.apache.xbean.finder.archive.CompositeArchive.loadClass(CompositeArchive.java:58)
>>>>>>>> at org.apache.openejb.config.FinderFactory$DebugArchive.loadClass(FinderFactory.java:139)
>>>>>>>> at org.apache.xbean.finder.AnnotationFinder$ClassInfo.get(AnnotationFinder.java:1425)
>>>>>>>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:540)
>>>>>>>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:489)
>>>>>>>> at org.apache.openejb.config.FinderFactory$ModuleLimitedFinder.findMetaAnnotatedClasses(FinderFactory.java:291)
>>>>>>>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:1391)
>>>>>>>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:436)
>>>>>>>> at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:351)
>>>>>>>> at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:396)
>>>>>>>> at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:938)
>>>>>>>> at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:799)
>>>>>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:531)
>>>>>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:575)
>>>>>>>> at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:429)
>>>>>>>> at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:408)
>>>>>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:148)
>>>>>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
>>>>>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:296)
>>>>>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:276)
>>>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>>>>>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>>>>>> at java.lang.reflect.Method.invoke(Method.java:606)
>>>>>>>> at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
>>>>>>>> at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:96)
>>>>>>>> at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:60)
>>>>>>>> at org.apache.openejb.core.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:44)
>>>>>>>>
>>>>>>>>
>>>>>>>> I am not sure if adding dependencies to OpenEJB class works using
>>>>>>>>
>>>>>>>> Thread.currentThread().setContextClassLoader(contextClassLoader);
>>>>>>>>
>>>>>>>> Thank you.
>>>>>>>>
>>>>>>>>
>>>>>>>> On Mon, Oct 13, 2014 at 7:10 AM, Romain Manni-Bucau
>>>>>>>> <rm...@gmail.com> wrote:
>>>>>>>>> not for war and classpath apps (only for ears)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Romain Manni-Bucau
>>>>>>>>> @rmannibucau
>>>>>>>>> http://www.tomitribe.com
>>>>>>>>> http://rmannibucau.wordpress.com
>>>>>>>>> https://github.com/rmannibucau
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> 2014-10-13 13:07 GMT+02:00 Andy Gumbrecht <ag...@tomitribe.com>:
>>>>>>>>>> Could this be related the '*openejb.finder.module-scoped=true*' property?
>>>>>>>>>>
>>>>>>>>>> Andy.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On 13/10/2014 08:39, Romain Manni-Bucau wrote:
>>>>>>>>>>>
>>>>>>>>>>> Hi
>>>>>>>>>>>
>>>>>>>>>>> it should do out of the box,can you share more details/code?
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Romain Manni-Bucau
>>>>>>>>>>> @rmannibucau
>>>>>>>>>>> http://www.tomitribe.com
>>>>>>>>>>> http://rmannibucau.wordpress.com
>>>>>>>>>>> https://github.com/rmannibucau
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> 2014-10-13 7:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>>>>>>>>>
>>>>>>>>>>>> I am writing unit tests. The unit test include multiple jars, each of
>>>>>>>>>>>> them has JPA entities and persistence.xml file. Each file has it's own
>>>>>>>>>>>> Persistence Context.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> The JPA entities in jar B references some entities in jar file A. I
>>>>>>>>>>>> need to load both persistence.xml.
>>>>>>>>>>>>
>>>>>>>>>>>> Is there a way to instruct openejb container to scan for other
>>>>>>>>>>>> persistence.xml in different jars ??
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Andy Gumbrecht
>>>>>>>>>> https://twitter.com/AndyGeeDe
>>>>>>>>>> http://www.tomitribe.com
>>>>>>>>>>
Re: Multiple persistence.xml in different jars
Posted by Romain Manni-Bucau <rm...@gmail.com>.
2014-10-15 1:06 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
> upgrading to 4.7.1 resolved the problem, but now back again to a
> problem I saw earlier.
>
> Oct 14, 2014 6:59:22 PM org.apache.openejb.OpenEJB$Instance <init>
> SEVERE: OpenEJB has encountered a fatal error and cannot be started:
> The Assembler encountered an unexpected error while attempting to
> build the container system.
> java.lang.NoClassDefFoundError:
> org/perfectjpattern/jee/integration/dao/AbstractJpaManagedBaseDao
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
> at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
> at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:205)
> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:79)
> at org.apache.xbean.finder.archive.JarArchive.loadClass(JarArchive.java:84)
> at org.apache.xbean.finder.archive.CompositeArchive.loadClass(CompositeArchive.java:58)
> at org.apache.openejb.config.FinderFactory$DebugArchive.loadClass(FinderFactory.java:282)
> at org.apache.xbean.finder.AnnotationFinder$ClassInfo.get(AnnotationFinder.java:1453)
> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:563)
> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:512)
> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:1406)
> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:442)
> at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:356)
>
>
> The class IS in the class path, and available to the current project
> as maven dependency. I am not sure why I am getting this error, and
> has been stuck with it.
> A work around could be is to disable scanning for EJBs and allow only
> one EJB to be discovered.
> Is there a way to do this ?
>
scan.xml would do it but weird the issue pops up like it, is it
possible openejb is in a lower classloader or
ParentClassLoaderFinder.Helper.get() is wrong?
>
> On Tue, Oct 14, 2014 at 11:13 AM, Romain Manni-Bucau
> <rm...@gmail.com> wrote:
>> Maybe try a more recent version cause we changed several things and
>> some of them were impacting in maven environment.
>>
>>
>> Romain Manni-Bucau
>> @rmannibucau
>> http://www.tomitribe.com
>> http://rmannibucau.wordpress.com
>> https://github.com/rmannibucau
>>
>>
>> 2014-10-14 17:06 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>> No. I am using openejb embedded 4.6.0
>>>
>>>
>>> On Tue, Oct 14, 2014 at 10:43 AM, Romain Manni-Bucau
>>> <rm...@gmail.com> wrote:
>>>> asm4? you are not on tomee 1.7?
>>>>
>>>>
>>>> Romain Manni-Bucau
>>>> @rmannibucau
>>>> http://www.tomitribe.com
>>>> http://rmannibucau.wordpress.com
>>>> https://github.com/rmannibucau
>>>>
>>>>
>>>> 2014-10-14 16:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>> Thank you Romain.
>>>>> The target/classes was in the class path, but the size of the url array was 0.
>>>>>
>>>>> This was helpful. I am getting another error, that I was not able to understand.
>>>>>
>>>>> SEVERE: FATAL ERROR: Unknown error in Assembler. Please send the
>>>>> following stack trace and this message to users@openejb.apache.org :
>>>>> java.lang.IllegalArgumentException
>>>>> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
>>>>> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
>>>>> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
>>>>> at org.apache.openejb.util.AnnotationFinder.readClassDef(AnnotationFinder.java:297)
>>>>> at org.apache.openejb.util.AnnotationFinder.find(AnnotationFinder.java:163)
>>>>> at org.apache.openejb.config.DeploymentLoader.checkAnnotations(DeploymentLoader.java:1871)
>>>>> at org.apache.openejb.config.DeploymentLoader.discoverModuleType(DeploymentLoader.java:1782)
>>>>> at org.apache.openejb.config.DeploymentsResolver.processUrls(DeploymentsResolver.java:388)
>>>>> at org.apache.openejb.config.DeploymentsResolver.loadFromClasspath(DeploymentsResolver.java:301)
>>>>> at org.apache.openejb.config.ConfigurationFactory.getModulesFromClassPath(ConfigurationFactory.java:647)
>>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:524)
>>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:575)
>>>>> at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:429)
>>>>> at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:408)
>>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:148)
>>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
>>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:296)
>>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:276)
>>>>>
>>>>>
>>>>> I will continue digging.
>>>>>
>>>>> Thank you a lot.
>>>>>
>>>>>
>>>>> On Tue, Oct 14, 2014 at 2:20 AM, Romain Manni-Bucau
>>>>> <rm...@gmail.com> wrote:
>>>>>> Hi
>>>>>>
>>>>>> we have a mojo like it
>>>>>> http://svn.apache.org/repos/asf/tomee/tomee/trunk/maven/openejb-embedded-maven-plugin/
>>>>>>
>>>>>> I think you miss target/classes in your loader
>>>>>>
>>>>>>
>>>>>> Romain Manni-Bucau
>>>>>> @rmannibucau
>>>>>> http://www.tomitribe.com
>>>>>> http://rmannibucau.wordpress.com
>>>>>> https://github.com/rmannibucau
>>>>>>
>>>>>>
>>>>>> 2014-10-14 6:37 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>>>> Romain,
>>>>>>> It was my fault. I was loading the persistence context using openjpa.
>>>>>>> However, switched to OpenEJB to allow scanning for the persistence.xml
>>>>>>> in other jars. The problem is the current jar has some EJBs. I am
>>>>>>> loading them from maven mojo. In a way, it's similar to unit testing.
>>>>>>>
>>>>>>> protected void setupClassPath() throws MalformedURLException,
>>>>>>> DependencyResolutionRequiredException
>>>>>>> {
>>>>>>>
>>>>>>> synchronized (this)
>>>>>>> {
>>>>>>> if (classLoader != null)
>>>>>>> return;
>>>>>>> }
>>>>>>> synchronized (this)
>>>>>>> {
>>>>>>> List<URL> urls = new ArrayList<URL>();
>>>>>>>
>>>>>>> List<String> paths = new LinkedList<String>();
>>>>>>>
>>>>>>> List<String> compilePath = mavenProject.getCompileClasspathElements();
>>>>>>>
>>>>>>> List<String> testPath = mavenProject.getTestClasspathElements();
>>>>>>>
>>>>>>> List<String> runtimePath = mavenProject.getRuntimeClasspathElements();
>>>>>>>
>>>>>>> List<String> systemPath = mavenProject.getSystemClasspathElements();
>>>>>>>
>>>>>>> List<Dependency> dependencies = mavenProject.getCompileDependencies();
>>>>>>>
>>>>>>> this.merge(paths, compilePath);
>>>>>>> this.merge(paths, testPath);
>>>>>>> this.merge(paths, runtimePath);
>>>>>>> this.merge(paths, systemPath);
>>>>>>>
>>>>>>> getLog().info("Scanning ... ");
>>>>>>>
>>>>>>> for (Object object : paths)
>>>>>>> {
>>>>>>> String path = (String) object;
>>>>>>>
>>>>>>> getLog().info("Adding " + path + " to classpath");
>>>>>>>
>>>>>>> urls.add(new File(path).toURL());
>>>>>>> }
>>>>>>>
>>>>>>> ClassLoader parent = Thread.currentThread().getContextClassLoader();
>>>>>>>
>>>>>>> parent = this.getClass().getClassLoader();
>>>>>>>
>>>>>>> ClassLoader contextClassLoader =
>>>>>>> URLClassLoader.newInstance(urls.toArray(new URL[0]), parent);
>>>>>>>
>>>>>>> Thread.currentThread().setContextClassLoader(contextClassLoader);
>>>>>>>
>>>>>>> return;
>>>>>>> }
>>>>>>> }
>>>>>>>
>>>>>>> .....
>>>>>>>
>>>>>>> properties.put(Context.INITIAL_CONTEXT_FACTORY,
>>>>>>> "org.apache.openejb.client.LocalInitialContextFactory");
>>>>>>>
>>>>>>> // properties.put(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
>>>>>>> properties.put("openejb.validation.output.level", "VERBOSE");
>>>>>>>
>>>>>>> properties.put("jdbc/dataSource", "new://Resource?type=DataSource");
>>>>>>> properties.put("jdbc/dataSource.JdbcDriver", this.driver);
>>>>>>> properties.put("jdbc/dataSource.JdbcUrl", this.url);
>>>>>>> properties.put("jdbc/dataSource.UserName", this.username);
>>>>>>> properties.put("jdbc/dataSource.Password", this.password);
>>>>>>>
>>>>>>> properties.setProperty("javax.persistence.transactionType",
>>>>>>> "RESOURCE_LOCAL");
>>>>>>>
>>>>>>> Context ctx;
>>>>>>> try
>>>>>>> {
>>>>>>>
>>>>>>> ctx = new InitialContext(properties);
>>>>>>>
>>>>>>>
>>>>>>> The problem I am facing now, is that not all the dependencies are
>>>>>>> available for OpenEJB:
>>>>>>>
>>>>>>> Oct 13, 2014 10:15:36 PM org.apache.openejb.OpenEJB$Instance <init>
>>>>>>> SEVERE: OpenEJB has encountered a fatal error and cannot be started:
>>>>>>> The Assembler encountered an unexpected error while attempting to
>>>>>>> build the container system.
>>>>>>> java.lang.NoClassDefFoundError:
>>>>>>> org/perfectjpattern/jee/integration/dao/AbstractJpaManagedBaseDao
>>>>>>> at java.lang.ClassLoader.defineClass1(Native Method)
>>>>>>> at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
>>>>>>> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
>>>>>>> at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
>>>>>>> at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
>>>>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
>>>>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
>>>>>>> at java.security.AccessController.doPrivileged(Native Method)
>>>>>>> at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
>>>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
>>>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
>>>>>>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:180)
>>>>>>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:74)
>>>>>>> at org.apache.xbean.finder.archive.JarArchive.loadClass(JarArchive.java:84)
>>>>>>> at org.apache.xbean.finder.archive.CompositeArchive.loadClass(CompositeArchive.java:58)
>>>>>>> at org.apache.openejb.config.FinderFactory$DebugArchive.loadClass(FinderFactory.java:139)
>>>>>>> at org.apache.xbean.finder.AnnotationFinder$ClassInfo.get(AnnotationFinder.java:1425)
>>>>>>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:540)
>>>>>>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:489)
>>>>>>> at org.apache.openejb.config.FinderFactory$ModuleLimitedFinder.findMetaAnnotatedClasses(FinderFactory.java:291)
>>>>>>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:1391)
>>>>>>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:436)
>>>>>>> at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:351)
>>>>>>> at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:396)
>>>>>>> at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:938)
>>>>>>> at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:799)
>>>>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:531)
>>>>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:575)
>>>>>>> at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:429)
>>>>>>> at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:408)
>>>>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:148)
>>>>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
>>>>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:296)
>>>>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:276)
>>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>>>>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>>>>> at java.lang.reflect.Method.invoke(Method.java:606)
>>>>>>> at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
>>>>>>> at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:96)
>>>>>>> at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:60)
>>>>>>> at org.apache.openejb.core.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:44)
>>>>>>>
>>>>>>>
>>>>>>> I am not sure if adding dependencies to OpenEJB class works using
>>>>>>>
>>>>>>> Thread.currentThread().setContextClassLoader(contextClassLoader);
>>>>>>>
>>>>>>> Thank you.
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Oct 13, 2014 at 7:10 AM, Romain Manni-Bucau
>>>>>>> <rm...@gmail.com> wrote:
>>>>>>>> not for war and classpath apps (only for ears)
>>>>>>>>
>>>>>>>>
>>>>>>>> Romain Manni-Bucau
>>>>>>>> @rmannibucau
>>>>>>>> http://www.tomitribe.com
>>>>>>>> http://rmannibucau.wordpress.com
>>>>>>>> https://github.com/rmannibucau
>>>>>>>>
>>>>>>>>
>>>>>>>> 2014-10-13 13:07 GMT+02:00 Andy Gumbrecht <ag...@tomitribe.com>:
>>>>>>>>> Could this be related the '*openejb.finder.module-scoped=true*' property?
>>>>>>>>>
>>>>>>>>> Andy.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On 13/10/2014 08:39, Romain Manni-Bucau wrote:
>>>>>>>>>>
>>>>>>>>>> Hi
>>>>>>>>>>
>>>>>>>>>> it should do out of the box,can you share more details/code?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Romain Manni-Bucau
>>>>>>>>>> @rmannibucau
>>>>>>>>>> http://www.tomitribe.com
>>>>>>>>>> http://rmannibucau.wordpress.com
>>>>>>>>>> https://github.com/rmannibucau
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> 2014-10-13 7:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>>>>>>>>
>>>>>>>>>>> I am writing unit tests. The unit test include multiple jars, each of
>>>>>>>>>>> them has JPA entities and persistence.xml file. Each file has it's own
>>>>>>>>>>> Persistence Context.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> The JPA entities in jar B references some entities in jar file A. I
>>>>>>>>>>> need to load both persistence.xml.
>>>>>>>>>>>
>>>>>>>>>>> Is there a way to instruct openejb container to scan for other
>>>>>>>>>>> persistence.xml in different jars ??
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Andy Gumbrecht
>>>>>>>>> https://twitter.com/AndyGeeDe
>>>>>>>>> http://www.tomitribe.com
>>>>>>>>>
Re: Multiple persistence.xml in different jars
Posted by Mansour Al Akeel <ma...@gmail.com>.
upgrading to 4.7.1 resolved the problem, but now back again to a
problem I saw earlier.
Oct 14, 2014 6:59:22 PM org.apache.openejb.OpenEJB$Instance <init>
SEVERE: OpenEJB has encountered a fatal error and cannot be started:
The Assembler encountered an unexpected error while attempting to
build the container system.
java.lang.NoClassDefFoundError:
org/perfectjpattern/jee/integration/dao/AbstractJpaManagedBaseDao
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:205)
at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:79)
at org.apache.xbean.finder.archive.JarArchive.loadClass(JarArchive.java:84)
at org.apache.xbean.finder.archive.CompositeArchive.loadClass(CompositeArchive.java:58)
at org.apache.openejb.config.FinderFactory$DebugArchive.loadClass(FinderFactory.java:282)
at org.apache.xbean.finder.AnnotationFinder$ClassInfo.get(AnnotationFinder.java:1453)
at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:563)
at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:512)
at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:1406)
at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:442)
at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:356)
The class IS in the class path, and available to the current project
as maven dependency. I am not sure why I am getting this error, and
has been stuck with it.
A work around could be is to disable scanning for EJBs and allow only
one EJB to be discovered.
Is there a way to do this ?
On Tue, Oct 14, 2014 at 11:13 AM, Romain Manni-Bucau
<rm...@gmail.com> wrote:
> Maybe try a more recent version cause we changed several things and
> some of them were impacting in maven environment.
>
>
> Romain Manni-Bucau
> @rmannibucau
> http://www.tomitribe.com
> http://rmannibucau.wordpress.com
> https://github.com/rmannibucau
>
>
> 2014-10-14 17:06 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>> No. I am using openejb embedded 4.6.0
>>
>>
>> On Tue, Oct 14, 2014 at 10:43 AM, Romain Manni-Bucau
>> <rm...@gmail.com> wrote:
>>> asm4? you are not on tomee 1.7?
>>>
>>>
>>> Romain Manni-Bucau
>>> @rmannibucau
>>> http://www.tomitribe.com
>>> http://rmannibucau.wordpress.com
>>> https://github.com/rmannibucau
>>>
>>>
>>> 2014-10-14 16:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>> Thank you Romain.
>>>> The target/classes was in the class path, but the size of the url array was 0.
>>>>
>>>> This was helpful. I am getting another error, that I was not able to understand.
>>>>
>>>> SEVERE: FATAL ERROR: Unknown error in Assembler. Please send the
>>>> following stack trace and this message to users@openejb.apache.org :
>>>> java.lang.IllegalArgumentException
>>>> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
>>>> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
>>>> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
>>>> at org.apache.openejb.util.AnnotationFinder.readClassDef(AnnotationFinder.java:297)
>>>> at org.apache.openejb.util.AnnotationFinder.find(AnnotationFinder.java:163)
>>>> at org.apache.openejb.config.DeploymentLoader.checkAnnotations(DeploymentLoader.java:1871)
>>>> at org.apache.openejb.config.DeploymentLoader.discoverModuleType(DeploymentLoader.java:1782)
>>>> at org.apache.openejb.config.DeploymentsResolver.processUrls(DeploymentsResolver.java:388)
>>>> at org.apache.openejb.config.DeploymentsResolver.loadFromClasspath(DeploymentsResolver.java:301)
>>>> at org.apache.openejb.config.ConfigurationFactory.getModulesFromClassPath(ConfigurationFactory.java:647)
>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:524)
>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:575)
>>>> at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:429)
>>>> at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:408)
>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:148)
>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:296)
>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:276)
>>>>
>>>>
>>>> I will continue digging.
>>>>
>>>> Thank you a lot.
>>>>
>>>>
>>>> On Tue, Oct 14, 2014 at 2:20 AM, Romain Manni-Bucau
>>>> <rm...@gmail.com> wrote:
>>>>> Hi
>>>>>
>>>>> we have a mojo like it
>>>>> http://svn.apache.org/repos/asf/tomee/tomee/trunk/maven/openejb-embedded-maven-plugin/
>>>>>
>>>>> I think you miss target/classes in your loader
>>>>>
>>>>>
>>>>> Romain Manni-Bucau
>>>>> @rmannibucau
>>>>> http://www.tomitribe.com
>>>>> http://rmannibucau.wordpress.com
>>>>> https://github.com/rmannibucau
>>>>>
>>>>>
>>>>> 2014-10-14 6:37 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>>> Romain,
>>>>>> It was my fault. I was loading the persistence context using openjpa.
>>>>>> However, switched to OpenEJB to allow scanning for the persistence.xml
>>>>>> in other jars. The problem is the current jar has some EJBs. I am
>>>>>> loading them from maven mojo. In a way, it's similar to unit testing.
>>>>>>
>>>>>> protected void setupClassPath() throws MalformedURLException,
>>>>>> DependencyResolutionRequiredException
>>>>>> {
>>>>>>
>>>>>> synchronized (this)
>>>>>> {
>>>>>> if (classLoader != null)
>>>>>> return;
>>>>>> }
>>>>>> synchronized (this)
>>>>>> {
>>>>>> List<URL> urls = new ArrayList<URL>();
>>>>>>
>>>>>> List<String> paths = new LinkedList<String>();
>>>>>>
>>>>>> List<String> compilePath = mavenProject.getCompileClasspathElements();
>>>>>>
>>>>>> List<String> testPath = mavenProject.getTestClasspathElements();
>>>>>>
>>>>>> List<String> runtimePath = mavenProject.getRuntimeClasspathElements();
>>>>>>
>>>>>> List<String> systemPath = mavenProject.getSystemClasspathElements();
>>>>>>
>>>>>> List<Dependency> dependencies = mavenProject.getCompileDependencies();
>>>>>>
>>>>>> this.merge(paths, compilePath);
>>>>>> this.merge(paths, testPath);
>>>>>> this.merge(paths, runtimePath);
>>>>>> this.merge(paths, systemPath);
>>>>>>
>>>>>> getLog().info("Scanning ... ");
>>>>>>
>>>>>> for (Object object : paths)
>>>>>> {
>>>>>> String path = (String) object;
>>>>>>
>>>>>> getLog().info("Adding " + path + " to classpath");
>>>>>>
>>>>>> urls.add(new File(path).toURL());
>>>>>> }
>>>>>>
>>>>>> ClassLoader parent = Thread.currentThread().getContextClassLoader();
>>>>>>
>>>>>> parent = this.getClass().getClassLoader();
>>>>>>
>>>>>> ClassLoader contextClassLoader =
>>>>>> URLClassLoader.newInstance(urls.toArray(new URL[0]), parent);
>>>>>>
>>>>>> Thread.currentThread().setContextClassLoader(contextClassLoader);
>>>>>>
>>>>>> return;
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> .....
>>>>>>
>>>>>> properties.put(Context.INITIAL_CONTEXT_FACTORY,
>>>>>> "org.apache.openejb.client.LocalInitialContextFactory");
>>>>>>
>>>>>> // properties.put(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
>>>>>> properties.put("openejb.validation.output.level", "VERBOSE");
>>>>>>
>>>>>> properties.put("jdbc/dataSource", "new://Resource?type=DataSource");
>>>>>> properties.put("jdbc/dataSource.JdbcDriver", this.driver);
>>>>>> properties.put("jdbc/dataSource.JdbcUrl", this.url);
>>>>>> properties.put("jdbc/dataSource.UserName", this.username);
>>>>>> properties.put("jdbc/dataSource.Password", this.password);
>>>>>>
>>>>>> properties.setProperty("javax.persistence.transactionType",
>>>>>> "RESOURCE_LOCAL");
>>>>>>
>>>>>> Context ctx;
>>>>>> try
>>>>>> {
>>>>>>
>>>>>> ctx = new InitialContext(properties);
>>>>>>
>>>>>>
>>>>>> The problem I am facing now, is that not all the dependencies are
>>>>>> available for OpenEJB:
>>>>>>
>>>>>> Oct 13, 2014 10:15:36 PM org.apache.openejb.OpenEJB$Instance <init>
>>>>>> SEVERE: OpenEJB has encountered a fatal error and cannot be started:
>>>>>> The Assembler encountered an unexpected error while attempting to
>>>>>> build the container system.
>>>>>> java.lang.NoClassDefFoundError:
>>>>>> org/perfectjpattern/jee/integration/dao/AbstractJpaManagedBaseDao
>>>>>> at java.lang.ClassLoader.defineClass1(Native Method)
>>>>>> at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
>>>>>> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
>>>>>> at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
>>>>>> at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
>>>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
>>>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
>>>>>> at java.security.AccessController.doPrivileged(Native Method)
>>>>>> at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
>>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
>>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
>>>>>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:180)
>>>>>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:74)
>>>>>> at org.apache.xbean.finder.archive.JarArchive.loadClass(JarArchive.java:84)
>>>>>> at org.apache.xbean.finder.archive.CompositeArchive.loadClass(CompositeArchive.java:58)
>>>>>> at org.apache.openejb.config.FinderFactory$DebugArchive.loadClass(FinderFactory.java:139)
>>>>>> at org.apache.xbean.finder.AnnotationFinder$ClassInfo.get(AnnotationFinder.java:1425)
>>>>>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:540)
>>>>>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:489)
>>>>>> at org.apache.openejb.config.FinderFactory$ModuleLimitedFinder.findMetaAnnotatedClasses(FinderFactory.java:291)
>>>>>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:1391)
>>>>>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:436)
>>>>>> at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:351)
>>>>>> at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:396)
>>>>>> at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:938)
>>>>>> at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:799)
>>>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:531)
>>>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:575)
>>>>>> at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:429)
>>>>>> at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:408)
>>>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:148)
>>>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
>>>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:296)
>>>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:276)
>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>>>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>>>> at java.lang.reflect.Method.invoke(Method.java:606)
>>>>>> at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
>>>>>> at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:96)
>>>>>> at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:60)
>>>>>> at org.apache.openejb.core.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:44)
>>>>>>
>>>>>>
>>>>>> I am not sure if adding dependencies to OpenEJB class works using
>>>>>>
>>>>>> Thread.currentThread().setContextClassLoader(contextClassLoader);
>>>>>>
>>>>>> Thank you.
>>>>>>
>>>>>>
>>>>>> On Mon, Oct 13, 2014 at 7:10 AM, Romain Manni-Bucau
>>>>>> <rm...@gmail.com> wrote:
>>>>>>> not for war and classpath apps (only for ears)
>>>>>>>
>>>>>>>
>>>>>>> Romain Manni-Bucau
>>>>>>> @rmannibucau
>>>>>>> http://www.tomitribe.com
>>>>>>> http://rmannibucau.wordpress.com
>>>>>>> https://github.com/rmannibucau
>>>>>>>
>>>>>>>
>>>>>>> 2014-10-13 13:07 GMT+02:00 Andy Gumbrecht <ag...@tomitribe.com>:
>>>>>>>> Could this be related the '*openejb.finder.module-scoped=true*' property?
>>>>>>>>
>>>>>>>> Andy.
>>>>>>>>
>>>>>>>>
>>>>>>>> On 13/10/2014 08:39, Romain Manni-Bucau wrote:
>>>>>>>>>
>>>>>>>>> Hi
>>>>>>>>>
>>>>>>>>> it should do out of the box,can you share more details/code?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Romain Manni-Bucau
>>>>>>>>> @rmannibucau
>>>>>>>>> http://www.tomitribe.com
>>>>>>>>> http://rmannibucau.wordpress.com
>>>>>>>>> https://github.com/rmannibucau
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> 2014-10-13 7:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>>>>>>>
>>>>>>>>>> I am writing unit tests. The unit test include multiple jars, each of
>>>>>>>>>> them has JPA entities and persistence.xml file. Each file has it's own
>>>>>>>>>> Persistence Context.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> The JPA entities in jar B references some entities in jar file A. I
>>>>>>>>>> need to load both persistence.xml.
>>>>>>>>>>
>>>>>>>>>> Is there a way to instruct openejb container to scan for other
>>>>>>>>>> persistence.xml in different jars ??
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Andy Gumbrecht
>>>>>>>> https://twitter.com/AndyGeeDe
>>>>>>>> http://www.tomitribe.com
>>>>>>>>
Re: Multiple persistence.xml in different jars
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Maybe try a more recent version cause we changed several things and
some of them were impacting in maven environment.
Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau
2014-10-14 17:06 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
> No. I am using openejb embedded 4.6.0
>
>
> On Tue, Oct 14, 2014 at 10:43 AM, Romain Manni-Bucau
> <rm...@gmail.com> wrote:
>> asm4? you are not on tomee 1.7?
>>
>>
>> Romain Manni-Bucau
>> @rmannibucau
>> http://www.tomitribe.com
>> http://rmannibucau.wordpress.com
>> https://github.com/rmannibucau
>>
>>
>> 2014-10-14 16:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>> Thank you Romain.
>>> The target/classes was in the class path, but the size of the url array was 0.
>>>
>>> This was helpful. I am getting another error, that I was not able to understand.
>>>
>>> SEVERE: FATAL ERROR: Unknown error in Assembler. Please send the
>>> following stack trace and this message to users@openejb.apache.org :
>>> java.lang.IllegalArgumentException
>>> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
>>> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
>>> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
>>> at org.apache.openejb.util.AnnotationFinder.readClassDef(AnnotationFinder.java:297)
>>> at org.apache.openejb.util.AnnotationFinder.find(AnnotationFinder.java:163)
>>> at org.apache.openejb.config.DeploymentLoader.checkAnnotations(DeploymentLoader.java:1871)
>>> at org.apache.openejb.config.DeploymentLoader.discoverModuleType(DeploymentLoader.java:1782)
>>> at org.apache.openejb.config.DeploymentsResolver.processUrls(DeploymentsResolver.java:388)
>>> at org.apache.openejb.config.DeploymentsResolver.loadFromClasspath(DeploymentsResolver.java:301)
>>> at org.apache.openejb.config.ConfigurationFactory.getModulesFromClassPath(ConfigurationFactory.java:647)
>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:524)
>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:575)
>>> at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:429)
>>> at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:408)
>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:148)
>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:296)
>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:276)
>>>
>>>
>>> I will continue digging.
>>>
>>> Thank you a lot.
>>>
>>>
>>> On Tue, Oct 14, 2014 at 2:20 AM, Romain Manni-Bucau
>>> <rm...@gmail.com> wrote:
>>>> Hi
>>>>
>>>> we have a mojo like it
>>>> http://svn.apache.org/repos/asf/tomee/tomee/trunk/maven/openejb-embedded-maven-plugin/
>>>>
>>>> I think you miss target/classes in your loader
>>>>
>>>>
>>>> Romain Manni-Bucau
>>>> @rmannibucau
>>>> http://www.tomitribe.com
>>>> http://rmannibucau.wordpress.com
>>>> https://github.com/rmannibucau
>>>>
>>>>
>>>> 2014-10-14 6:37 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>> Romain,
>>>>> It was my fault. I was loading the persistence context using openjpa.
>>>>> However, switched to OpenEJB to allow scanning for the persistence.xml
>>>>> in other jars. The problem is the current jar has some EJBs. I am
>>>>> loading them from maven mojo. In a way, it's similar to unit testing.
>>>>>
>>>>> protected void setupClassPath() throws MalformedURLException,
>>>>> DependencyResolutionRequiredException
>>>>> {
>>>>>
>>>>> synchronized (this)
>>>>> {
>>>>> if (classLoader != null)
>>>>> return;
>>>>> }
>>>>> synchronized (this)
>>>>> {
>>>>> List<URL> urls = new ArrayList<URL>();
>>>>>
>>>>> List<String> paths = new LinkedList<String>();
>>>>>
>>>>> List<String> compilePath = mavenProject.getCompileClasspathElements();
>>>>>
>>>>> List<String> testPath = mavenProject.getTestClasspathElements();
>>>>>
>>>>> List<String> runtimePath = mavenProject.getRuntimeClasspathElements();
>>>>>
>>>>> List<String> systemPath = mavenProject.getSystemClasspathElements();
>>>>>
>>>>> List<Dependency> dependencies = mavenProject.getCompileDependencies();
>>>>>
>>>>> this.merge(paths, compilePath);
>>>>> this.merge(paths, testPath);
>>>>> this.merge(paths, runtimePath);
>>>>> this.merge(paths, systemPath);
>>>>>
>>>>> getLog().info("Scanning ... ");
>>>>>
>>>>> for (Object object : paths)
>>>>> {
>>>>> String path = (String) object;
>>>>>
>>>>> getLog().info("Adding " + path + " to classpath");
>>>>>
>>>>> urls.add(new File(path).toURL());
>>>>> }
>>>>>
>>>>> ClassLoader parent = Thread.currentThread().getContextClassLoader();
>>>>>
>>>>> parent = this.getClass().getClassLoader();
>>>>>
>>>>> ClassLoader contextClassLoader =
>>>>> URLClassLoader.newInstance(urls.toArray(new URL[0]), parent);
>>>>>
>>>>> Thread.currentThread().setContextClassLoader(contextClassLoader);
>>>>>
>>>>> return;
>>>>> }
>>>>> }
>>>>>
>>>>> .....
>>>>>
>>>>> properties.put(Context.INITIAL_CONTEXT_FACTORY,
>>>>> "org.apache.openejb.client.LocalInitialContextFactory");
>>>>>
>>>>> // properties.put(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
>>>>> properties.put("openejb.validation.output.level", "VERBOSE");
>>>>>
>>>>> properties.put("jdbc/dataSource", "new://Resource?type=DataSource");
>>>>> properties.put("jdbc/dataSource.JdbcDriver", this.driver);
>>>>> properties.put("jdbc/dataSource.JdbcUrl", this.url);
>>>>> properties.put("jdbc/dataSource.UserName", this.username);
>>>>> properties.put("jdbc/dataSource.Password", this.password);
>>>>>
>>>>> properties.setProperty("javax.persistence.transactionType",
>>>>> "RESOURCE_LOCAL");
>>>>>
>>>>> Context ctx;
>>>>> try
>>>>> {
>>>>>
>>>>> ctx = new InitialContext(properties);
>>>>>
>>>>>
>>>>> The problem I am facing now, is that not all the dependencies are
>>>>> available for OpenEJB:
>>>>>
>>>>> Oct 13, 2014 10:15:36 PM org.apache.openejb.OpenEJB$Instance <init>
>>>>> SEVERE: OpenEJB has encountered a fatal error and cannot be started:
>>>>> The Assembler encountered an unexpected error while attempting to
>>>>> build the container system.
>>>>> java.lang.NoClassDefFoundError:
>>>>> org/perfectjpattern/jee/integration/dao/AbstractJpaManagedBaseDao
>>>>> at java.lang.ClassLoader.defineClass1(Native Method)
>>>>> at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
>>>>> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
>>>>> at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
>>>>> at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
>>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
>>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
>>>>> at java.security.AccessController.doPrivileged(Native Method)
>>>>> at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
>>>>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:180)
>>>>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:74)
>>>>> at org.apache.xbean.finder.archive.JarArchive.loadClass(JarArchive.java:84)
>>>>> at org.apache.xbean.finder.archive.CompositeArchive.loadClass(CompositeArchive.java:58)
>>>>> at org.apache.openejb.config.FinderFactory$DebugArchive.loadClass(FinderFactory.java:139)
>>>>> at org.apache.xbean.finder.AnnotationFinder$ClassInfo.get(AnnotationFinder.java:1425)
>>>>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:540)
>>>>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:489)
>>>>> at org.apache.openejb.config.FinderFactory$ModuleLimitedFinder.findMetaAnnotatedClasses(FinderFactory.java:291)
>>>>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:1391)
>>>>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:436)
>>>>> at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:351)
>>>>> at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:396)
>>>>> at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:938)
>>>>> at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:799)
>>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:531)
>>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:575)
>>>>> at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:429)
>>>>> at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:408)
>>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:148)
>>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
>>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:296)
>>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:276)
>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>>> at java.lang.reflect.Method.invoke(Method.java:606)
>>>>> at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
>>>>> at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:96)
>>>>> at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:60)
>>>>> at org.apache.openejb.core.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:44)
>>>>>
>>>>>
>>>>> I am not sure if adding dependencies to OpenEJB class works using
>>>>>
>>>>> Thread.currentThread().setContextClassLoader(contextClassLoader);
>>>>>
>>>>> Thank you.
>>>>>
>>>>>
>>>>> On Mon, Oct 13, 2014 at 7:10 AM, Romain Manni-Bucau
>>>>> <rm...@gmail.com> wrote:
>>>>>> not for war and classpath apps (only for ears)
>>>>>>
>>>>>>
>>>>>> Romain Manni-Bucau
>>>>>> @rmannibucau
>>>>>> http://www.tomitribe.com
>>>>>> http://rmannibucau.wordpress.com
>>>>>> https://github.com/rmannibucau
>>>>>>
>>>>>>
>>>>>> 2014-10-13 13:07 GMT+02:00 Andy Gumbrecht <ag...@tomitribe.com>:
>>>>>>> Could this be related the '*openejb.finder.module-scoped=true*' property?
>>>>>>>
>>>>>>> Andy.
>>>>>>>
>>>>>>>
>>>>>>> On 13/10/2014 08:39, Romain Manni-Bucau wrote:
>>>>>>>>
>>>>>>>> Hi
>>>>>>>>
>>>>>>>> it should do out of the box,can you share more details/code?
>>>>>>>>
>>>>>>>>
>>>>>>>> Romain Manni-Bucau
>>>>>>>> @rmannibucau
>>>>>>>> http://www.tomitribe.com
>>>>>>>> http://rmannibucau.wordpress.com
>>>>>>>> https://github.com/rmannibucau
>>>>>>>>
>>>>>>>>
>>>>>>>> 2014-10-13 7:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>>>>>>
>>>>>>>>> I am writing unit tests. The unit test include multiple jars, each of
>>>>>>>>> them has JPA entities and persistence.xml file. Each file has it's own
>>>>>>>>> Persistence Context.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> The JPA entities in jar B references some entities in jar file A. I
>>>>>>>>> need to load both persistence.xml.
>>>>>>>>>
>>>>>>>>> Is there a way to instruct openejb container to scan for other
>>>>>>>>> persistence.xml in different jars ??
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Andy Gumbrecht
>>>>>>> https://twitter.com/AndyGeeDe
>>>>>>> http://www.tomitribe.com
>>>>>>>
Re: Multiple persistence.xml in different jars
Posted by Mansour Al Akeel <ma...@gmail.com>.
No. I am using openejb embedded 4.6.0
On Tue, Oct 14, 2014 at 10:43 AM, Romain Manni-Bucau
<rm...@gmail.com> wrote:
> asm4? you are not on tomee 1.7?
>
>
> Romain Manni-Bucau
> @rmannibucau
> http://www.tomitribe.com
> http://rmannibucau.wordpress.com
> https://github.com/rmannibucau
>
>
> 2014-10-14 16:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>> Thank you Romain.
>> The target/classes was in the class path, but the size of the url array was 0.
>>
>> This was helpful. I am getting another error, that I was not able to understand.
>>
>> SEVERE: FATAL ERROR: Unknown error in Assembler. Please send the
>> following stack trace and this message to users@openejb.apache.org :
>> java.lang.IllegalArgumentException
>> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
>> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
>> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
>> at org.apache.openejb.util.AnnotationFinder.readClassDef(AnnotationFinder.java:297)
>> at org.apache.openejb.util.AnnotationFinder.find(AnnotationFinder.java:163)
>> at org.apache.openejb.config.DeploymentLoader.checkAnnotations(DeploymentLoader.java:1871)
>> at org.apache.openejb.config.DeploymentLoader.discoverModuleType(DeploymentLoader.java:1782)
>> at org.apache.openejb.config.DeploymentsResolver.processUrls(DeploymentsResolver.java:388)
>> at org.apache.openejb.config.DeploymentsResolver.loadFromClasspath(DeploymentsResolver.java:301)
>> at org.apache.openejb.config.ConfigurationFactory.getModulesFromClassPath(ConfigurationFactory.java:647)
>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:524)
>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:575)
>> at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:429)
>> at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:408)
>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:148)
>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:296)
>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:276)
>>
>>
>> I will continue digging.
>>
>> Thank you a lot.
>>
>>
>> On Tue, Oct 14, 2014 at 2:20 AM, Romain Manni-Bucau
>> <rm...@gmail.com> wrote:
>>> Hi
>>>
>>> we have a mojo like it
>>> http://svn.apache.org/repos/asf/tomee/tomee/trunk/maven/openejb-embedded-maven-plugin/
>>>
>>> I think you miss target/classes in your loader
>>>
>>>
>>> Romain Manni-Bucau
>>> @rmannibucau
>>> http://www.tomitribe.com
>>> http://rmannibucau.wordpress.com
>>> https://github.com/rmannibucau
>>>
>>>
>>> 2014-10-14 6:37 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>> Romain,
>>>> It was my fault. I was loading the persistence context using openjpa.
>>>> However, switched to OpenEJB to allow scanning for the persistence.xml
>>>> in other jars. The problem is the current jar has some EJBs. I am
>>>> loading them from maven mojo. In a way, it's similar to unit testing.
>>>>
>>>> protected void setupClassPath() throws MalformedURLException,
>>>> DependencyResolutionRequiredException
>>>> {
>>>>
>>>> synchronized (this)
>>>> {
>>>> if (classLoader != null)
>>>> return;
>>>> }
>>>> synchronized (this)
>>>> {
>>>> List<URL> urls = new ArrayList<URL>();
>>>>
>>>> List<String> paths = new LinkedList<String>();
>>>>
>>>> List<String> compilePath = mavenProject.getCompileClasspathElements();
>>>>
>>>> List<String> testPath = mavenProject.getTestClasspathElements();
>>>>
>>>> List<String> runtimePath = mavenProject.getRuntimeClasspathElements();
>>>>
>>>> List<String> systemPath = mavenProject.getSystemClasspathElements();
>>>>
>>>> List<Dependency> dependencies = mavenProject.getCompileDependencies();
>>>>
>>>> this.merge(paths, compilePath);
>>>> this.merge(paths, testPath);
>>>> this.merge(paths, runtimePath);
>>>> this.merge(paths, systemPath);
>>>>
>>>> getLog().info("Scanning ... ");
>>>>
>>>> for (Object object : paths)
>>>> {
>>>> String path = (String) object;
>>>>
>>>> getLog().info("Adding " + path + " to classpath");
>>>>
>>>> urls.add(new File(path).toURL());
>>>> }
>>>>
>>>> ClassLoader parent = Thread.currentThread().getContextClassLoader();
>>>>
>>>> parent = this.getClass().getClassLoader();
>>>>
>>>> ClassLoader contextClassLoader =
>>>> URLClassLoader.newInstance(urls.toArray(new URL[0]), parent);
>>>>
>>>> Thread.currentThread().setContextClassLoader(contextClassLoader);
>>>>
>>>> return;
>>>> }
>>>> }
>>>>
>>>> .....
>>>>
>>>> properties.put(Context.INITIAL_CONTEXT_FACTORY,
>>>> "org.apache.openejb.client.LocalInitialContextFactory");
>>>>
>>>> // properties.put(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
>>>> properties.put("openejb.validation.output.level", "VERBOSE");
>>>>
>>>> properties.put("jdbc/dataSource", "new://Resource?type=DataSource");
>>>> properties.put("jdbc/dataSource.JdbcDriver", this.driver);
>>>> properties.put("jdbc/dataSource.JdbcUrl", this.url);
>>>> properties.put("jdbc/dataSource.UserName", this.username);
>>>> properties.put("jdbc/dataSource.Password", this.password);
>>>>
>>>> properties.setProperty("javax.persistence.transactionType",
>>>> "RESOURCE_LOCAL");
>>>>
>>>> Context ctx;
>>>> try
>>>> {
>>>>
>>>> ctx = new InitialContext(properties);
>>>>
>>>>
>>>> The problem I am facing now, is that not all the dependencies are
>>>> available for OpenEJB:
>>>>
>>>> Oct 13, 2014 10:15:36 PM org.apache.openejb.OpenEJB$Instance <init>
>>>> SEVERE: OpenEJB has encountered a fatal error and cannot be started:
>>>> The Assembler encountered an unexpected error while attempting to
>>>> build the container system.
>>>> java.lang.NoClassDefFoundError:
>>>> org/perfectjpattern/jee/integration/dao/AbstractJpaManagedBaseDao
>>>> at java.lang.ClassLoader.defineClass1(Native Method)
>>>> at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
>>>> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
>>>> at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
>>>> at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
>>>> at java.security.AccessController.doPrivileged(Native Method)
>>>> at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
>>>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:180)
>>>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:74)
>>>> at org.apache.xbean.finder.archive.JarArchive.loadClass(JarArchive.java:84)
>>>> at org.apache.xbean.finder.archive.CompositeArchive.loadClass(CompositeArchive.java:58)
>>>> at org.apache.openejb.config.FinderFactory$DebugArchive.loadClass(FinderFactory.java:139)
>>>> at org.apache.xbean.finder.AnnotationFinder$ClassInfo.get(AnnotationFinder.java:1425)
>>>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:540)
>>>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:489)
>>>> at org.apache.openejb.config.FinderFactory$ModuleLimitedFinder.findMetaAnnotatedClasses(FinderFactory.java:291)
>>>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:1391)
>>>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:436)
>>>> at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:351)
>>>> at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:396)
>>>> at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:938)
>>>> at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:799)
>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:531)
>>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:575)
>>>> at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:429)
>>>> at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:408)
>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:148)
>>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:296)
>>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:276)
>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>> at java.lang.reflect.Method.invoke(Method.java:606)
>>>> at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
>>>> at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:96)
>>>> at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:60)
>>>> at org.apache.openejb.core.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:44)
>>>>
>>>>
>>>> I am not sure if adding dependencies to OpenEJB class works using
>>>>
>>>> Thread.currentThread().setContextClassLoader(contextClassLoader);
>>>>
>>>> Thank you.
>>>>
>>>>
>>>> On Mon, Oct 13, 2014 at 7:10 AM, Romain Manni-Bucau
>>>> <rm...@gmail.com> wrote:
>>>>> not for war and classpath apps (only for ears)
>>>>>
>>>>>
>>>>> Romain Manni-Bucau
>>>>> @rmannibucau
>>>>> http://www.tomitribe.com
>>>>> http://rmannibucau.wordpress.com
>>>>> https://github.com/rmannibucau
>>>>>
>>>>>
>>>>> 2014-10-13 13:07 GMT+02:00 Andy Gumbrecht <ag...@tomitribe.com>:
>>>>>> Could this be related the '*openejb.finder.module-scoped=true*' property?
>>>>>>
>>>>>> Andy.
>>>>>>
>>>>>>
>>>>>> On 13/10/2014 08:39, Romain Manni-Bucau wrote:
>>>>>>>
>>>>>>> Hi
>>>>>>>
>>>>>>> it should do out of the box,can you share more details/code?
>>>>>>>
>>>>>>>
>>>>>>> Romain Manni-Bucau
>>>>>>> @rmannibucau
>>>>>>> http://www.tomitribe.com
>>>>>>> http://rmannibucau.wordpress.com
>>>>>>> https://github.com/rmannibucau
>>>>>>>
>>>>>>>
>>>>>>> 2014-10-13 7:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>>>>>
>>>>>>>> I am writing unit tests. The unit test include multiple jars, each of
>>>>>>>> them has JPA entities and persistence.xml file. Each file has it's own
>>>>>>>> Persistence Context.
>>>>>>>>
>>>>>>>>
>>>>>>>> The JPA entities in jar B references some entities in jar file A. I
>>>>>>>> need to load both persistence.xml.
>>>>>>>>
>>>>>>>> Is there a way to instruct openejb container to scan for other
>>>>>>>> persistence.xml in different jars ??
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Andy Gumbrecht
>>>>>> https://twitter.com/AndyGeeDe
>>>>>> http://www.tomitribe.com
>>>>>>
Re: Multiple persistence.xml in different jars
Posted by Romain Manni-Bucau <rm...@gmail.com>.
asm4? you are not on tomee 1.7?
Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau
2014-10-14 16:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
> Thank you Romain.
> The target/classes was in the class path, but the size of the url array was 0.
>
> This was helpful. I am getting another error, that I was not able to understand.
>
> SEVERE: FATAL ERROR: Unknown error in Assembler. Please send the
> following stack trace and this message to users@openejb.apache.org :
> java.lang.IllegalArgumentException
> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
> at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
> at org.apache.openejb.util.AnnotationFinder.readClassDef(AnnotationFinder.java:297)
> at org.apache.openejb.util.AnnotationFinder.find(AnnotationFinder.java:163)
> at org.apache.openejb.config.DeploymentLoader.checkAnnotations(DeploymentLoader.java:1871)
> at org.apache.openejb.config.DeploymentLoader.discoverModuleType(DeploymentLoader.java:1782)
> at org.apache.openejb.config.DeploymentsResolver.processUrls(DeploymentsResolver.java:388)
> at org.apache.openejb.config.DeploymentsResolver.loadFromClasspath(DeploymentsResolver.java:301)
> at org.apache.openejb.config.ConfigurationFactory.getModulesFromClassPath(ConfigurationFactory.java:647)
> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:524)
> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:575)
> at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:429)
> at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:408)
> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:148)
> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
> at org.apache.openejb.OpenEJB.init(OpenEJB.java:296)
> at org.apache.openejb.OpenEJB.init(OpenEJB.java:276)
>
>
> I will continue digging.
>
> Thank you a lot.
>
>
> On Tue, Oct 14, 2014 at 2:20 AM, Romain Manni-Bucau
> <rm...@gmail.com> wrote:
>> Hi
>>
>> we have a mojo like it
>> http://svn.apache.org/repos/asf/tomee/tomee/trunk/maven/openejb-embedded-maven-plugin/
>>
>> I think you miss target/classes in your loader
>>
>>
>> Romain Manni-Bucau
>> @rmannibucau
>> http://www.tomitribe.com
>> http://rmannibucau.wordpress.com
>> https://github.com/rmannibucau
>>
>>
>> 2014-10-14 6:37 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>> Romain,
>>> It was my fault. I was loading the persistence context using openjpa.
>>> However, switched to OpenEJB to allow scanning for the persistence.xml
>>> in other jars. The problem is the current jar has some EJBs. I am
>>> loading them from maven mojo. In a way, it's similar to unit testing.
>>>
>>> protected void setupClassPath() throws MalformedURLException,
>>> DependencyResolutionRequiredException
>>> {
>>>
>>> synchronized (this)
>>> {
>>> if (classLoader != null)
>>> return;
>>> }
>>> synchronized (this)
>>> {
>>> List<URL> urls = new ArrayList<URL>();
>>>
>>> List<String> paths = new LinkedList<String>();
>>>
>>> List<String> compilePath = mavenProject.getCompileClasspathElements();
>>>
>>> List<String> testPath = mavenProject.getTestClasspathElements();
>>>
>>> List<String> runtimePath = mavenProject.getRuntimeClasspathElements();
>>>
>>> List<String> systemPath = mavenProject.getSystemClasspathElements();
>>>
>>> List<Dependency> dependencies = mavenProject.getCompileDependencies();
>>>
>>> this.merge(paths, compilePath);
>>> this.merge(paths, testPath);
>>> this.merge(paths, runtimePath);
>>> this.merge(paths, systemPath);
>>>
>>> getLog().info("Scanning ... ");
>>>
>>> for (Object object : paths)
>>> {
>>> String path = (String) object;
>>>
>>> getLog().info("Adding " + path + " to classpath");
>>>
>>> urls.add(new File(path).toURL());
>>> }
>>>
>>> ClassLoader parent = Thread.currentThread().getContextClassLoader();
>>>
>>> parent = this.getClass().getClassLoader();
>>>
>>> ClassLoader contextClassLoader =
>>> URLClassLoader.newInstance(urls.toArray(new URL[0]), parent);
>>>
>>> Thread.currentThread().setContextClassLoader(contextClassLoader);
>>>
>>> return;
>>> }
>>> }
>>>
>>> .....
>>>
>>> properties.put(Context.INITIAL_CONTEXT_FACTORY,
>>> "org.apache.openejb.client.LocalInitialContextFactory");
>>>
>>> // properties.put(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
>>> properties.put("openejb.validation.output.level", "VERBOSE");
>>>
>>> properties.put("jdbc/dataSource", "new://Resource?type=DataSource");
>>> properties.put("jdbc/dataSource.JdbcDriver", this.driver);
>>> properties.put("jdbc/dataSource.JdbcUrl", this.url);
>>> properties.put("jdbc/dataSource.UserName", this.username);
>>> properties.put("jdbc/dataSource.Password", this.password);
>>>
>>> properties.setProperty("javax.persistence.transactionType",
>>> "RESOURCE_LOCAL");
>>>
>>> Context ctx;
>>> try
>>> {
>>>
>>> ctx = new InitialContext(properties);
>>>
>>>
>>> The problem I am facing now, is that not all the dependencies are
>>> available for OpenEJB:
>>>
>>> Oct 13, 2014 10:15:36 PM org.apache.openejb.OpenEJB$Instance <init>
>>> SEVERE: OpenEJB has encountered a fatal error and cannot be started:
>>> The Assembler encountered an unexpected error while attempting to
>>> build the container system.
>>> java.lang.NoClassDefFoundError:
>>> org/perfectjpattern/jee/integration/dao/AbstractJpaManagedBaseDao
>>> at java.lang.ClassLoader.defineClass1(Native Method)
>>> at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
>>> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
>>> at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
>>> at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
>>> at java.security.AccessController.doPrivileged(Native Method)
>>> at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
>>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:180)
>>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:74)
>>> at org.apache.xbean.finder.archive.JarArchive.loadClass(JarArchive.java:84)
>>> at org.apache.xbean.finder.archive.CompositeArchive.loadClass(CompositeArchive.java:58)
>>> at org.apache.openejb.config.FinderFactory$DebugArchive.loadClass(FinderFactory.java:139)
>>> at org.apache.xbean.finder.AnnotationFinder$ClassInfo.get(AnnotationFinder.java:1425)
>>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:540)
>>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:489)
>>> at org.apache.openejb.config.FinderFactory$ModuleLimitedFinder.findMetaAnnotatedClasses(FinderFactory.java:291)
>>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:1391)
>>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:436)
>>> at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:351)
>>> at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:396)
>>> at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:938)
>>> at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:799)
>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:531)
>>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:575)
>>> at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:429)
>>> at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:408)
>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:148)
>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:296)
>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:276)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>> at java.lang.reflect.Method.invoke(Method.java:606)
>>> at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
>>> at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:96)
>>> at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:60)
>>> at org.apache.openejb.core.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:44)
>>>
>>>
>>> I am not sure if adding dependencies to OpenEJB class works using
>>>
>>> Thread.currentThread().setContextClassLoader(contextClassLoader);
>>>
>>> Thank you.
>>>
>>>
>>> On Mon, Oct 13, 2014 at 7:10 AM, Romain Manni-Bucau
>>> <rm...@gmail.com> wrote:
>>>> not for war and classpath apps (only for ears)
>>>>
>>>>
>>>> Romain Manni-Bucau
>>>> @rmannibucau
>>>> http://www.tomitribe.com
>>>> http://rmannibucau.wordpress.com
>>>> https://github.com/rmannibucau
>>>>
>>>>
>>>> 2014-10-13 13:07 GMT+02:00 Andy Gumbrecht <ag...@tomitribe.com>:
>>>>> Could this be related the '*openejb.finder.module-scoped=true*' property?
>>>>>
>>>>> Andy.
>>>>>
>>>>>
>>>>> On 13/10/2014 08:39, Romain Manni-Bucau wrote:
>>>>>>
>>>>>> Hi
>>>>>>
>>>>>> it should do out of the box,can you share more details/code?
>>>>>>
>>>>>>
>>>>>> Romain Manni-Bucau
>>>>>> @rmannibucau
>>>>>> http://www.tomitribe.com
>>>>>> http://rmannibucau.wordpress.com
>>>>>> https://github.com/rmannibucau
>>>>>>
>>>>>>
>>>>>> 2014-10-13 7:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>>>>
>>>>>>> I am writing unit tests. The unit test include multiple jars, each of
>>>>>>> them has JPA entities and persistence.xml file. Each file has it's own
>>>>>>> Persistence Context.
>>>>>>>
>>>>>>>
>>>>>>> The JPA entities in jar B references some entities in jar file A. I
>>>>>>> need to load both persistence.xml.
>>>>>>>
>>>>>>> Is there a way to instruct openejb container to scan for other
>>>>>>> persistence.xml in different jars ??
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Andy Gumbrecht
>>>>> https://twitter.com/AndyGeeDe
>>>>> http://www.tomitribe.com
>>>>>
Re: Multiple persistence.xml in different jars
Posted by Mansour Al Akeel <ma...@gmail.com>.
Thank you Romain.
The target/classes was in the class path, but the size of the url array was 0.
This was helpful. I am getting another error, that I was not able to understand.
SEVERE: FATAL ERROR: Unknown error in Assembler. Please send the
following stack trace and this message to users@openejb.apache.org :
java.lang.IllegalArgumentException
at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
at org.apache.openejb.util.AnnotationFinder.readClassDef(AnnotationFinder.java:297)
at org.apache.openejb.util.AnnotationFinder.find(AnnotationFinder.java:163)
at org.apache.openejb.config.DeploymentLoader.checkAnnotations(DeploymentLoader.java:1871)
at org.apache.openejb.config.DeploymentLoader.discoverModuleType(DeploymentLoader.java:1782)
at org.apache.openejb.config.DeploymentsResolver.processUrls(DeploymentsResolver.java:388)
at org.apache.openejb.config.DeploymentsResolver.loadFromClasspath(DeploymentsResolver.java:301)
at org.apache.openejb.config.ConfigurationFactory.getModulesFromClassPath(ConfigurationFactory.java:647)
at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:524)
at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:575)
at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:429)
at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:408)
at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:148)
at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
at org.apache.openejb.OpenEJB.init(OpenEJB.java:296)
at org.apache.openejb.OpenEJB.init(OpenEJB.java:276)
I will continue digging.
Thank you a lot.
On Tue, Oct 14, 2014 at 2:20 AM, Romain Manni-Bucau
<rm...@gmail.com> wrote:
> Hi
>
> we have a mojo like it
> http://svn.apache.org/repos/asf/tomee/tomee/trunk/maven/openejb-embedded-maven-plugin/
>
> I think you miss target/classes in your loader
>
>
> Romain Manni-Bucau
> @rmannibucau
> http://www.tomitribe.com
> http://rmannibucau.wordpress.com
> https://github.com/rmannibucau
>
>
> 2014-10-14 6:37 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>> Romain,
>> It was my fault. I was loading the persistence context using openjpa.
>> However, switched to OpenEJB to allow scanning for the persistence.xml
>> in other jars. The problem is the current jar has some EJBs. I am
>> loading them from maven mojo. In a way, it's similar to unit testing.
>>
>> protected void setupClassPath() throws MalformedURLException,
>> DependencyResolutionRequiredException
>> {
>>
>> synchronized (this)
>> {
>> if (classLoader != null)
>> return;
>> }
>> synchronized (this)
>> {
>> List<URL> urls = new ArrayList<URL>();
>>
>> List<String> paths = new LinkedList<String>();
>>
>> List<String> compilePath = mavenProject.getCompileClasspathElements();
>>
>> List<String> testPath = mavenProject.getTestClasspathElements();
>>
>> List<String> runtimePath = mavenProject.getRuntimeClasspathElements();
>>
>> List<String> systemPath = mavenProject.getSystemClasspathElements();
>>
>> List<Dependency> dependencies = mavenProject.getCompileDependencies();
>>
>> this.merge(paths, compilePath);
>> this.merge(paths, testPath);
>> this.merge(paths, runtimePath);
>> this.merge(paths, systemPath);
>>
>> getLog().info("Scanning ... ");
>>
>> for (Object object : paths)
>> {
>> String path = (String) object;
>>
>> getLog().info("Adding " + path + " to classpath");
>>
>> urls.add(new File(path).toURL());
>> }
>>
>> ClassLoader parent = Thread.currentThread().getContextClassLoader();
>>
>> parent = this.getClass().getClassLoader();
>>
>> ClassLoader contextClassLoader =
>> URLClassLoader.newInstance(urls.toArray(new URL[0]), parent);
>>
>> Thread.currentThread().setContextClassLoader(contextClassLoader);
>>
>> return;
>> }
>> }
>>
>> .....
>>
>> properties.put(Context.INITIAL_CONTEXT_FACTORY,
>> "org.apache.openejb.client.LocalInitialContextFactory");
>>
>> // properties.put(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
>> properties.put("openejb.validation.output.level", "VERBOSE");
>>
>> properties.put("jdbc/dataSource", "new://Resource?type=DataSource");
>> properties.put("jdbc/dataSource.JdbcDriver", this.driver);
>> properties.put("jdbc/dataSource.JdbcUrl", this.url);
>> properties.put("jdbc/dataSource.UserName", this.username);
>> properties.put("jdbc/dataSource.Password", this.password);
>>
>> properties.setProperty("javax.persistence.transactionType",
>> "RESOURCE_LOCAL");
>>
>> Context ctx;
>> try
>> {
>>
>> ctx = new InitialContext(properties);
>>
>>
>> The problem I am facing now, is that not all the dependencies are
>> available for OpenEJB:
>>
>> Oct 13, 2014 10:15:36 PM org.apache.openejb.OpenEJB$Instance <init>
>> SEVERE: OpenEJB has encountered a fatal error and cannot be started:
>> The Assembler encountered an unexpected error while attempting to
>> build the container system.
>> java.lang.NoClassDefFoundError:
>> org/perfectjpattern/jee/integration/dao/AbstractJpaManagedBaseDao
>> at java.lang.ClassLoader.defineClass1(Native Method)
>> at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
>> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
>> at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
>> at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
>> at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
>> at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:180)
>> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:74)
>> at org.apache.xbean.finder.archive.JarArchive.loadClass(JarArchive.java:84)
>> at org.apache.xbean.finder.archive.CompositeArchive.loadClass(CompositeArchive.java:58)
>> at org.apache.openejb.config.FinderFactory$DebugArchive.loadClass(FinderFactory.java:139)
>> at org.apache.xbean.finder.AnnotationFinder$ClassInfo.get(AnnotationFinder.java:1425)
>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:540)
>> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:489)
>> at org.apache.openejb.config.FinderFactory$ModuleLimitedFinder.findMetaAnnotatedClasses(FinderFactory.java:291)
>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:1391)
>> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:436)
>> at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:351)
>> at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:396)
>> at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:938)
>> at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:799)
>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:531)
>> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:575)
>> at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:429)
>> at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:408)
>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:148)
>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:296)
>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:276)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> at java.lang.reflect.Method.invoke(Method.java:606)
>> at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
>> at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:96)
>> at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:60)
>> at org.apache.openejb.core.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:44)
>>
>>
>> I am not sure if adding dependencies to OpenEJB class works using
>>
>> Thread.currentThread().setContextClassLoader(contextClassLoader);
>>
>> Thank you.
>>
>>
>> On Mon, Oct 13, 2014 at 7:10 AM, Romain Manni-Bucau
>> <rm...@gmail.com> wrote:
>>> not for war and classpath apps (only for ears)
>>>
>>>
>>> Romain Manni-Bucau
>>> @rmannibucau
>>> http://www.tomitribe.com
>>> http://rmannibucau.wordpress.com
>>> https://github.com/rmannibucau
>>>
>>>
>>> 2014-10-13 13:07 GMT+02:00 Andy Gumbrecht <ag...@tomitribe.com>:
>>>> Could this be related the '*openejb.finder.module-scoped=true*' property?
>>>>
>>>> Andy.
>>>>
>>>>
>>>> On 13/10/2014 08:39, Romain Manni-Bucau wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> it should do out of the box,can you share more details/code?
>>>>>
>>>>>
>>>>> Romain Manni-Bucau
>>>>> @rmannibucau
>>>>> http://www.tomitribe.com
>>>>> http://rmannibucau.wordpress.com
>>>>> https://github.com/rmannibucau
>>>>>
>>>>>
>>>>> 2014-10-13 7:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>>>
>>>>>> I am writing unit tests. The unit test include multiple jars, each of
>>>>>> them has JPA entities and persistence.xml file. Each file has it's own
>>>>>> Persistence Context.
>>>>>>
>>>>>>
>>>>>> The JPA entities in jar B references some entities in jar file A. I
>>>>>> need to load both persistence.xml.
>>>>>>
>>>>>> Is there a way to instruct openejb container to scan for other
>>>>>> persistence.xml in different jars ??
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Andy Gumbrecht
>>>> https://twitter.com/AndyGeeDe
>>>> http://www.tomitribe.com
>>>>
Re: Multiple persistence.xml in different jars
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi
we have a mojo like it
http://svn.apache.org/repos/asf/tomee/tomee/trunk/maven/openejb-embedded-maven-plugin/
I think you miss target/classes in your loader
Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau
2014-10-14 6:37 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
> Romain,
> It was my fault. I was loading the persistence context using openjpa.
> However, switched to OpenEJB to allow scanning for the persistence.xml
> in other jars. The problem is the current jar has some EJBs. I am
> loading them from maven mojo. In a way, it's similar to unit testing.
>
> protected void setupClassPath() throws MalformedURLException,
> DependencyResolutionRequiredException
> {
>
> synchronized (this)
> {
> if (classLoader != null)
> return;
> }
> synchronized (this)
> {
> List<URL> urls = new ArrayList<URL>();
>
> List<String> paths = new LinkedList<String>();
>
> List<String> compilePath = mavenProject.getCompileClasspathElements();
>
> List<String> testPath = mavenProject.getTestClasspathElements();
>
> List<String> runtimePath = mavenProject.getRuntimeClasspathElements();
>
> List<String> systemPath = mavenProject.getSystemClasspathElements();
>
> List<Dependency> dependencies = mavenProject.getCompileDependencies();
>
> this.merge(paths, compilePath);
> this.merge(paths, testPath);
> this.merge(paths, runtimePath);
> this.merge(paths, systemPath);
>
> getLog().info("Scanning ... ");
>
> for (Object object : paths)
> {
> String path = (String) object;
>
> getLog().info("Adding " + path + " to classpath");
>
> urls.add(new File(path).toURL());
> }
>
> ClassLoader parent = Thread.currentThread().getContextClassLoader();
>
> parent = this.getClass().getClassLoader();
>
> ClassLoader contextClassLoader =
> URLClassLoader.newInstance(urls.toArray(new URL[0]), parent);
>
> Thread.currentThread().setContextClassLoader(contextClassLoader);
>
> return;
> }
> }
>
> .....
>
> properties.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.apache.openejb.client.LocalInitialContextFactory");
>
> // properties.put(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
> properties.put("openejb.validation.output.level", "VERBOSE");
>
> properties.put("jdbc/dataSource", "new://Resource?type=DataSource");
> properties.put("jdbc/dataSource.JdbcDriver", this.driver);
> properties.put("jdbc/dataSource.JdbcUrl", this.url);
> properties.put("jdbc/dataSource.UserName", this.username);
> properties.put("jdbc/dataSource.Password", this.password);
>
> properties.setProperty("javax.persistence.transactionType",
> "RESOURCE_LOCAL");
>
> Context ctx;
> try
> {
>
> ctx = new InitialContext(properties);
>
>
> The problem I am facing now, is that not all the dependencies are
> available for OpenEJB:
>
> Oct 13, 2014 10:15:36 PM org.apache.openejb.OpenEJB$Instance <init>
> SEVERE: OpenEJB has encountered a fatal error and cannot be started:
> The Assembler encountered an unexpected error while attempting to
> build the container system.
> java.lang.NoClassDefFoundError:
> org/perfectjpattern/jee/integration/dao/AbstractJpaManagedBaseDao
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
> at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
> at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:180)
> at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:74)
> at org.apache.xbean.finder.archive.JarArchive.loadClass(JarArchive.java:84)
> at org.apache.xbean.finder.archive.CompositeArchive.loadClass(CompositeArchive.java:58)
> at org.apache.openejb.config.FinderFactory$DebugArchive.loadClass(FinderFactory.java:139)
> at org.apache.xbean.finder.AnnotationFinder$ClassInfo.get(AnnotationFinder.java:1425)
> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:540)
> at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:489)
> at org.apache.openejb.config.FinderFactory$ModuleLimitedFinder.findMetaAnnotatedClasses(FinderFactory.java:291)
> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:1391)
> at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:436)
> at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:351)
> at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:396)
> at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:938)
> at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:799)
> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:531)
> at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:575)
> at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:429)
> at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:408)
> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:148)
> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
> at org.apache.openejb.OpenEJB.init(OpenEJB.java:296)
> at org.apache.openejb.OpenEJB.init(OpenEJB.java:276)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
> at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:96)
> at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:60)
> at org.apache.openejb.core.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:44)
>
>
> I am not sure if adding dependencies to OpenEJB class works using
>
> Thread.currentThread().setContextClassLoader(contextClassLoader);
>
> Thank you.
>
>
> On Mon, Oct 13, 2014 at 7:10 AM, Romain Manni-Bucau
> <rm...@gmail.com> wrote:
>> not for war and classpath apps (only for ears)
>>
>>
>> Romain Manni-Bucau
>> @rmannibucau
>> http://www.tomitribe.com
>> http://rmannibucau.wordpress.com
>> https://github.com/rmannibucau
>>
>>
>> 2014-10-13 13:07 GMT+02:00 Andy Gumbrecht <ag...@tomitribe.com>:
>>> Could this be related the '*openejb.finder.module-scoped=true*' property?
>>>
>>> Andy.
>>>
>>>
>>> On 13/10/2014 08:39, Romain Manni-Bucau wrote:
>>>>
>>>> Hi
>>>>
>>>> it should do out of the box,can you share more details/code?
>>>>
>>>>
>>>> Romain Manni-Bucau
>>>> @rmannibucau
>>>> http://www.tomitribe.com
>>>> http://rmannibucau.wordpress.com
>>>> https://github.com/rmannibucau
>>>>
>>>>
>>>> 2014-10-13 7:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>>
>>>>> I am writing unit tests. The unit test include multiple jars, each of
>>>>> them has JPA entities and persistence.xml file. Each file has it's own
>>>>> Persistence Context.
>>>>>
>>>>>
>>>>> The JPA entities in jar B references some entities in jar file A. I
>>>>> need to load both persistence.xml.
>>>>>
>>>>> Is there a way to instruct openejb container to scan for other
>>>>> persistence.xml in different jars ??
>>>>
>>>>
>>>
>>>
>>> --
>>> Andy Gumbrecht
>>> https://twitter.com/AndyGeeDe
>>> http://www.tomitribe.com
>>>
Re: Multiple persistence.xml in different jars
Posted by Mansour Al Akeel <ma...@gmail.com>.
Romain,
It was my fault. I was loading the persistence context using openjpa.
However, switched to OpenEJB to allow scanning for the persistence.xml
in other jars. The problem is the current jar has some EJBs. I am
loading them from maven mojo. In a way, it's similar to unit testing.
protected void setupClassPath() throws MalformedURLException,
DependencyResolutionRequiredException
{
synchronized (this)
{
if (classLoader != null)
return;
}
synchronized (this)
{
List<URL> urls = new ArrayList<URL>();
List<String> paths = new LinkedList<String>();
List<String> compilePath = mavenProject.getCompileClasspathElements();
List<String> testPath = mavenProject.getTestClasspathElements();
List<String> runtimePath = mavenProject.getRuntimeClasspathElements();
List<String> systemPath = mavenProject.getSystemClasspathElements();
List<Dependency> dependencies = mavenProject.getCompileDependencies();
this.merge(paths, compilePath);
this.merge(paths, testPath);
this.merge(paths, runtimePath);
this.merge(paths, systemPath);
getLog().info("Scanning ... ");
for (Object object : paths)
{
String path = (String) object;
getLog().info("Adding " + path + " to classpath");
urls.add(new File(path).toURL());
}
ClassLoader parent = Thread.currentThread().getContextClassLoader();
parent = this.getClass().getClassLoader();
ClassLoader contextClassLoader =
URLClassLoader.newInstance(urls.toArray(new URL[0]), parent);
Thread.currentThread().setContextClassLoader(contextClassLoader);
return;
}
}
.....
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
// properties.put(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
properties.put("openejb.validation.output.level", "VERBOSE");
properties.put("jdbc/dataSource", "new://Resource?type=DataSource");
properties.put("jdbc/dataSource.JdbcDriver", this.driver);
properties.put("jdbc/dataSource.JdbcUrl", this.url);
properties.put("jdbc/dataSource.UserName", this.username);
properties.put("jdbc/dataSource.Password", this.password);
properties.setProperty("javax.persistence.transactionType",
"RESOURCE_LOCAL");
Context ctx;
try
{
ctx = new InitialContext(properties);
The problem I am facing now, is that not all the dependencies are
available for OpenEJB:
Oct 13, 2014 10:15:36 PM org.apache.openejb.OpenEJB$Instance <init>
SEVERE: OpenEJB has encountered a fatal error and cannot be started:
The Assembler encountered an unexpected error while attempting to
build the container system.
java.lang.NoClassDefFoundError:
org/perfectjpattern/jee/integration/dao/AbstractJpaManagedBaseDao
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:180)
at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:74)
at org.apache.xbean.finder.archive.JarArchive.loadClass(JarArchive.java:84)
at org.apache.xbean.finder.archive.CompositeArchive.loadClass(CompositeArchive.java:58)
at org.apache.openejb.config.FinderFactory$DebugArchive.loadClass(FinderFactory.java:139)
at org.apache.xbean.finder.AnnotationFinder$ClassInfo.get(AnnotationFinder.java:1425)
at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:540)
at org.apache.xbean.finder.AnnotationFinder.findMetaAnnotatedClasses(AnnotationFinder.java:489)
at org.apache.openejb.config.FinderFactory$ModuleLimitedFinder.findMetaAnnotatedClasses(FinderFactory.java:291)
at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:1391)
at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:436)
at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:351)
at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:396)
at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:938)
at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:799)
at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:531)
at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:575)
at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:429)
at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:408)
at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:148)
at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:65)
at org.apache.openejb.OpenEJB.init(OpenEJB.java:296)
at org.apache.openejb.OpenEJB.init(OpenEJB.java:276)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:96)
at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:60)
at org.apache.openejb.core.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:44)
I am not sure if adding dependencies to OpenEJB class works using
Thread.currentThread().setContextClassLoader(contextClassLoader);
Thank you.
On Mon, Oct 13, 2014 at 7:10 AM, Romain Manni-Bucau
<rm...@gmail.com> wrote:
> not for war and classpath apps (only for ears)
>
>
> Romain Manni-Bucau
> @rmannibucau
> http://www.tomitribe.com
> http://rmannibucau.wordpress.com
> https://github.com/rmannibucau
>
>
> 2014-10-13 13:07 GMT+02:00 Andy Gumbrecht <ag...@tomitribe.com>:
>> Could this be related the '*openejb.finder.module-scoped=true*' property?
>>
>> Andy.
>>
>>
>> On 13/10/2014 08:39, Romain Manni-Bucau wrote:
>>>
>>> Hi
>>>
>>> it should do out of the box,can you share more details/code?
>>>
>>>
>>> Romain Manni-Bucau
>>> @rmannibucau
>>> http://www.tomitribe.com
>>> http://rmannibucau.wordpress.com
>>> https://github.com/rmannibucau
>>>
>>>
>>> 2014-10-13 7:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>>
>>>> I am writing unit tests. The unit test include multiple jars, each of
>>>> them has JPA entities and persistence.xml file. Each file has it's own
>>>> Persistence Context.
>>>>
>>>>
>>>> The JPA entities in jar B references some entities in jar file A. I
>>>> need to load both persistence.xml.
>>>>
>>>> Is there a way to instruct openejb container to scan for other
>>>> persistence.xml in different jars ??
>>>
>>>
>>
>>
>> --
>> Andy Gumbrecht
>> https://twitter.com/AndyGeeDe
>> http://www.tomitribe.com
>>
Re: Multiple persistence.xml in different jars
Posted by Romain Manni-Bucau <rm...@gmail.com>.
not for war and classpath apps (only for ears)
Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau
2014-10-13 13:07 GMT+02:00 Andy Gumbrecht <ag...@tomitribe.com>:
> Could this be related the '*openejb.finder.module-scoped=true*' property?
>
> Andy.
>
>
> On 13/10/2014 08:39, Romain Manni-Bucau wrote:
>>
>> Hi
>>
>> it should do out of the box,can you share more details/code?
>>
>>
>> Romain Manni-Bucau
>> @rmannibucau
>> http://www.tomitribe.com
>> http://rmannibucau.wordpress.com
>> https://github.com/rmannibucau
>>
>>
>> 2014-10-13 7:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>>>
>>> I am writing unit tests. The unit test include multiple jars, each of
>>> them has JPA entities and persistence.xml file. Each file has it's own
>>> Persistence Context.
>>>
>>>
>>> The JPA entities in jar B references some entities in jar file A. I
>>> need to load both persistence.xml.
>>>
>>> Is there a way to instruct openejb container to scan for other
>>> persistence.xml in different jars ??
>>
>>
>
>
> --
> Andy Gumbrecht
> https://twitter.com/AndyGeeDe
> http://www.tomitribe.com
>
Re: Multiple persistence.xml in different jars
Posted by Andy Gumbrecht <ag...@tomitribe.com>.
Could this be related the '*openejb.finder.module-scoped=true*' property?
Andy.
On 13/10/2014 08:39, Romain Manni-Bucau wrote:
> Hi
>
> it should do out of the box,can you share more details/code?
>
>
> Romain Manni-Bucau
> @rmannibucau
> http://www.tomitribe.com
> http://rmannibucau.wordpress.com
> https://github.com/rmannibucau
>
>
> 2014-10-13 7:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
>> I am writing unit tests. The unit test include multiple jars, each of
>> them has JPA entities and persistence.xml file. Each file has it's own
>> Persistence Context.
>>
>>
>> The JPA entities in jar B references some entities in jar file A. I
>> need to load both persistence.xml.
>>
>> Is there a way to instruct openejb container to scan for other
>> persistence.xml in different jars ??
>
--
Andy Gumbrecht
https://twitter.com/AndyGeeDe
http://www.tomitribe.com
Re: Multiple persistence.xml in different jars
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi
it should do out of the box,can you share more details/code?
Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau
2014-10-13 7:40 GMT+02:00 Mansour Al Akeel <ma...@gmail.com>:
> I am writing unit tests. The unit test include multiple jars, each of
> them has JPA entities and persistence.xml file. Each file has it's own
> Persistence Context.
>
>
> The JPA entities in jar B references some entities in jar file A. I
> need to load both persistence.xml.
>
> Is there a way to instruct openejb container to scan for other
> persistence.xml in different jars ??