Announcement Announcement Module
Collapse
No announcement yet.
Authentication is not working, spring-security, spring mvc, hibernate, stringTemplate Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Authentication is not working, spring-security, spring mvc, hibernate, stringTemplate

    Hi, I am a newbie in spring,
    Authentication is not working, what is going on, i don`t know where is the problem. Help me I`m using spring mvc 2.5 spring-security 2.0, Hibernate 3.0 and stringTemplate.

    Here is my code:
    web.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?> 
    <web-app version="2.4" 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">
    	
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    
    	<context-param> 
    		<param-name>contextConfigLocation</param-name> 
    		<param-value> 
    			/WEB-INF/jshop-servlet.xml,
    			/WEB-INF/applicationContext-security.xml  
    		</param-value>
    	</context-param> 
    
    	<filter> 
    		<filter-name>springSecurityFilterChain</filter-name> 
    		<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> 
    	</filter> 
    	
    	<filter-mapping> 
    		<filter-name>springSecurityFilterChain</filter-name> 
    		<url-pattern>/*</url-pattern> 
    	</filter-mapping>
    
    	<filter>
            <filter-name>encoding-filter</filter-name>
            <filter-class>
                org.springframework.web.filter.CharacterEncodingFilter
            </filter-class>
            <init-param>
                <param-name>encoding</param-name>
                <param-value>UTF-8</param-value>
            </init-param>
        </filter>
    
        <filter-mapping>
            <filter-name>encoding-filter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    
    	<servlet> 
    		<servlet-name>jshop</servlet-name> 
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
    		<load-on-startup>1</load-on-startup> 
    	</servlet>
    
    	<servlet-mapping>
    		<servlet-name>jshop</servlet-name> 
    		<url-pattern>*.html</url-pattern>
    	</servlet-mapping> 
    		
    	<welcome-file-list> 
    		<welcome-file>index.html</welcome-file>
    	</welcome-file-list> 
    	
    </web-app>
    applicationContext-security.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?> 
    
    <beans:beans xmlns="http://www.springframework.org/schema/security" 
    	xmlns:beans="http://www.springframework.org/schema/beans" 
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    	xsi:schemaLocation="http://www.springframework.org/schema/beans 
    		http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
    		http://www.springframework.org/schema/security 
    		http://www.springframework.org/schema/security/spring-security-2.0.2.xsd"> 
    
    	<global-method-security secured-annotations="enabled"></global-method-security> 
    	<http auto-config="true">
    		 
    		<intercept-url pattern="/logged*" access="ROLE_USER,ROLE_ADMIN"  />
    		<intercept-url pattern="/**" access="ROLE_ANONYMOUS" /> 
    <!--		<intercept-url pattern="/add_product.html" access="ROLE_ADMIN" />-->
    		
    		<logout logout-success-url="/login.html" /> 
    		<form-login authentication-failure-url="/login.html?login_error=1" 
    		login-page="/login.html" default-target-url="/logged.html" /> 
    	</http> 
    	
    	
    	<authentication-provider> 
    		<jdbc-user-service data-source-ref="myDataSource" 
    			users-by-username-query="select username, password, enabled from users where username=?" /> 
    	</authentication-provider> 
    </beans:beans>
    login.st
    Code:
    	Log in: 
    	<form action="j_spring_security_check"> 
    	$if(login_error)$
    		<br />
    		<b>Wrong login or password!</b><br />
    	$endif$ 
    	
    	<table> 
    		<tr> 
    			<td> <label for="j_username">Username: </label> </td> 
    			<td> <input type="text" name="j_username" id="j_username" /> </td> 
    		</tr> 
    		<tr> 
    			<td> <label for="j_password">Password: </label> </td> 
    			<td> <input type="password" name="j_password" id="j_password"/> </td> 
    		</tr>
    		<!--<tr> <td> <input type='checkbox' name='_spring_security_remember_me'/>  </td><td> Remember me on this computer. </td></tr>-->
    		<tr> 
    			<td> <input class="button" type="submit" value="Login"/> </td> 
    		</tr> 
    	</table> 
    
    </form>
    logged.st
    Code:
    	<div id="posts">
    		 
    		[ <a href="j_spring_security_logout"><b>logout</b></a> ]								
    		
    		<br /><br /> You are logged! :) 
    		
    		<sec:authorize ifAllGranted="ROLE_ADMIN">
    			<p>Administrator</p>
    	    </sec:authorize>	
    		
    		<sec:authorize ifAllGranted="ROLE_USER">
    			<p>User</p>
    	    </sec:authorize>
    	    
    	</div>
    please help me!!

  • #2
    For starters your setup is wrong. Don't let the contextloaderlistener load the servlet configuration, this will duplicate your beans and configuration.

    Comment


    • #3
      thanks for replay, but what do you mean by this?? if i remove listener then application stop working. sorry for this question, maybe stupid but as i wrote i am newbie in it.

      Comment


      • #4
        Originally posted by Marten Deinum View Post
        For starters your setup is wrong. Don't let the contextloaderlistener load the servlet configuration, this will duplicate your beans and configuration.
        Not if you have two different configurations. One for servlets and other for contextloaderlistener. Just don't put any beans to configuration that is meant for servlets, beans inside contextlistener loaded config will still be available to servlets.

        Comment


        • #5
          Your contextloaderlistener is configured to load 2 xmls files one is the -servlet.xml which is ALSO loaded by the dispatcherservlet. The contextloaderlistener mustn't load this xml file.

          Comment


          • #6
            it`s not working i don`t know what to do ;/ maybe a don`t understand what you are talking about, please give me another hint, if you can of course

            Comment


            • #7
              1) What isn't working?
              2) Post your configuration.

              Comment


              • #8
                Originally posted by Marten Deinum View Post
                1) What isn't working?
                2) Post your configuration.
                1 . it isn`t working authentication, i tried to do something, but authentication isn`t working again, i thing that i dont understand your hints, and I can not adapt to them.
                2. configuration is the first post

                Comment


                • #9
                  If you didn't change your configuration with my hints it indeed isn't going to work...

                  Your contextloaderlistener is configured to load 2 xmls files one is the -servlet.xml which is ALSO loaded by the dispatcherservlet. The contextloaderlistener mustn't load this xml file.
                  The above is quite clear IMHO...

                  And no not your FULL configuration is in your first post, only partially... Hence my request for your configuration.

                  Comment


                  • #10
                    so it should be:?
                    web.xml
                    Code:
                    ...
                    <context-param> 
                    		<param-name>contextConfigLocation</param-name> 
                    		<param-value> 
                    			/WEB-INF/applicationContext-security.xml  
                    		</param-value>
                    	</context-param>
                    
                    .....
                    
                    <servlet> 
                    		<servlet-name>jshop</servlet-name> 
                    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
                    		<load-on-startup>1</load-on-startup> 
                    	</servlet>
                    ...
                    instead
                    Code:
                            <context-param> 
                    		<param-name>contextConfigLocation</param-name> 
                    		<param-value> 
                    			/WEB-INF/applicationContext-security.xml  
                                           /WEB-INF/jshop-servlet.xml  
                    		</param-value>
                    	</context-param>
                    ....
                           <servlet> 
                    		<servlet-name>jshop</servlet-name> 
                    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
                    		<load-on-startup>1</load-on-startup> 
                           </servlet>

                    Comment


                    • #11
                      for starters yes...

                      Comment


                      • #12
                        when i did it i got it:
                        Code:
                        org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_filterChainProxy': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_filterChainList': Cannot resolve reference to bean '_rememberMeFilter' while setting bean property 'filters' with key [6]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_rememberMeFilter': Cannot resolve reference to bean '_rememberMeServices' while setting bean property 'rememberMeServices'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_rememberMeServices': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.userdetails.jdbc.JdbcUserDetailsManager#0': Cannot resolve reference to bean 'myDataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'myDataSource' is defined
                        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
                        	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:3972)
                        	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
                        	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
                        	at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
                        	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
                        	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
                        	at org.apache.catalina.core.StandardService.start(StandardService.java:519)
                        	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
                        	at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
                        	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                        	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                        	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                        	at java.lang.reflect.Method.invoke(Unknown Source)
                        	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
                        	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
                        Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_filterChainList': Cannot resolve reference to bean '_rememberMeFilter' while setting bean property 'filters' with key [6]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_rememberMeFilter': Cannot resolve reference to bean '_rememberMeServices' while setting bean property 'rememberMeServices'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_rememberMeServices': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.userdetails.jdbc.JdbcUserDetailsManager#0': Cannot resolve reference to bean 'myDataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'myDataSource' is defined
                        	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
                        	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
                        	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:287)
                        	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:126)
                        	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
                        	at org.springframework.security.config.FilterChainProxyPostProcessor.postProcessBeforeInitialization(FilterChainProxyPostProcessor.java:52)
                        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:350)
                        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1331)
                        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
                        	... 29 more
                        Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_rememberMeFilter': Cannot resolve reference to bean '_rememberMeServices' while setting bean property 'rememberMeServices'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_rememberMeServices': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.userdetails.jdbc.JdbcUserDetailsManager#0': Cannot resolve reference to bean 'myDataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'myDataSource' is defined
                        	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
                        	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
                        	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
                        jshop-servlet.xml
                        Code:
                        <bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
                        		<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
                        		<property name="url" value="jdbc:mysql://localhost/jshop"/>
                        		<property name="username" value="root"/>
                        		<property name="password" value="admin1029"/>
                        	</bean>
                        		
                        	<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" > 
                        		<property name="dataSource" ref="myDataSource"/> 
                        		<property name="hibernateProperties"> 
                        			<props> 
                        				<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop> 
                        				<prop key="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop> 
                        				<prop key="hibernate.current_session_context_class">thread</prop> 
                        			</props> 
                        		</property> 
                        		<property name="mappingResources" > 
                        			<list> 
                        				<value>com/jshop/hibernate/Product.hbm.xml</value>
                        				<value>com/jshop/hibernate/Category.hbm.xml</value>
                        				<value>com/jshop/hibernate/DeliveryForm.hbm.xml</value>
                        				<value>com/jshop/hibernate/PaymentMethod.hbm.xml</value>
                        				<value>com/jshop/hibernate/Newsletter.hbm.xml</value>
                        				<value>com/jshop/hibernate/AllTexts.hbm.xml</value>
                        			</list> 
                        		</property> 
                        	</bean>
                        Last edited by jolsys; Oct 6th, 2010, 07:45 AM.

                        Comment


                        • #13
                          1) Your infrastructure code should be loaded by the contextloaderlistener so create an additional file containing your datasource/sessionfactory/tx management and move that to there and let it be loaded by the contextlodaerlistener. (Basically you want to do the same for your services and daos, the DispatcherServlet should only load web related things like controllers, views, etc...).

                          2. Your tx management is broken remove the hibernate.current_session_context_class property from the localsessionfactorybean, the same goes for the hibernate.connection properties as they are useless due to the fact that you are injecting a datasource.

                          As I wanted to prevent you from this hence my request for your configuration...

                          Comment


                          • #14
                            i I removed the
                            hibernate.current_session_context_class and hibernate.connection
                            I do not understand the first point

                            Code:
                            jshop-servlet.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:context="http://www.springframework.org/schema/context"
                            	xmlns:tx="http://www.springframework.org/schema/tx"
                            	xsi:schemaLocation="http://www.springframework.org/schema/beans 
                            	http://www.springframework.org/schema/beans/spring-beans-2.0.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
                            	http://www.springframework.org/schema/aop 
                            	http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
                            	
                            	
                            	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
                            	<!-- URL Mappings                                                    -->
                            	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
                            	<!--	HandlerMapping - jest odpowiedzialny za okreslenie		-->
                            	<!--	odpowiedniego kontrolera lub innego obiektu, do którego	-->
                            	<!--	nalezy przekazac obsługe zadania						-->
                            	<bean id="simpleUrlMapping"
                            		class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
                            		<property name="mappings">
                            			<props>
                            				<prop key="/index.html">indexController</prop>
                            				<prop key="/product.html">ProductController</prop>
                            			</props>
                            		</property>
                            		<property name="alwaysUseFullPath" value="true"/>
                            	</bean>
                             	
                             	<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
                            
                            	 <!-- Scan for controllers and services -->
                            	<context:component-scan base-package="com.jshop.web"/>
                            	<context:component-scan base-package="com.jshop.service"/>
                            	
                            	<!-- Create a proxy to generate session-scoped shopping carts -->
                            	<bean id="shoppingCart" class="com.jshop.model.ShoppingCart" scope="session">
                            		<!-- This requires CGLIB -->
                            		<aop:scoped-proxy/>
                            	</bean>
                            	
                            		
                            <!--	<bean id="personReader" class="org.springframework.batch.item.validator.ValidatingItemReader">
                            	    <property name="validator" ref="validator" />
                            	    <property name="itemReader" ref="reader"/>	    
                              		</bean>
                            -->
                            	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
                            	<!-- Controllers                                                     -->
                            	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
                            	<bean id="indexController" 	class="org.springframework.web.servlet.mvc.ParameterizableViewController">
                            		<property name="viewName" value="index"/>
                            	</bean>
                            	
                            	<bean id="ProductController" class="com.jshop.web.ProductController">
                            		<property name="productManager" ref="ProductManager" />
                            		<property name="shoppingCart" ref="ShoppingCartService" />
                            	</bean>
                            	<bean name="/product.html" class="com.jshop.web.ProductController" >
                            		<property name="productManager" ref="ProductManager" />
                            		<property name="shoppingCart" ref="ShoppingCartService" />
                            	</bean>
                            	
                            	
                            	<bean name="ProductManager" class="com.jshop.service.ProductManager"> 
                            		<property name="productDao" ref="ProductDao" /> 
                            	</bean>
                            	
                            	<bean id="ProductDao" class="com.jshop.model.ProductDao"> 
                            		<property name="sessionFactory" ref="mySessionFactory" /> 
                            	</bean>
                            	
                            	<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> 
                            		<property name="basenames">
                                        <list><value>error-messages</value></list>
                                    </property>
                            	</bean>
                            	
                            	<!--	ViewResolver - jest to komponent, który odwzorowuje logiczne	-->
                            	<!--	nazwy widoków na faktyczne widoki, które zostana uzyte do		-->
                            	<!--	przedstawienia zawartosci modelu								-->
                            	<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                            		<property name="viewClass" value="com.jshop.template.StringTemplateView" />
                            		<property name="prefix" value="/WEB-INF/template/" />
                            		<property name="suffix" value=".st" />
                            		<property name="requestContextAttribute" value="rc" />
                            	</bean>
                            	
                            	<!--	LocaleResolver - pozwala na okreslenie ustawien				-->
                            	<!--	miedzynarodowych, jakich nalezy uzyc podczas generowania	-->
                            	<!--	widoku														-->
                            	
                            	<!-- HIBERNATE -->
                            	<bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
                            		<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
                            		<property name="url" value="jdbc:mysql://localhost/jshop"/>
                            		<property name="username" value="root"/>
                            		<property name="password" value="admin1029"/>
                            	</bean>
                            		
                            	<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" > 
                            		<property name="dataSource" ref="myDataSource"/> 
                            		<property name="hibernateProperties"> 
                            			<props> 
                            				<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop> 
                            			</props> 
                            		</property> 
                            		<property name="mappingResources" > 
                            			<list> 
                            				<value>com/jshop/hibernate/Product.hbm.xml</value>
                            				<value>com/jshop/hibernate/Category.hbm.xml</value>
                            				<value>com/jshop/hibernate/DeliveryForm.hbm.xml</value>
                            				<value>com/jshop/hibernate/PaymentMethod.hbm.xml</value>
                            				<value>com/jshop/hibernate/Newsletter.hbm.xml</value>
                            				<value>com/jshop/hibernate/AllTexts.hbm.xml</value>
                            			</list> 
                            		</property> 
                            	</bean> 
                            	
                            	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> 
                            		<property name="sessionFactory" ref="mySessionFactory" /> 
                            	</bean>
                            	
                            	<tx:annotation-driven transaction-manager="transactionManager"/>
                            	
                            </beans>

                            Comment


                            • #15
                              shared code should be loaded by the contextloaderlistener, you want to share your (SINGLE) sessionfactory with your whole application, not only the web layer... Hence move those to a configuration file which is loaded by the contextloaderlistener.

                              You seem to be missing basic concepts and knowlegde I suggest a read of the reference guide (or at least a spring book) and take a look at the sample application, which shows what I mentioned earlier.

                              Comment

                              Working...
                              X