Announcement Announcement Module
Collapse
No announcement yet.
Property not found trying to access a protected Data Source Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Property not found trying to access a protected Data Source

    I am trying to access a protected data source from spring passing the initial context factory, provider url, principal, credentials.
    I am using WLS 8.1.3 with a role condition saying that only the user "zadevl" (with the
    correct credentials) can have access to all the resources in the container.

    Following is excerpt from the spring config.xml
    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryB ean" singleton="false">
    <property name="resourceRef"><value>true</value></property>
    <property name="java.naming.factory.initial"><value>weblogic .jndi.WLInitialContextFactory</value></property>
    <property name="java.naming.provider.url"><value>t3://dfapt-ap02:7277</value></property>
    <property name="jndiName"><value>jdbc/txamengineInputPool</value></property>
    <property name="java.naming.security.principal"><value>zadev l</value></property>
    <property name="java.naming.security.credentials"><value>pas sword</value></property>
    </bean>

    I am getting the following exception.
    testGetProductCharacteristicsProductType(com.wlspo licy.spring.test.TestCharacteristicsService)org.sp ringframework.beans.factory.BeanDefinitionStoreExc eption: Error registering bean with name 'dataSource' defined in resource loaded through InputStream: Validation of bean definition with name failed; nested exception is org.springframework.beans.factory.support.BeanDefi nitionValidationException: FactoryBean must be defined as singleton - FactoryBeans themselves are not allowed to be prototypes
    org.springframework.beans.factory.support.BeanDefi nitionValidationException: FactoryBean must be defined as singleton - FactoryBeans themselves are not allowed to be prototypes
    at org.springframework.beans.factory.support.RootBean Definition.validate(RootBeanDefinition.java:151)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.registerBeanDefinition(DefaultL istableBeanFactory.java:323)
    at org.springframework.beans.factory.support.BeanDefi nitionReaderUtils.registerBeanDefinition(BeanDefin itionReaderUtils.java:122)
    at org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser.registerBeanDefinitions(Default XmlBeanDefinitionParser.java:187)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.registerBeanDefinitions(XmlBeanDefinit ionReader.java:175)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:133)
    at org.springframework.beans.factory.xml.XmlBeanFacto ry.<init>(XmlBeanFactory.java:88)
    at org.springframework.beans.factory.xml.XmlBeanFacto ry.<init>(XmlBeanFactory.java:59)
    at com.wlspolicy.spring.test.TestCharacteristicsServi ce.setUp(TestCharacteristicsService.java:39)
    at com.wlspolicy.spring.test.TestCharacteristicsServi ce.main(TestCharacteristicsService.java:21)

    To avoid this isngleton error I tried the following configuration
    Following spring config.xml is same as above except for the attribute singleton="true".
    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryB ean" singleton="true">
    <property name="resourceRef"><value>true</value></property>
    <property name="java.naming.factory.initial"><value>weblogic .jndi.WLInitialContextFactory</value></property>
    <property name="java.naming.provider.url"><value>t3://dfapt-ap02:7277</value></property>
    <property name="jndiName"><value>jdbc/txamengineInputPool</value></property>
    <property name="java.naming.security.principal"><value>zadev l</value></property>
    <property name="java.naming.security.credentials"><value>pas sword</value></property>
    </bean>

    Now I am getting the following exception saying that all the java.x.y.z properties are invalid.
    testGetProductCharacteristicsProductType(com.wlspo licy.spring.test.TestCharacteristicsService)org.sp ringframework.beans.factory.BeanCreationException: Error creating bean with name 'charactericsDAO' defined in resource loaded through InputStream: Can't resolve reference to bean 'dataSource' while setting property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'dataSource' defined in resource loaded through InputStream: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'java.naming.factory.initial' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Nested property in path 'java.naming.factory.initial' does not exist; nested exception is org.springframework.beans.NotReadablePropertyExcep tion: Invalid property 'java' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Bean property 'java' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'dataSource' defined in resource loaded through InputStream: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'java.naming.factory.initial' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Nested property in path 'java.naming.factory.initial' does not exist; nested exception is org.springframework.beans.NotReadablePropertyExcep tion: Invalid property 'java' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Bean property 'java' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
    org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'java.naming.factory.initial' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Nested property in path 'java.naming.factory.initial' does not exist; nested exception is org.springframework.beans.NotReadablePropertyExcep tion: Invalid property 'java' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Bean property 'java' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
    org.springframework.beans.NotReadablePropertyExcep tion: Invalid property 'java' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Bean property 'java' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
    at org.springframework.beans.BeanWrapperImpl.getPrope rtyValue(BeanWrapperImpl.java:595)
    at org.springframework.beans.BeanWrapperImpl.getNeste dBeanWrapper(BeanWrapperImpl.java:496)
    at org.springframework.beans.BeanWrapperImpl.getBeanW rapperForPropertyPath(BeanWrapperImpl.java:474)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:677)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:826)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:853)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:842)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:874)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:688)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:325)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:260)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:221)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:145)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.resolveReference(Abstra ctAutowireCapableBeanFactory.java:980)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.resolveValueIfNecessary (AbstractAutowireCapableBeanFactory.java:918)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:859)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:688)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:325)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:260)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:221)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:145)
    at com.wlspolicy.spring.test.LookupFactory.getCharact ericsDao(LookupFactory.java:63)
    at com.wlspolicy.spring.test.TestCharacteristicsServi ce.setUp(TestCharacteristicsService.java:41)
    at com.wlspolicy.spring.test.TestCharacteristicsServi ce.main(TestCharacteristicsService.java:21)

    Is this the right way to access a protected data source or is there any other way.
    Could you please provide me an example how to make this work.

    I really appreciate your help.

    Thanks a lot.
    Raj.

  • #2
    Raj,

    JndiObjectFactoryBean doesn't have all those properties you are trying to set - it only has resourceRef and jndiName. The other properties must be set as a Java Properties instance in the jndiEnvironment property like this:

    <property name="jndiEnvironment">
    <props>
    <prop name="java.naming.factory.initial">weblogic.jndi.W LInitialContextFactory</prop>
    </props>
    </property>

    Rob

    Comment


    • #3
      Property not found trying to access a protected Data Source

      Thanks a lot Rob.

      I would like to point one thing about the syntax though.

      <prop key="java.naming.factory.initial">weblogic.jndi.WL InitialContextFactory</prop>

      Comment

      Working...
      X