Announcement Announcement Module
Collapse
No announcement yet.
jee:jndi-lookup question Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • jee:jndi-lookup question

    I am using the <jee:jndi-lookup> Spring configuration element to access JNDI properties. My intent is to do this to access environment-specific properties (e.g., server names, configuration properties, etc.) instead of hard-coding them or otherwise having to maintain a set of properties files to maintain this information. I am deploying a Spring-WS war file to \jboss-4.2.3-GA\server\default\deploy, but I can not figure out how to specify JNDI properties within JBoss and access them via the <jee:jndi-lookup> bean specified in my Spring application context. For testing purposes, I had the default-value attributes specified on the <jee:jndi-lookup> elements. When I remove the default-value attributes and redeploy, I get a javax.naming.NameNotFoundException. So, the JNDI properties I've tried setting up so far are not visible to my application.

    Can someone please explain to me how to configure JNDI properties in JBoss 4.2.3 when simply deploying a Spring-enabled war with the <jee:jndi-lookup> elements specified? BTW, I am using the Spring 3.x framework. Not sure if that makes a difference or not. Thanks!

  • #2
    Forgot code examples

    When I use the following configuration, my app works fine.
    Code:
    <jee:jndi-lookup id="ldap_context_source_password"
    		jndi-name="ldap_context_source_password"
    		default-value="password" />
    When I remove the default-value attribute...

    Code:
    <jee:jndi-lookup id="ldap_context_source_password"
    		jndi-name="ldap_context_source_password"/>
    ...I get the following stack trace:

    Code:
    Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldap_context_source_password': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: ldap_context_source_password not bound
    	org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:591)
    	org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:193)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:925)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:835)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	java.security.AccessController.doPrivileged(Native Method)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
    	org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
    	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
    	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402)
    	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316)
    	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282)
    	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
    	javax.servlet.GenericServlet.init(GenericServlet.java:212)
    	org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
    	org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
    	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
    	java.lang.Thread.run(Thread.java:595)
    </pre></p><p><b>root cause</b> <pre>org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.company.svc.UserAdminService] is defined: Unsatisfied dependency of type [interface com.company.svc.UserAdminService]: expected at least 1 matching bean
    	org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:613)
    	org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:622)
    	org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:584)
    	org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:193)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:925)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:835)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	java.security.AccessController.doPrivileged(Native Method)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
    	org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
    	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
    	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402)
    	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316)
    	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282)
    	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
    	javax.servlet.GenericServlet.init(GenericServlet.java:212)
    	org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
    	org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
    	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
    	java.lang.Thread.run(Thread.java:595)
    I have already tried making entries in jndi.properties and I have also tried the following:

    Code:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE server PUBLIC "-//JBoss//DTD MBean Service 4.0//EN" "http://www.jboss.org/j2ee/dtd/jboss-service_4_0.dtd">
    <server>
    	<mbean code="org.jboss.naming.JNDIBindingServiceMgr" name="jboss.tests:service=JNDIBindingServiceMgr">
    		<attribute name="BindingsConfig" serialDataType="jbxb">
    			<jndi:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
    				xmlns:jndi="urn:jboss:jndi-binding-service:1.0"
    				xs:schemaLocation="urn:jboss:jndi-binding-service:1.0 resource:jndi-binding-service_1_0.xsd">
    				<jndi:binding name="maps/testProps">
    					<java:properties xmlns:java="urn:jboss:java-properties"
    						xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
    						xs:schemaLocation="urn:jboss:java-properties resource:java-properties_1_0.xsd">
    						<java:property>
    							<java:key>ldap_context_source_password</java:key>
    							<java:value>password</java:value>
    						</java:property>
    					</java:properties>
    				</jndi:binding>
    			</jndi:bindings>
    		</attribute>
    	</mbean>
    </server>
    Is there a simple way of doing this? It shouldn't be difficult to do, but for the life of me, I can't find the documentation that specifies how to get this done. I really appreciate your help!

    Comment

    Working...
    X