Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: OutOfMemoryError: PermGen space

  1. #11
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    You can create a HibernateTemplate yourself. Simply inject the SessionFactory (as you do with the dao objects and inside the setter create a hibernatetemplate).

    Code:
    private HibernateTemplate hibernateTemplate;
    
    public void setSessionFactory(SessionFactory sessionFactory) {
      hibernateTemplate = new HibernateTemplate(sessionFactory);
    }
    That should work or instead of the SessionFactory create a HibernateTemplate in your ApplicationContext.xml and inject that.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  2. #12
    Join Date
    Sep 2007
    Posts
    26

    Default Thanks.

    your suggestion make sense.
    however, I'm still finding a place for injecting my sessionFactory. Could I just inject it inside my own LdapAuthenticationProvider. A portion of my config is:

    Code:
    <bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager">
    	<property name="providers">
    		<list>
    			<ref local="ldapRoleAuthenticationProvider" />
    		</list>
    	</property>
    </bean>
    <bean id="ldapRoleAuthenticationProvider" class="com.fimat.security.util.LdapRoleAuthenticationProvider">
    	<constructor-arg>
    		<bean class="org.acegisecurity.providers.ldap.authenticator.BindAuthenticator">
    			...
    		</bean>
    	</constructor-arg>
    	<constructor-arg>
    		<bean class="org.acegisecurity.providers.ldap.populator.DefaultLdapAuthoritiesPopulator">
    			<constructor-arg>
    				<ref local="initialDirContextFactory"/>
    			</constructor-arg>
    			<constructor-arg>
    				...
    			</constructor-arg>
    			<property name="groupRoleAttribute">
    				...
    			</property>
    		</bean>
    	</constructor-arg>
    </bean>
    I try to embed the HibernateTemplate but find no way to inject the sessionFactory:

    Code:
    public class LdapRoleAuthenticationProvider extends LdapAuthenticationProvider{
    
    	public LdapRoleAuthenticationProvider(LdapAuthenticator arg0, LdapAuthoritiesPopulator arg1) {
    		super(arg0, arg1);
    	}
    
    	private HibernateTemplate hibernateTemplate;
    	public void setSessionFactory(SessionFactory sessionFactory)
    	{
    		hibernateTemplate = new HibernateTemplate(sessionFactory);
    	}
    	public List getUserRoleList(String userID)
    	{
    		return hibernateTemplate.findByNamedQueryAndNamedParam("getRolesAuthenticated", "user_id", userID);
    	}
    }
    Sorry for posting long code and appreciated for any suggestions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •