avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McKibben <m...@hihat.net>
Subject Re: Issues with Memory Context.
Date Mon, 01 Oct 2001 20:22:41 GMT
The reason you are seeing this error is because "java:comp" is being
interpreted as a URL. By default, the JNDI context looks for a URL context
implementation for the "java" scheme by consulting the
Context.URL_PKG_PREFIXES environment property. This property is a colon
separated list of package prefixes. So for example if I had the prefix
"org.apache.avalon.jndi.url" it would look for the class
org.apache.avalon.jndi.url.javaURLContextFactory to create a context for
the java scheme.

So, if no URL_PKG_PREFIXES are defined or no object factories match the
requested URL scheme, then as a last result the underlying initial context
implementation is consulted.

There is a nice tutorial on sun's site describing how to support urls in a
jndi provider implementation at
http://java.sun.com/products/jndi/tutorial/provider/index.html 

Regards,

--mike

On Mon, 1 Oct 2001, Berin Loritsch wrote:

> I am trying to use the Memory context to bind an object during init time
> so that we can retrieve it later.  I am having issues in that it is claming
> that the name I just bound is not bound.  What is happening is that it is
> not looking in the subcontexts:
> 
> ------------------------ Code Snippet ------------------------------------
> 
>     private static AxisClient getEngine() {
>         String provider = System.getProperty("java.naming.factory.initial", null);
>         Context initCtx = null;
> 
>         if (null == provider) {
>             System.setProperty("java.naming.factory.initial",
>                                "org.apache.avalon.excalibur.naming.memory.MemoryInitialContextFactory");
> 
>             try {
>                 initCtx = new InitialContext();
>                 initCtx.createSubcontext("java:comp").createSubcontext("env").createSubcontext("axis");
>             } catch (Exception e) {
>                 e.printStackTrace(System.err);
>                 throw new RuntimeException("Could not get client instance: " + e.getMessage());
>             }
>         }
> 
>         AxisClient client = null;
>         try {
>             if (initCtx == null) {
>                 initCtx = new InitialContext();
>             }
>             client = (AxisClient) initCtx.lookup("java:comp/env/axis/Client");
>         } catch (Exception e) {
>             // it wasn't there, so we bind the factory
>             try {
>                 if (initCtx == null) {
>                     initCtx = new InitialContext();
>                 }
>                 Context context = (Context) new InitialContext().lookup("java:comp/env");
> 
>                 try {
>                     context = (Context) context.lookup("axis");
>                 } catch (Exception ne) {
>                     context = context.createSubcontext("axis");
>                 }
> 
>                 context.bind("java:comp/env/axis/Client", new AxisEngineFactory());
>                 client = (AxisClient) initCtx.lookup("java:comp/env/axis/Client");
>             } catch (Exception ne) {
>                 ne.printStackTrace(System.err);
>                 throw new RuntimeException("Could not get client instance: " + e.getMessage());
>             }
>         }
> 
>         if (null == client) {
>             throw new RuntimeException("Could not get client instance");
>         }
> 
>         return client;
>     }
> 
> --------------------------------- End Snippet ---------------------------------
> 
> The stack trace I get is:
> 
> javax.naming.NameNotFoundException: java:comp
>     at org.apache.avalon.excalibur.naming.memory.MemoryContext.doLocalLookup(MemoryContext.java:89)
>     at org.apache.avalon.excalibur.naming.AbstractLocalContext.localLookup(AbstractLocalContext.java:309)
>     at org.apache.avalon.excalibur.naming.AbstractLocalContext.lookupSubContext(AbstractLocalContext.java:348)
>     at org.apache.avalon.excalibur.naming.AbstractLocalContext.lookup(AbstractLocalContext.java:294)
>     at org.apache.avalon.excalibur.naming.AbstractContext.lookup(AbstractContext.java:246)
>     at javax.naming.InitialContext.lookup(InitialContext.java:350)
>     at org.apache.axis.client.ServiceClient.getEngine(ServiceClient.java:160)
>     at org.apache.axis.client.ServiceClient.<init>(ServiceClient.java:302)
>     at test.encoding.TestArrayListConversions.init(TestArrayListConversions.java:55)
>     at test.encoding.TestArrayListConversions.<init>(TestArrayListConversions.java:26)
>     at java.lang.reflect.Constructor.newInstance(Native Method)
>     at junit.framework.TestSuite.addTestMethod(TestSuite.java:102)
>     at junit.framework.TestSuite.<init>(TestSuite.java:66)
>     at junit.framework.TestSuite.addTestSuite(TestSuite.java:90)
>     at test.encoding.PackageTests.suite(PackageTests.java:31)
>     at java.lang.reflect.Method.invoke(Native Method)
>     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>(JUnitTestRunner.java:191)
>     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>(JUnitTestRunner.java:156)
>     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:407)
> javax.naming.NameNotFoundException: java:comp
>     at org.apache.avalon.excalibur.naming.memory.MemoryContext.doLocalLookup(MemoryContext.java:89)
>     at org.apache.avalon.excalibur.naming.AbstractLocalContext.localLookup(AbstractLocalContext.java:309)
>     at org.apache.avalon.excalibur.naming.AbstractLocalContext.lookupSubContext(AbstractLocalContext.java:348)
>     at org.apache.avalon.excalibur.naming.AbstractLocalContext.lookup(AbstractLocalContext.java:294)
>     at org.apache.avalon.excalibur.naming.AbstractContext.lookup(AbstractContext.java:246)
>     at javax.naming.InitialContext.lookup(InitialContext.java:350)
>     at org.apache.axis.client.ServiceClient.getEngine(ServiceClient.java:160)
>     at org.apache.axis.client.ServiceClient.<init>(ServiceClient.java:302)
>     at test.encoding.TestArrayListConversions.init(TestArrayListConversions.java:55)
>     at test.encoding.TestArrayListConversions.<init>(TestArrayListConversions.java:26)
>     at java.lang.reflect.Constructor.newInstance(Native Method)
>     at junit.framework.TestSuite.addTestMethod(TestSuite.java:102)
>     at junit.framework.TestSuite.<init>(TestSuite.java:66)
>     at junit.framework.TestSuite.addTestSuite(TestSuite.java:90)
>     at test.encoding.PackageTests.suite(PackageTests.java:31)
>     at java.lang.reflect.Method.invoke(Native Method)
>     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>(JUnitTestRunner.java:191)
>     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>(JUnitTestRunner.java:156)
>     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:407)
> javax.naming.NameNotFoundException: java:comp
>     at org.apache.avalon.excalibur.naming.memory.MemoryContext.doLocalLookup(MemoryContext.java:89)
>     at org.apache.avalon.excalibur.naming.AbstractLocalContext.localLookup(AbstractLocalContext.java:309)
>     at org.apache.avalon.excalibur.naming.AbstractLocalContext.lookupSubContext(AbstractLocalContext.java:348)
>     at org.apache.avalon.excalibur.naming.AbstractLocalContext.lookup(AbstractLocalContext.java:294)
>     at org.apache.avalon.excalibur.naming.AbstractContext.lookup(AbstractContext.java:246)
>     at javax.naming.InitialContext.lookup(InitialContext.java:350)
>     at org.apache.axis.client.ServiceClient.getEngine(ServiceClient.java:160)
>     at org.apache.axis.client.ServiceClient.<init>(ServiceClient.java:302)
>     at test.encoding.TestArrayListConversions.init(TestArrayListConversions.java:55)
>     at test.encoding.TestArrayListConversions.<init>(TestArrayListConversions.java:26)
>     at java.lang.reflect.Constructor.newInstance(Native Method)
>     at junit.framework.TestSuite.addTestMethod(TestSuite.java:102)
>     at junit.framework.TestSuite.<init>(TestSuite.java:66)
>     at junit.framework.TestSuite.addTestSuite(TestSuite.java:90)
>     at test.encoding.PackageTests.suite(PackageTests.java:31)
>     at java.lang.reflect.Method.invoke(Native Method)
>     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>(JUnitTestRunner.java:191)
>     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>(JUnitTestRunner.java:156)
>     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:407)
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Mime
View raw message