[cas-user] Resolving attirbutes dao results in "no value specified for parameter 2"

48 views
Skip to first unread message

Manfredo Hopp

unread,
Aug 19, 2015, 2:26:07 PM8/19/15
to cas-...@lists.jasig.org
Hello I am using singleRowJdbcPersonAttributeDao to resolve principal attributes defined as:

singleRowJdbcPersonAttributeDao
class="org.jasig.services.persondir.support.jdbc.SingleRowJdbcPersonAttributeDao">
<constructor-arg index="0" ref="dataSourceA" />
<constructor-arg index="1"
value="(SELECT a, b,  c , d
FROM u WHERE {0} 
  UNION
  (SELECT a, b ,c d 
  FROM r WHERE {0})" />
<property name="queryAttributeMapping">
<map>
<entry key="username" value="id" />
</map>
</property>

And get SQLException->No value specified for parameter 2 

NO replacement for second {0}, so I am not able to use this query.

Is there any reason for the behaviour of this implementation?

Regards Manfredo
-- 
You are currently subscribed to cas-...@lists.jasig.org as: jasig-cas-user...@googlegroups.com
To unsubscribe, change settings or access archives, see http://www.ja-sig.org/wiki/display/JSG/cas-user

Misagh Moayyed

unread,
Aug 19, 2015, 4:45:37 PM8/19/15
to cas-...@lists.jasig.org

This “may” be an issue with person directory. Don’t know yet, but your other option for now would be to have 2 DAOs and merge the result together finally.

 

What version of person directory is this by the way? Can you dulicate the problem with the latest?

 

From: Manfredo Hopp [mailto:mhopp....@gmail.com]
Sent: Wednesday, August 19, 2015 11:26 AM
To: cas-...@lists.jasig.org
Subject: [cas-user] Resolving attirbutes dao results in "no value specified for parameter 2"

 

Hello I am using singleRowJdbcPersonAttributeDao to resolve principal attributes defined as:

 

singleRowJdbcPersonAttributeDao

                    class="org.jasig.services.persondir.support.jdbc.SingleRowJdbcPersonAttributeDao">

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

                      <constructor-arg index="1"

                      value="(SELECT a, b,  c , d

                                              FROM u WHERE {0} 

                                  UNION

                                              (SELECT a, b ,c d 

                                              FROM r WHERE {0})" />

                      <property name="queryAttributeMapping">

                                  <map>

                                              <entry key="username" value="id" />

                                  </map>

                      </property>

 

And get SQLException->No value specified for parameter 2 

 

NO replacement for second {0}, so I am not able to use this query.

 

Is there any reason for the behaviour of this implementation?

 

Regards Manfredo

 
-- 
You are currently subscribed to cas-...@lists.jasig.org as: mmoa...@unicon.net
To unsubscribe, change settings or access archives, see http://www.ja-sig.org/wiki/display/JSG/cas-user

Manfredo Hopp

unread,
Aug 19, 2015, 6:07:55 PM8/19/15
to cas-...@lists.jasig.org
Its 1.5.1 ( CAS 4.0.1)

from log output:

2015-08-19 15:12:02,288 DEBUG [org.jasig.services.persondir.support.jdbc.SingleRowJdbcPersonAttributeDao] - <Adding attribute 'id' with value '[myname]' to query builder 'null'>
2015-08-19 15:12:02,289 DEBUG [org.jasig.services.persondir.support.jdbc.SingleRowJdbcPersonAttributeDao] - <Generated query builder 'sql=[id = ?] args=[myname]' from query Map {username=[myname]}.>

In last line of following source you can see that executing query passes querybuilder.arguments which has only one value, whereas replacement happens twice.


  • AbstractJdbcPersonAttributeDao
  protected List<IPersonAttributesgetPeopleForQuery(PartialWhereClause queryBuilderString queryUserName) {
        //Execute the query
        final ParameterizedRowMapper<R> rowMapper = this.getRowMapper();
        
        final List<R> results;
        if (queryBuilder != null) {
            //Merge the generated SQL with the base query template
            final StringBuilder partialSqlWhere = queryBuilder.sql;
167
            final Matcher queryMatcher = WHERE_PLACEHOLDER.matcher(this.queryTemplate);
168
            final String querySQL = queryMatcher.replaceAll(partialSqlWhere.toString());

            

            results = this.simpleJdbcTemplate.query(querySQLrowMapperqueryBuilder.arguments.toArray())




Regards Manfredo




-- 
You are currently subscribed to cas-...@lists.jasig.org as: mhopp....@gmail.com
To unsubscribe, change settings or access archives, see http://www.ja-sig.org/wiki/display/JSG/cas-user

Manfredo Hopp

unread,
Aug 19, 2015, 6:26:37 PM8/19/15
to cas-...@lists.jasig.org
See my previous mail which describes details of this issue.

Same result for  version 1.7.0 (latest?)

Regards Manfredo

2015-08-19 17:45 GMT-03:00 Misagh Moayyed <mmoa...@unicon.net>:
-- 
You are currently subscribed to cas-...@lists.jasig.org as: mhopp....@gmail.com
To unsubscribe, change settings or access archives, see http://www.ja-sig.org/wiki/display/JSG/cas-user

Misagh M

unread,
Aug 24, 2015, 2:57:25 AM8/24/15
to jasig-cas-user, cas-...@lists.jasig.org
Try using NamedParameterJdbcPersonAttributeDao  instead.

Manfredo Hopp

unread,
Aug 26, 2015, 3:20:22 PM8/26/15
to cas-...@lists.jasig.org
Hi test with  NamedParameterJdbcPersonAttributeDao results in :


2015-08-26 16:07:34,851 ERROR [org.springframework.web.context.ContextLoader] - <Context initialization failed>
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 constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationManager' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Cannot resolve reference to bean 'primaryPrincipalResolver' while setting constructor argument with key [<primaryAuthenticationHandler>]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'primaryPrincipalResolver' 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]: Cannot resolve reference to bean 'singleRowJdbcPersonAttributeDao' while setting bean property 'personAttributeDaos' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'singleRowJdbcPersonAttributeDao' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:326)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:623)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1075)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:979)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)


ConfigContext:

<bean id="singleRowJdbcPersonAttributeDao"
class="org.jasig.services.persondir.support.jdbc.NamedParameterJdbcPersonAttributeDao">
<constructor-arg index="0" ref="dataSourceSarauth" />
<constructor-arg index="1"
value="(SELECT id , a , b , c,  email  FROM usr WHERE {0}
 UNION
 (SELECT d , a , b , c,  email FROM regpend WHERE {0} )" />
<property name="queryAttributeMapping">
<map>
<entry key="username" value="id" />
</map>
</property>
<property name="resultAttributeMapping">
<map>
<entry key="id" value="id" />
....


Regards Manfredo

Misagh Moayyed

unread,
Aug 26, 2015, 3:25:45 PM8/26/15
to cas-...@lists.jasig.org

Manfredo Hopp

unread,
Aug 26, 2015, 4:11:50 PM8/26/15
to cas-...@lists.jasig.org
Ups sorry I didnt read! 

When using src's example:


p>Example Sprring Configuration:</p>
*
* &lt;bean id="rolesUserSource" class="org.jasig.services.persondir.support.jdbc.NamedParameterJdbcPersonAttributeDao"&gt;
* &lt;property name="dataSource" ref="PersonDB" /&gt;
* &lt;property name="sql"&gt;
* &lt;value&gt;
* SELECT rolename AS scsRoleName
* from s_external_role
* where oprid = UPPER(:username)
* &lt;/value&gt;
* &lt;/property&gt;
* &lt;property name="usernameAttributeProvider" ref="usernameAttributeProvider" /&gt;
* &lt;property name="userAttributeNames"&gt;
* &lt;set&gt;
* &lt;value&gt;scsRoleName&lt;/value&gt;
* &lt;/set&gt;
* &lt;/property&gt;
* &lt;/bean&gt;
I get following error;


rg.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 215 in XML document from ServletContext resource [/WEB-INF/deployerConfigContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 215; columnNumber: 7; cvc-complex-type.2.4.a: Invalid content was found starting with element 'set'. One of '{"http://www.springframework.org/schema/beans":meta, "http://www.springframework.org/schema/beans":constructor-arg, "http://www.springframework.org/schema/beans":property, "http://www.springframework.org/schema/beans":qualifier, "http://www.springframework.org/schema/beans":lookup-method, "http://www.springframework.org/schema/beans":replaced-method, WC[##other:"http://www.springframework.org/schema/beans"]}' is expected.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)

So apparently the example isnt  accurate.

With more time I'll try to figure out what is needed.

Thank you!


Reply all
Reply to author
Forward
0 new messages