-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Web App hangs up when opening hibernate session factory
PostPosted: Thu Jun 25, 2009 1:16 am 
Newbie

Joined: Thu Jun 25, 2009 1:14 am
Posts: 1
Hello All,
I have a very strange problem that causes our web application to hangup. I'm using the following technologies
Spring 2.5.6
Spring Security 2.0.1
Spring Security 2.0.1 core-tiger
Hibernate 3.0
JDK 1.6 update 10
PostgreSQL 8.3 (postgresql-8.3-603.jdbc3 driver)

I have a Class Campaign having a many-to-many association with Two other Classes namely Location and Advertisement.

A Campaign can be run on many locations and a location can run many campaigns

A Campaign is made up of many advertisements and an advertisement can appear in many campaigns.

Below are the class definition of Campaign,Location and Advertisement respectively.

Code:
public class Campaign extends AbstractPersistentBaseObject{
    private Long id;   
    private List<Advertisement> advertisements;
    private List<Location> locations;   

    @ManyToMany(cascade={CascadeType.PERSIST})
    @JoinTable(name="campaign_advertisement",joinColumns={@JoinColumn(name="campaign_id")},
                                                                                inverseJoinColumns={@JoinColumn(name="advertisement_id")})
    public List<Advertisement> getAdvertisements() {
        return advertisements;
    }   
    public void setAdvertisements(List<Advertisement> advertisements) {
        this.advertisements = advertisements;
    }
   
    @ManyToMany(cascade={CascadeType.PERSIST})
    @JoinTable(name="campaign_location",joinColumns={@JoinColumn(name="campaign_id")},
                                                                      inverseJoinColumns={@JoinColumn(name="location_id")})
    public List<Location> getLocations() {
        return locations;
    }
    public void setLocations(List<Location> locations) {
        this.locations = locations;
    }

Code:
public class Location extends AbstractPersistentBaseObject {
    private Long id;
    private List<Campaign> campaigns;

    @ManyToMany(mappedBy="locations",cascade={CascadeType.PERSIST})
    @JoinTable(name="campaign_location",joinColumns={@JoinColumn(name="location_id")},
                                                                      inverseJoinColumns={@JoinColumn(name="campaign_id")})
    public List<Campaign> getCampaigns() {
        return campaigns;
    }   
    public void setCampaigns(List<Campaign> campaigns) {
        this.campaigns = campaigns;
    }

Code:
public class Advertisement extends AbstractPersistentBaseObject{
    private Long id;
    private List<Campaign> campaigns;

    @ManyToMany(mappedBy="advertisements",cascade={CascadeType.PERSIST})
    @JoinTable(name="campaign_advertisement",joinColumns={@JoinColumn(name="advertisement_id")},
                                                                                inverseJoinColumns={@JoinColumn(name="campaign_id")})
    public List<Campaign> getCampaigns() {
        return campaigns;
    }   
    public void setCampaigns(List<Campaign> campaigns) {
        this.campaigns = campaigns;
    }


At first the many-to-many association was unidirectional from campaign to location and from campaign to advertisement but later changed it to bi directional with campaign being the owner of the association(but the problem is not solved regardless of directionality).

Locations and Advertisements are being loaded lazily when a campaign is loaded. When a campaign is updated, the locations and advertisements are loaded (using query by criteria) and the lists are set manually in campaign using the appropriate setters. Below are the two query by criteria for fetching all the locations and advertisements for a campaign

Code:
public class CampaignDaoHibernateImpl extends GenericDaoHibernateImpl<Campaign,Long> implements ICampaignDao{

    public CampaignDaoHibernateImpl(){
        super(Campaign.class);
    }

    public List<Campaign> findCampaignLocations(Campaign campaign) {
        Criteria criteria = getSession().createCriteria(Campaign.class).                                                           
                                                           add(Restrictions.eq("id", campaign.getId())).
                                                           setMaxResults(1).
                                                           createCriteria("locations");
        return criteria.list();
    }

    public List<Campaign> findCampaignAdvertisements(Campaign campaign) {
        Criteria criteria = getSession().createCriteria(Campaign.class).
                                                           add(Restrictions.eq("id", campaign.getId())).
                                                           setMaxResults(1).
                                                           createCriteria("advertisements");
        return criteria.list();
    }
}


The web application hangs up when editing/saving a campaign (mostly on editing and if done continuously 2 to 3 times) and all that is logged on the console is given below

DEBUG CampaignFormController - Calling doUpdate for entity with id: [113]
DEBUG SessionFactoryUtils - Opening Hibernate Session

during this hangup, if we try to log in again,following is the message that is logged on the console

Quote:
DEBUG FilterChainProxy - Converted URL to lowercase, from: '/login.jsp'; to: '/login.jsp'
DEBUG FilterChainProxy - Candidate is: '/login.jsp'; pattern is /**; matched=true
DEBUG FilterChainProxy - /login.jsp at position 1 of 10 in additional filter chain; firing Filter: 'org.springframework.security.context.HttpSessionContextIntegrationFilter[ order=200; ]'
DEBUG essionContextIntegrationFilter - Obtained a valid SecurityContext from SPRING_SECURITY_CONTEXT to associate with SecurityContextHolder: 'org.springframework.security.context.SecurityContextImpl@ef073bd6: Authentication: org.springframework.security.providers.UsernamePasswordAuthenticationToken@ef073bd6: Principal: org.springframework.security.userdetails.User@0: Username: hasnain; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_USER; Password: [PROTECTED]; Authenticated: true; Details: org.springframework.security.ui.WebAuthenticationDetails@2eb76: RemoteIpAddress: 127.0.0.1; SessionId: 0DA65CF76F3BAE76B73416C7AEDE1538; Granted Authorities: ROLE_USER'
DEBUG FilterChainProxy - /login.jsp at position 2 of 10 in additional filter chain; firing Filter: 'org.springframework.security.ui.SessionFixationProtectionFilter[ order=300; ]'
DEBUG FilterChainProxy - /login.jsp at position 3 of 10 in additional filter chain; firing Filter: 'org.springframework.security.ui.logout.LogoutFilter[ order=400; ]'
DEBUG FilterChainProxy - /login.jsp at position 4 of 10 in additional filter chain; firing Filter: 'org.springframework.security.ui.webapp.AuthenticationProcessingFilter[ order=800; ]'
DEBUG FilterChainProxy - /login.jsp at position 5 of 10 in additional filter chain; firing Filter: 'org.springframework.security.ui.basicauth.BasicProcessingFilter[ order=1100; ]'
DEBUG BasicProcessingFilter - Authorization header: null
DEBUG FilterChainProxy - /login.jsp at position 6 of 10 in additional filter chain; firing Filter: 'org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter[ order=1200; ]'
DEBUG SavedRequestAwareWrapper - Wrapper not replaced; SavedRequest was: null
DEBUG FilterChainProxy - /login.jsp at position 7 of 10 in additional filter chain; firing Filter: 'org.springframework.security.ui.rememberme.RememberMeProcessingFilter[ order=1300; ]'
DEBUG RememberMeProcessingFilter - SecurityContextHolder not populated with remember-me token, as it already contained: 'org.springframework.security.providers.UsernamePasswordAuthenticationToken@ef073bd6: Principal: org.springframework.security.userdetails.User@0: Username: hasnain; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_USER; Password: [PROTECTED]; Authenticated: true; Details: org.springframework.security.ui.WebAuthenticationDetails@2eb76: RemoteIpAddress: 127.0.0.1; SessionId: 0DA65CF76F3BAE76B73416C7AEDE1538; Granted Authorities: ROLE_USER'
DEBUG FilterChainProxy - /login.jsp at position 8 of 10 in additional filter chain; firing Filter: 'org.springframework.security.providers.anonymous.AnonymousProcessingFilter[ order=1400; ]'
DEBUG AnonymousProcessingFilter - SecurityContextHolder not populated with anonymous token, as it already contained: 'org.springframework.security.providers.UsernamePasswordAuthenticationToken@ef073bd6: Principal: org.springframework.security.userdetails.User@0: Username: hasnain; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_USER; Password: [PROTECTED]; Authenticated: true; Details: org.springframework.security.ui.WebAuthenticationDetails@2eb76: RemoteIpAddress: 127.0.0.1; SessionId: 0DA65CF76F3BAE76B73416C7AEDE1538; Granted Authorities: ROLE_USER'
DEBUG FilterChainProxy - /login.jsp at position 9 of 10 in additional filter chain; firing Filter: 'org.springframework.security.ui.ExceptionTranslationFilter[ order=1500; ]'
DEBUG FilterChainProxy - /login.jsp at position 10 of 10 in additional filter chain; firing Filter: 'org.springframework.security.intercept.web.FilterSecurityInterceptor@16528a2'
DEBUG lterInvocationDefinitionSource - Converted URL to lowercase, from: '/login.jsp'; to: '/login.jsp'
DEBUG lterInvocationDefinitionSource - Candidate is: '/login.jsp'; pattern is /**/*.htm*; matched=false
DEBUG AbstractSecurityInterceptor - Public object - authentication not attempted
DEBUG XmlWebApplicationContext - Publishing event in context [org.springframework.web.context.support.XmlWebApplicationContext@381a53]: org.springframework.security.event.authorization.PublicInvocationEvent[source=FilterInvocation: URL: /login.jsp]
DEBUG FilterChainProxy - /login.jsp reached end of additional filter chain; proceeding with original chain
DEBUG ExceptionTranslationFilter - Chain processed normally
DEBUG essionContextIntegrationFilter - SecurityContextHolder now cleared, as request processing completed
DEBUG FilterChainProxy - Converted URL to lowercase, from: '/j_security_check'; to: '/j_security_check'
DEBUG FilterChainProxy - Candidate is: '/j_security_check'; pattern is /**; matched=true
DEBUG FilterChainProxy - /j_security_check at position 1 of 10 in additional filter chain; firing Filter: 'org.springframework.security.context.HttpSessionContextIntegrationFilter[ order=200; ]'
DEBUG essionContextIntegrationFilter - Obtained a valid SecurityContext from SPRING_SECURITY_CONTEXT to associate with SecurityContextHolder: 'org.springframework.security.context.SecurityContextImpl@ef073bd6: Authentication: org.springframework.security.providers.UsernamePasswordAuthenticationToken@ef073bd6: Principal: org.springframework.security.userdetails.User@0: Username: hasnain; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_USER; Password: [PROTECTED]; Authenticated: true; Details: org.springframework.security.ui.WebAuthenticationDetails@2eb76: RemoteIpAddress: 127.0.0.1; SessionId: 0DA65CF76F3BAE76B73416C7AEDE1538; Granted Authorities: ROLE_USER'
DEBUG FilterChainProxy - /j_security_check at position 2 of 10 in additional filter chain; firing Filter: 'org.springframework.security.ui.SessionFixationProtectionFilter[ order=300; ]'
DEBUG FilterChainProxy - /j_security_check at position 3 of 10 in additional filter chain; firing Filter: 'org.springframework.security.ui.logout.LogoutFilter[ order=400; ]'
DEBUG FilterChainProxy - /j_security_check at position 4 of 10 in additional filter chain; firing Filter: 'org.springframework.security.ui.webapp.AuthenticationProcessingFilter[ order=800; ]'
DEBUG AuthenticationProcessingFilter - Request is to process authentication
DEBUG ProviderManager - Authentication attempt using org.springframework.security.providers.dao.DaoAuthenticationProvider
DEBUG JdbcTemplate - Executing prepared SQL query
DEBUG JdbcTemplate - Executing prepared SQL statement [SELECT username,password,enabled FROM users WHERE username = ?]
DEBUG DataSourceUtils - Fetching JDBC Connection from DataSource


Some times, it happens that the web application/tomcat hangs up during deployment and happens at two separate occasions and the logged messages that are shown on the console are given below

1.
Quote:
DEBUG FilterChainProxy- /netbeans-tomcat-status-test at position 10 of 10 in additional filter chain; firing Filter: 'org.springframework.security.intercept.web.FilterSecurityInterceptor@e20ef8'


2.
Quote:
DEBUG essionContextIntegrationFilter - HttpSession being created as SecurityContextHolder contents are non-default


Have no idea why the application hangs up ??

Any help would be highly appreciated.Waiting for a favorable response.

Thanks in advance :D .

Kind regrads.
HJaved.

PS. apologies for the long post


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.