You have to use interface and cast to the interface unless Spring is forced to use cglib for proxy creation.
If your UserDao is interface then just cast to it, not to the JdbcUserDao and it should be fine. ----- Original Message ---- From: Sergey Podatelev <[EMAIL PROTECTED]> To: [email protected] Sent: Sunday, January 13, 2008 1:34:08 PM Subject: Cannot create Spring Bean via Proxy in Wicket Hello, My WebApplication extends SpringWebApplication and I use proxy-based approach for bean instantiation. I'm using JDK1.4, so I'm unable to just annotate the beans, but have to do it in the following way: MyWebApplication { private UserDao userDao; ... public UserDao getUserDao() { if (userDao == null) { userDao = (JdbcUserDao) createSpringBeanProxy( JdbcUserDao.class, "userDao"); } return userDao; } } However, I get the following exception: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'userDao' must be of type [com.myapp.user.JdbcUserDao], but was actually of type [$Proxy9] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:309) ... My configurations are pretty much taken from wicket-phonebook example, the only major difference is that phonebook uses Wicket 1.2 with Wicket is configured as servlet, while I use it as filter to enable Acegi support. If you're still with me, here're related entries from web.xml...: <filter> <filter-name>Spring Application Factory Filter</filter-name> <filter-class>org.apache.wicket.protocol.http.WicketFilter </filter-class> <init-param> <param-name>applicationFactoryClassName</param-name> <param-value> org.apache.wicket.spring.SpringWebApplicationFactory</param-value> </init-param> </filter> <filter-mapping> <filter-name>Spring Application Factory Filter</filter-name> <url-pattern>/myapp/*</url-pattern> </filter-mapping> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener</listener-class> </listener> ...and from applicationContext.xml: <bean id="userDaoTarget" class="com.myapp.user.JdbcUserDao"> <property name="dataSource" ref="dataSource"/> </bean> <bean id="transactionManager" class=" org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <!-- this is a transactional proxy for userdetails dao which ensures proper transaction handling --> <bean id="userDao" class=" org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager" ref="transactionManager" /> <property name="target" ref="userDaoTarget"/> <property name="transactionAttributes"> <props> <prop key="save">PROPAGATION_REQUIRED</prop> <prop key="*">PROPAGATION_REQUIRED,readOnly</prop> </props> </property> </bean> I'd be happy if someone could point me on where to look at since I'm a little afraid to dig into the whole Spring's proxy instantiation thing. I use Wicket 1.3, Wicket-Spring 1.3 and Spring 2.5. -- sp --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
