Hi Mike,
thank you for your response.
on 12/2/2005 7:30 AM Mike Kienenberger stated:
> Can you post the setter method for ds in CasesJdbcDAO?
Here are the crucial parts of CasesJdbcDAO:
/* the field definition [1]*/
private JDBCDataSource ds;
/* the setter*/
public void setDs(JDBCDataSource dataSource) {
this.ds = dataSource;
this.setDataSource(this.ds.getDs());
}
> Also can you post the class definition line for JDBCDataSource?
The JDBCDataSource class is very simple and just holds an
javax.sql.DataSource object. Here are the interesting parts:
/*the class definition */
public class JDBCDataSource{
/*the javax.sql.DataSource*/
private DataSource ds;
private String jndiLookup;
...
public DataSource getDs() {
doLookup();
return ds;
}
}
The issue again: If I change the name of the field in CasesJdbcDAO at
position [1] to dataSource, and adjust the injection in faces-config.xml
accordingly the application crashes with the stated exception.
Any ideas?
Kurt
The question is can JDBCDataSource be coerced to the type of getDs()?
On 12/2/05, Kurt Edegger <[EMAIL PROTECTED]> wrote:
Hi,
I do have a question relating to properties of managed beans defined in
faces-config.xml. I do face the following situation of two beans:
<managed-bean>
<managed-bean-name>jdbcDataSourceBean</managed-bean-name>
<managed-bean-class>JDBCDataSource</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>casesDAOBean</managed-bean-name>
<managed-bean-class>CasesJdbcDAO</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<!-- [1] -->
<property-name>ds</property-name>
<value>#{jdbcDataSourceBean}</value>
</managed-property>
</managed-bean>
The first bean is injected into the second one and everything works
fine, but as I wrote the code I decided to name the managed-property of
the second bean 'dataSource' since it's more descriptive.
I renamed the field in the class and the setter as well.
But when the casesDAOBean is contructed at runtime, the application
crashes with an exception 'javax.servlet.jsp.el.ELException: Attempt to
coerce a value of type "JDBCDataSource" to type "javax.sql.DataSource"'.
Somehow the property name is recognized as type, even I had to declared
it in CasesJdbcDAO anyway (JDBCDataSource dataSource; ).
Why am I not allowed to call the field like a class in the package
javax.sql?
I had a hard time to find this one, since I wouldn't think of simply
renaming the field solved the issue.
Any clues why this happens?
Thanks,
Kurt
P.S.: Yep, sorry, not really myfaces related ;)