tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@gmail.com>
Subject Re: NameAlreadyBoundException: ParsedName{path=openejb/client/test-classes/comp/env, component=env}
Date Sat, 02 Jul 2011 03:44:17 GMT

On Jul 1, 2011, at 7:51 PM, Marius Kruger wrote:

> hi,
> I keep hitting this every couple of months or weeks.
> Basically it seems that openejb does not allow you to have multiple
> application clients in the classpath :(
> and gives the exception below.
> 
> I logged a bug: https://issues.apache.org/jira/browse/OPENEJB-1366
> and I saw that this was discussed before:
> http://openejb.979440.n4.nabble.com/OpenEJB-localclient-module-name-td2238205.html
> But there does not seem to be a workaround (I tried Apache OpenEJB
> 3.2.0-SNAPSHOT    build: 20110630-03:56 too)
> 
> Am I missing something?  Should I just live with the pain for now?
> If I want to look into fixing it where do I start?

Hi Marius!

Very excellent if you have any time to hack on it.  An adaptation of something we did in trunk
might work here.  We could certainly introduce this in 3.2 with some help.

When guessing the default module id based on the file path, we now do this (trunk):

        private String moduleName(File location) {
            List<String> invalid = new ArrayList<String>();
            invalid.add("classes");
            invalid.add("test-classes");
            invalid.add("target");
            invalid.add("build");
            invalid.add("dist");
            invalid.add("bin");

            while (invalid.contains(location.getName())) {
                location = location.getParentFile();
            }
            return stripExtension(location.getName());
        }

        private String stripExtension(String name) {
            String[] exts = {".jar", ".zip", ".ear", ".war", ".rar", ".unpacked"};
            for (String ext : exts) {
                if (name.endsWith(ext)) {
                    return name.substring(0, name.length() - ext.length());
                }
            }
            return name;
        }

So basically if we see "test-classes" we assume it's not valid and keep walking backward till
we find something we hope is more unique.

It was done as part of a much bigger change to get all module IDs to be a little more consistent
and under control (OPENEJB-1442), but adding this one little gem to at least ClientModule.java
should be pretty easy.

It won't fix the issue of not being able to set the module ID explicitly, but probably the
default will wind up being what you wanted anyway.  I can still give hints on that if you
want.

-David

> ==
> 2011-07-02 04:38:55,043:ERROR Application could not be deployed:
> classpath.ear - OpenEJB.startup
> org.apache.openejb.OpenEJBException: Creating application failed:
> classpath.ear: ParsedName{path=openejb/client/test-classes/comp/env,
> component=env}
> at
> org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:722)
> at
> org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:456)
> at
> org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(Assembler.java:374)
> at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:286)
> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:125)
> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:60)
> at org.apache.openejb.OpenEJB.init(OpenEJB.java:271)
> at org.apache.openejb.OpenEJB.init(OpenEJB.java:250)
> 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:616)
> at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
> at
> org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:71)
> at
> org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:53)
> at
> org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:42)
> at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
> at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:305)
> at javax.naming.InitialContext.init(InitialContext.java:240)
> at javax.naming.InitialContext.<init>(InitialContext.java:214)
> at
> za.co.enerweb.ebr.oe.OrchestrationEngineFactory.getEjbContext(OrchestrationEngineFactory.java:76)
> at
> za.co.enerweb.ebr.oe.OrchestrationEngineFactory.lookupEjb(OrchestrationEngineFactory.java:165)
> at
> za.co.enerweb.ebr.oe.OrchestrationEngineFactory.open(OrchestrationEngineFactory.java:179)
> at
> za.co.enerweb.ebr.oe.OrchestrationEngineFactory.getEjbContext(OrchestrationEngineFactory.java:61)
> at
> za.co.enerweb.ebr.oe.OrchestrationEngineFactory.lookupEjb(OrchestrationEngineFactory.java:165)
> at
> za.co.enerweb.ebr.oe.OrchestrationEngineFactory.lookupEjb(OrchestrationEngineFactory.java:156)
> at
> za.co.enerweb.ebr.oe.OrchestrationEngineFactory.lookupEjb(OrchestrationEngineFactory.java:151)
> at
> za.co.enerweb.ebr.oe.OrchestrationEngineFactory.getOrchestrationEngine(OrchestrationEngineFactory.java:237)
> at
> za.co.enerweb.ebr.oe.AbstractOrchestrationEngineTest.setUpBeforeInjection(AbstractOrchestrationEngineTest.java:47)
> at
> za.co.enerweb.ebr.oe.AbstractEjbTest.setInjectResources(AbstractEjbTest.java:24)
> 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:616)
> at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
> at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
> at
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
> at
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
> at org.junit.rules.TestWatchman$1.evaluate(TestWatchman.java:48)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
> at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
> at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> Caused by: javax.naming.NameAlreadyBoundException:
> ParsedName{path=openejb/client/test-classes/comp/env, component=env}
> at org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:96)
> at org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:90)
> at org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:90)
> at org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:105)
> at org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:90)
> at org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:105)
> at org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:105)
> at org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:90)
> at org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:105)
> at org.apache.openejb.core.ivm.naming.IvmContext.bind(IvmContext.java:295)
> at
> org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:673)
> ... 53 more
> 
> -- 
> thanks
> <>< Marius ><>


Mime
View raw message