Results 1 to 3 of 3

Thread: JndiTemplate.bind() Exception in Weblogic

  1. #1

    Default JndiTemplate.bind() Exception in Weblogic

    I have the following code to export some of my services into JNDI:

    Code:
    public class RTMJndiBinder {
    	private final JndiTemplate jndiTemplate = new JndiTemplate();
    
    	private Map<String, Object> jndiObjects;
    	public void setJndiObjects(Map<String, Object> jndiObjects) {
    		this.jndiObjects = jndiObjects;
    	}
    
    	@PostConstruct
    	public void init() throws Exception {
    		for (Map.Entry<String, Object> toBind : jndiObjects.entrySet()) {
    			jndiTemplate.bind(toBind.getKey(), toBind.getValue());
    		}
    	}
    
    	@PreDestroy
    	public void destroy() throws Exception {
    		for (String jndiName : jndiObjects.keySet()) {
    			if (jndiName != null && jndiTemplate.lookup(jndiName) != null) {
    				jndiTemplate.unbind(jndiName);
    			}
    		}
    	}
    }
    When I deploy this as a WAR within Weblogic, I get the following exception:

    Code:
    <Nov 12, 2009 4:34:36 PM EST> <Warning> <HTTP> <BEA-101162> <User defined listen
    er org.springframework.web.context.ContextLoaderListener failed: org.springframe
    work.beans.factory.BeanCreationException: Error creating bean with name 'control
    SystemBinder': Invocation of init method failed; nested exception is javax.namin
    g.NameNotFoundException: While trying to lookup 'rtm.cacheManager' didn't find s
    ubcontext 'rtm'. Resolved ''; remaining name 'rtm/cacheManager'.
    org.springframework.beans.factory.BeanCreationException: Error creating bean wit
    h name 'controlSystemBinder': Invocation of init method failed; nested exception
     is javax.naming.NameNotFoundException: While trying to lookup 'rtm.cacheManager
    ' didn't find subcontext 'rtm'. Resolved ''; remaining name 'rtm/cacheManager'
            at org.springframework.beans.factory.annotation.InitDestroyAnnotationBea
    nPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProc
    essor.java:147)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanF
    actory.java:350)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1331)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory$1.run(AbstractAutowireCapableBeanFactory.java:409)
            Truncated. see log file for complete stacktrace
    javax.naming.NameNotFoundException: While trying to lookup 'rtm.cacheManager' di
    dn't find subcontext 'rtm'. Resolved ''; remaining name 'rtm/cacheManager'
            at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(Basic
    NamingNode.java:1139)
            at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.jav
    a:247)
            at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.j
    ava:182)
            at weblogic.jndi.internal.BasicNamingNode.lookupHereOrCreate(BasicNaming
    Node.java:270)
            at weblogic.jndi.internal.BasicNamingNode.bind(BasicNamingNode.java:41
    2)
            Truncated. see log file for complete stacktrace
    >
    Any thoughts?

  2. #2

    Default

    I was able to get it to bind to flat names like:

    cacheManager

    But compound names like:

    rtm/cacheManager

    fail.

  3. #3

    Default

    I answered my own question, you have to explicitly create the subcontext. This can be done by doing the following:

    Code:
    // Create the subcontext
    			jndiTemplate.execute(new JndiCallback() {
    				public Object doInContext(Context ctx) throws NamingException {
    					ctx.createSubcontext("rtm");
    					return null;
    				}
    			});

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •