help me please!!! Wicket/Spring/Hibernate configuration woes
Hi there, For some time now I have been trying to put together a simple project to get me off the ground with a Wicket/Spring/Hibernate setup. I've had lots of ups and downs, and found this guide really useful: http://wicketinaction.com/2009/06/wicketspringhibernate-configuration/ However, I still seem to be having some problems and I've no idea where to look now. Here's the error I get in my log: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServiceImpl' defined in file [C:\tomcat6\webapps\ZenTemplate-0\WEB-INF\classes\uk\co\company\product\business\spring\UserServiceImpl.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [uk.co.company.product.business.spring.UserServiceImpl]: Constructor threw exception; nested exception is org.apache.wicket.Wicket RuntimeException: There is no application attached to current thread ContainerBackgroundProcessor[StandardEngine[Catalina]] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:883) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:839) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) 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:791) 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.check(HostConfig.java:1345) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590) at java.lang.Thread.run(Thread.java:619) Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [uk.co.company.product.business.spring.UserServiceImpl]: Constructor threw exception; nested exception is org.apache.wicket.WicketRuntimeException: There is no application attached to current thread ContainerBackgroundProcessor[StandardEngine[Catalina]] at
need help with spring annotations
Hi there, I was wondering if anyone could help me with spring annotations, I seem to have having some problems. I'm trying to inject my UserService into a CustomAuthenticatedWebSession I wrote to do validation for my pages. I get a NPE when I hit any page because my bean does not seem to have been injected. Here's my AuthenticatedWebSession Class: public class CustomAuthenticatedWebSession extends AuthenticatedWebSession{ private static final long serialVersionUID = 4713195500103052768L; @SpringBean(name=userService) transient private UserService userService; public void setUserService(final UserService userService){ this.userService = userService; } transient private String currentUser = null; public CustomAuthenticatedWebSession(final Request request){ super(request); } @Override public boolean authenticate(final String username, final String password){ currentUser = username; return userService.authenticate(username, password); } @Override public Roles getRoles(){ return userService.getRoles(currentUser, isSignedIn()); } } my applicationContext.xml file: ?xml version=1.0 encoding=UTF-8? beans xmlns=http://www.springframework.org/schema/beans; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:aop=http://www.springframework.org/schema/aop; xmlns:tx=http://www.springframework.org/schema/tx; xmlns:context=http://www.springframework.org/schema/context; xsi:schemaLocation= http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd bean id=wicketApplication class=uk.co.company.product.presentation.wicket.app.WicketApplication / bean id=placeholderConfigurer class=org.springframework.beans.factory.config.PropertyPlaceholderConfigurer property name=ignoreUnresolvablePlaceholders value=false / property name=systemPropertiesModeName value=SYSTEM_PROPERTIES_MODE_OVERRIDE / property name=ignoreResourceNotFound value=false / property name=locations list valueclasspath*:/application.properties/value /list /property /bean bean id=dataSource class=org.springframework.jdbc.datasource.DriverManagerDataSource property name=driverClassNamevalue${jdbc.driver}/value/property property name=urlvalue${jdbc.url}/value/property property name=usernamevalue${jdbc.username}/value/property property name=passwordvalue${jdbc.password}/value/property /bean tx:annotation-driven transaction-manager=txManager / bean id=txManager class=org.springframework.orm.hibernate3.HibernateTransactionManager property name=sessionFactory ref bean=sessionFactory / /property /bean !-- bean id=interceptor class=org.springframework.orm.hibernate3.HibernateInterceptor /bean -- bean id=sessionFactory class=org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean property name=dataSource ref=dataSource / property name=hibernateProperties props !-- prop key=hibernate.hbm2ddl.autocreate/prop -- prop key=hibernate.dialect${hibernate.dialect}/prop prop key=hibernate.connection.pool_size5/prop prop key=hibernate.current_session_context_classthread/prop prop key=hibernate.show_sqltrue/prop prop key=hibernate.cglib.use_reflection_optimizertrue/prop prop key=hibernate.cache.provider_classorg.hibernate.cache.EhCacheProvider/prop prop key=hibernate.hibernate.cache.use_query_cachetrue/prop /props /property !-- property name=entityInterceptorref bean=interceptor //property -- property name=packagesToScanlist valueuk.co.company.product.persistance.hibernate/value /list/property /bean context:component-scan base-package=uk.co.company.product / /beans and web.xml ?xml version=1.0 encoding=UTF-8? web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation= http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd version=2.4 display-nameZenTemplate/display-name context-param param-namecontextConfigLocation/param-name param-valueclasspath:applicationContext.xml/param-value /context-param listener