Like this?: <?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-name>ZenTemplate</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <filter> <filter-name>opensessioninview</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> </filter> <filter> <filter-name>wicket-spring-hibernate</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> <init-param> <param-name>applicationClassName</param-name> <param-value>uk.co.company.product.presentation.wicket.app.WicketApplication</param-value> </init-param> </filter> <filter-mapping> <filter-name>opensessioninview</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>wicket-spring-hibernate</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> On 15 December 2010 16:15, jcgarciam [via Apache Wicket] < ml-node+3089321-765746748-201...@n4.nabble.com<ml-node%2b3089321-765746748-201...@n4.nabble.com> > wrote: > In your web.xml > > the OSV Filter must comes in front (first) of the wicket filter > > On Wed, Dec 15, 2010 at 12:58 PM, adam.gibbons [via Apache Wicket] <[hidden > email] <http://user/SendEmail.jtp?type=node&node=3089321&i=0>> wrote: > >> Ok, I think this is now back to a Wicket question. Start up is ok now. >> However when I try and invoke UserServiceImpl.authenticate(){ >> >> final Temp1 temp1 = new Temp1(); >> temp1.setValue(userName); >> temp1DAO.save(temp1); >> return testUserService.authenticate(userName, password); >> } >> >> I get the following error through the GUI: >> >> Method onFormSubmitted of interface >> org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component >> [MarkupContainer [Component id = signInForm]] threw an exception >> >> Root cause: >> >> org.hibernate.HibernateException: persist is not valid without active >> transaction >> at >> org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:297) >> at $Proxy18.persist(Unknown Source) >> at >> uk.co.company.product.persistance.hibernate.AbstractTemp1DAO.save(AbstractTemp1DAO.java:21) >> at >> uk.co.company.product.persistance.hibernate.Temp1DAOImpl.save(Temp1DAOImpl.java:1) >> at java.lang.reflect.Method.invoke(Method.java:597) >> at >> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) >> at >> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) >> at >> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) >> at >> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) >> at >> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) >> at >> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) >> at $Proxy9.save(Unknown Source) >> at >> uk.co.company.product.business.spring.UserServiceImpl.authenticate(UserServiceImpl.java:42) >> at java.lang.reflect.Method.invoke(Method.java:597) >> at >> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) >> at >> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) >> at >> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) >> at >> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) >> at >> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) >> at >> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) >> at $Proxy10.authenticate(Unknown Source) >> at java.lang.reflect.Method.invoke(Method.java:597) >> at >> org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitProxyFactory.java:416) >> at org.apache.wicket.proxy.$Proxy15.authenticate(Unknown Source) >> at >> uk.co.company.product.presentation.wicket.app.CustomAuthenticatedWebSession.authenticate(CustomAuthenticatedWebSession.java:29) >> >> I was under the impression that the OpenSessionInViewFilter was supposed >> to do this for us? >> >> >> Once again here is the source code: >> >> >> >> 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-name>ZenTemplate</display-name> >> <context-param> >> <param-name>contextConfigLocation</param-name> >> <param-value>classpath:applicationContext.xml</param-value> >> </context-param> >> <listener> >> >> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> >> </listener> >> <filter> >> <filter-name>opensessioninview</filter-name> >> >> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> >> </filter> >> <filter> >> <filter-name>wicket-spring-hibernate</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> >> <init-param> >> <param-name>applicationClassName</param-name> >> >> <param-value>uk.co.company.product.presentation.wicket.app.WicketApplication</param-value> >> </init-param> >> </filter> >> <filter-mapping> >> <filter-name>opensessioninview</filter-name> >> <url-pattern>/*</url-pattern> >> </filter-mapping> >> <filter-mapping> >> <filter-name>wicket-spring-hibernate</filter-name> >> <url-pattern>/*</url-pattern> >> </filter-mapping> >> </web-app> >> >> >> >> applicationContext.xml: >> >> <?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 >> " >> default-autowire="byType" >> default-lazy-init="false" >> > >> <bean id="wicketApplication" >> class="uk.co.company.product.presentation.wicket.app.WicketApplication" /> >> >> <bean id="placeholderConfigurer" >> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >> autowire="byName"> >> >> <property name="ignoreUnresolvablePlaceholders" value="false" /> >> <property name="systemPropertiesModeName" >> value="SYSTEM_PROPERTIES_MODE_OVERRIDE" /> >> <property name="ignoreResourceNotFound" value="false" /> >> <property name="locations"><list> >> <value>classpath*:/application.properties</value> >> </list></property> >> </bean> >> >> <bean id="dataSource" >> class="org.springframework.jdbc.datasource.DriverManagerDataSource" >> autowire="byName"> >> >> <property >> name="driverClassName"><value>${jdbc.driver}</value></property> >> <property name="url"><value>${jdbc.url}</value></property> >> <property >> name="username"><value>${jdbc.username}</value></property> >> <property >> name="password"><value>${jdbc.password}</value></property> >> </bean> >> >> <tx:annotation-driven transaction-manager="txManager" /> >> >> <bean id="txManager" >> class="org.springframework.orm.hibernate3.HibernateTransactionManager" >> autowire="byName"> >> >> <property name="sessionFactory" ref="sessionFactory" /> >> </bean> >> >> <!--<bean id="interceptor" >> class="com.mycompany.hibernate.HibernateInterceptor"> >> </bean>--> >> >> <bean id="sessionFactory" >> class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" >> autowire="byName"> >> >> <property name="dataSource" ref="dataSource" /> >> <property name="hibernateProperties"> >> <props> >> <!-- GENERAL --> >> <prop key="hibernate.dialect">${hibernate.dialect}</prop> >> <prop key="hibernate.show_sql">true</prop> >> <prop key="hibernate.show_sql">hibernate.format_sql</prop> >> <prop key="hibernate.default_schema">zen_template</prop> >> <prop key="hibernate.max_fetch_depth">2</prop> >> <!-- <prop >> key="hibernate.default_batch_fetch_size">16</prop> --> >> <prop key="hibernate.default_entity_mode">pojo</prop> >> <prop key="hibernate.order_updates">true</prop> >> <prop key="hibernate.generate_statistics">true</prop> >> <prop key="hibernate.use_identifier_rollback">true</prop> >> <prop >> key="hibernate.current_session_context_class">thread</prop> >> <prop key="hibernate.use_outer_join">true</prop> >> <!-- JDBC --> >> <!-- <prop key="hibernate.jdbc.batch_size">20</prop> --> >> <!-- <prop >> key="hibernate.jdbc.batch_versioned_data">true</prop> --> >> <prop >> key="hibernate.jdbc.use_streams_for_binary">true</prop> >> <prop >> key="hibernate.jdbc.use_get_generated_keys">true</prop> >> <!-- CONNECTION --> >> <prop key="hibernate.connection.isolation">8</prop><!-- >> TRANSACTION_SERIALIZABLE --> >> <prop key="hibernate.connection.autocommit">false</prop> >> <prop key="hibernate.connection.pool_size">5</prop> >> <!-- CACHE --> >> <!-- <prop >> key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop> >> --> >> <!-- <prop >> key="hibernate.cache.use_minimal_puts">true</prop> --> >> <!-- <prop >> key="hibernate.cache.use_query_cache">true</prop> --> >> <!-- MISCELLANEOUS --> >> <prop >> key="hibernate.bytecode.use_reflection_optimizer">true</prop> >> <prop >> key="hibernate.cglib.use_reflection_optimizer">true</prop> >> <!-- <prop key="hibernate.bytecode.provider">cglib</prop> >> --> >> <!-- <prop key="hibernate.query.substitutions">true</prop> >> --> >> </props> >> </property> >> <!--<property name="entityInterceptor"> >> <ref bean="interceptor" /> >> </property>--> >> <property name="packagesToScan"><list> >> <value>uk.co.company.product.persistance.hibernate</value> >> </list></property> >> </bean> >> <context:component-scan base-package="uk.co.company.product" /> >> <context:annotation-config/> >> </beans> >> >> >> CustomAuthenticatedWebSession.java: >> >> >> public class CustomAuthenticatedWebSession extends >> AuthenticatedWebSession{ >> private static final long serialVersionUID = 4713195500103052768L; >> >> @SpringBean >> private UserService userService; >> public void setUserService(final UserService userService){ >> this.userService = userService; >> } >> >> transient private String currentUser = null; >> >> public CustomAuthenticatedWebSession(final Request request){ >> super(request); >> InjectorHolder.getInjector().inject(this);//<-- VERY IMPORTANT to >> get Spring DI to work (within Wicket objects) >> >> } >> >> @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()); >> } >> } >> >> >> UserServiceImpl.java: >> >> @Service >> public class UserServiceImpl extends _AbstractService implements >> UserService{ >> >> final private TestUserService testUserService = new TestUserService(); >> >> @Autowired >> private Temp1DAO temp1DAO; >> @Override >> @Required >> final public void setTemp1DAO(final Temp1DAO temp1dao){ >> temp1DAO = temp1dao; >> } >> >> public UserServiceImpl(){ >> super(); >> //InjectorHolder.getInjector().inject(this);//<-- VERY IMPORTANT >> to get Spring DI to work. >> } >> >> /* (non-Javadoc) >> * @see >> uk.co.company.product.business.spring.UserService#authenticate(java.lang.String, >> java.lang.String) >> */ >> @Override >> @Transactional >> final public boolean authenticate(final String userName, final String >> password){ >> final Temp1 temp1 = new Temp1(); >> temp1.setValue(userName); >> temp1DAO.save(temp1); >> return testUserService.authenticate(userName, password); >> } >> >> /* (non-Javadoc) >> * @see >> uk.co.company.product.business.spring.UserService#getRoles(java.lang.String, >> boolean) >> */ >> @Override >> @Transactional >> final public Roles getRoles(final String userName, final boolean >> signedIn){ >> return testUserService.getRoles(userName, signedIn); >> } >> } >> >> >> Temp1DAOImpl.java: >> >> @Repository >> public class Temp1DAOImpl extends AbstractTemp1DAO implements Temp1DAO{ >> private static final Log log = LogFactory.getLog(Temp1DAOImpl.class); >> >> public Temp1DAOImpl(){ >> super(); >> log.debug("Temp1DAO created."); >> } >> >> @Autowired >> public void init(final SessionFactory factory) { >> setSessionFactory(factory); >> } >> } >> >> >> >> >> ------------------------------ >> View message @ >> http://apache-wicket.1842946.n4.nabble.com/help-me-please-Wicket-Spring-Hibernate-configuration-woes-tp3088768p3089284.html<http://apache-wicket.1842946.n4.nabble.com/help-me-please-Wicket-Spring-Hibernate-configuration-woes-tp3088768p3089284.html?by-user=t> >> >> To start a new topic under Apache Wicket, email [hidden >> email]<http://user/SendEmail.jtp?type=node&node=3089321&i=1> >> To unsubscribe from Apache Wicket, click >> here<http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxODQyOTQ2fDEyNTYxMzc3ODY=&by-user=t>. >> >> > > > > -- > Sincerely, > JC (http://www.linkedin.com/in/jcgarciam) > --Anyone who has never made a mistake has never tried anything new.-- > > > > > ------------------------------ > View message @ > http://apache-wicket.1842946.n4.nabble.com/help-me-please-Wicket-Spring-Hibernate-configuration-woes-tp3088768p3089321.html > > To start a new topic under Apache Wicket, email > ml-node+1842946-1499480286-201...@n4.nabble.com<ml-node%2b1842946-1499480286-201...@n4.nabble.com> > To unsubscribe from Apache Wicket, click > here<http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1842946&code=YWRhbS5zLmdpYmJvbnNAZ21haWwuY29tfDE4NDI5NDZ8LTUzNzMyMDU4OQ==>. > > -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/help-me-please-Wicket-Spring-Hibernate-configuration-woes-tp3088768p3089371.html Sent from the Users forum mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org