Hi,

 

I want to get the attributes of a user that exists in the Oracle database.
User authentication is correct, so the connection to the DB is correct. When
I get other user data I get the following error:

 

 

2010-08-31 09:48:49,136 ERROR
[org.jasig.cas.web.init.SafeContextLoaderListener] -
SafeContextLoaderListener: 

The Spring ContextLoaderListener we wrap threw on contextInitialized.

But for our having caught this error, the web application context would not
have initialized.

org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'centralAuthenticationService' defined in ServletContext resource
[/WEB-INF/spring-configuration/applicationContext.xml]: Cannot resolve
reference to bean 'authenticationManager' while setting bean property
'authenticationManager'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'authenticationManager' defined in ServletContext resource
[/WEB-INF/deployerConfigContext.xml]: Cannot create inner bean
'org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincip
alResolver#9a18a0' of type
[org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincip
alResolver] while setting bean property 'credentialsToPrincipalResolvers'
with key [0]; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name
'org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincip
alResolver#9a18a0' defined in ServletContext resource
[/WEB-INF/deployerConfigContext.xml]: Cannot resolve reference to bean
'attributeRepository' while setting bean property 'attributeRepository';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'attributeRepository' defined in
ServletContext resource [/WEB-INF/deployerConfigContext.xml]: 3 constructor
arguments specified but no matching constructor found in bean
'attributeRepository' (hint: specify index/type/name arguments for simple
parameters to avoid type ambiguities)

                at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolv
eReference(BeanDefinitionValueResolver.java:328)

                at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolv
eValueIfNecessary(BeanDefinitionValueResolver.java:106)

                at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1308)

                at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.populateBean(AbstractAutowireCapableBeanFactory.java:1067)

                at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)

                at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.createBean(AbstractAutowireCapableBeanFactory.java:450)

                at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(Ab
stractBeanFactory.java:290)

                at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSi
ngleton(DefaultSingletonBeanRegistry.java:222)

                at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(Abst
ractBeanFactory.java:287)

                at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abstra
ctBeanFactory.java:189)

                at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInst
antiateSingletons(DefaultListableBeanFactory.java:562)

                at
org.springframework.context.support.AbstractApplicationContext.finishBeanFac
toryInitialization(AbstractApplicationContext.java:871)

                at
org.springframework.context.support.AbstractApplicationContext.refresh(Abstr
actApplicationContext.java:423)

                at
org.springframework.web.context.ContextLoader.createWebApplicationContext(Co
ntextLoader.java:272)

                at
org.springframework.web.context.ContextLoader.initWebApplicationContext(Cont
extLoader.java:196)

                at
org.springframework.web.context.ContextLoaderListener.contextInitialized(Con
textLoaderListener.java:47)

                at
org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized_aroundBo
dy0(SafeContextLoaderListener.java:62)

                at
org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized_aroundBo
dy1$advice(SafeContextLoaderListener.java:44)

                at
org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized(SafeCont
extLoaderListener.java:1)

                at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:
4135)

                at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)

                at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:7
91)

                at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)

                at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)

                at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905)

                at
org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740)

                at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)

                at
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)

                at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)

                at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSuppor
t.java:119)

                at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)

                at
org.apache.catalina.core.StandardHost.start(StandardHost.java:785)

                at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)

                at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)

                at
org.apache.catalina.core.StandardService.start(StandardService.java:519)

                at
org.apache.catalina.core.StandardServer.start(StandardServer.java:710)

                at
org.apache.catalina.startup.Catalina.start(Catalina.java:581)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)

                at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)

                at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)

                at java.lang.reflect.Method.invoke(Method.java:597)

                at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)

                at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'authenticationManager' defined in ServletContext
resource [/WEB-INF/deployerConfigContext.xml]: Cannot create inner bean
'org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincip
alResolver#9a18a0' of type
[org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincip
alResolver] while setting bean property 'credentialsToPrincipalResolvers'
with key [0]; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name
'org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincip
alResolver#9a18a0' defined in ServletContext resource
[/WEB-INF/deployerConfigContext.xml]: Cannot resolve reference to bean
'attributeRepository' while setting bean property 'attributeRepository';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'attributeRepository' defined in
ServletContext resource [/WEB-INF/deployerConfigContext.xml]: 3 constructor
arguments specified but no matching constructor found in bean
'attributeRepository' (hint: specify index/type/name arguments for simple
parameters to avoid type ambiguities)

                at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolv
eInnerBean(BeanDefinitionValueResolver.java:281)

                at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolv
eValueIfNecessary(BeanDefinitionValueResolver.java:120)

                at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolv
eManagedList(BeanDefinitionValueResolver.java:355)

                at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolv
eValueIfNecessary(BeanDefinitionValueResolver.java:153)

                at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1308)

                at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.populateBean(AbstractAutowireCapableBeanFactory.java:1067)

                at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)

                at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.createBean(AbstractAutowireCapableBeanFactory.java:450)

                at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(Ab
stractBeanFactory.java:290)

                at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSi
ngleton(DefaultSingletonBeanRegistry.java:222)

                at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(Abst
ractBeanFactory.java:287)

                at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abstra
ctBeanFactory.java:189)

                at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolv
eReference(BeanDefinitionValueResolver.java:322)

                ... 42 more

 

The code used in the deployerConfigContext.xml is:

 

<bean id="attributeRepository"
class="org.jasig.services.persondir.support.jdbc.SingleRowJdbcPersonAttribut
eDao">
 <constructor-arg index="0" ref="dataSource"/>
 <constructor-arg index="1">
  <list>
   <value>user</value>
  </list>
 </constructor-arg>
 <constructor-arg index="2" value="SELECT surname FROM users WHERE
lower(user) = lower(?)"/>

 

 <property name="columnsToAttributes">
  <map>
   <entry key="surname" value=" surname" />
  </map>
 </property>
</bean>

 

 

In the bean UsernamePasswordCredentiaslToPrincipalResolver I write the
following:

 

<property name="attributeRepository">

                <ref bean=" attributeRepository"/>

</property>

 

 

On the other hand, I also tried the following code, and I get no error, but
I do not get the attributes from the client.

 

 

<bean id=" attributeRepository "

 
class="org.jasig.services.persondir.support.jdbc.SingleRowJdbcPersonAttribut
eDao">

                 <constructor-arg index="0" ref="dataSource" />

                <constructor-arg index="1" value=" SELECT surname FROM users
WHERE lower(user) = lower(?)"/>/>

                 <property name="queryAttributeMapping">

                 <map>

                     <entry key="user" value="user" />

                 </map>

                 </property>

                 <property name="resultAttributeMapping">

                 <map>

                     <entry key="surname" value=" surname " />

                 </map>

                 </property>

                     </bean>

 

The code in the jsp file from the client is:

 

 

 <dt>Your attributes:</dt>
<%
  AttributePrincipal principal = (AttributePrincipal)
request.getUserPrincipal();
  Map attributes = principal.getAttributes();

 

  if (attributes.size() > 0) {

 

   out.println("You have " + attributes.size() + " attributes : <br />");
   Iterator keyIterator = attributes.keySet().iterator();

 

   while (keyIterator.hasNext()) {

 

    Object key = keyIterator.next();
    Object value = attributes.get(key);
    out.println("<b>" + key + "</b>" + " : " + value);
          }
  } else {
   out.println("You have no attributes set");
  }
%>
</dl>

 

 

How do I resolve this?

 

Thanks.

 


-- 
You are currently subscribed to [email protected] as: 
[email protected]
To unsubscribe, change settings or access archives, see 
http://www.ja-sig.org/wiki/display/JSG/cas-user

Reply via email to