glassfish
  1. glassfish
  2. GLASSFISH-14972

NullPointerException in org.eclipse.persistence.internal.identitymaps.CacheKey.equals

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Incomplete
    • Affects Version/s: v3.0.1
    • Fix Version/s: None
    • Component/s: entity-persistence
    • Labels:
      None
    • Environment:

      Ubuntu Linux

      Description

      I get the following explosion in my JPA/EJB webapp. It happened reproducibly again and again with the same input. However, after trying some other input the problem went away and never came back. Don't we all love this kind of bugs?

      It appears to be something deep down in the JPA handler.

      The problem is next to impossible to reproduce, so I guess you have to stare hard at the source to find it...

      (Strange; there's no JPA alternative in the 'Components' select box, so I specify 'Unknown' for now, you guys can assign it better than me).

      Here's the stack trace. Hope this is useful.

      java.lang.NullPointerException AT org.eclipse.persistence.internal.identitymaps.CacheKey.equals:282 ObjectChangeSet.equals:205 ObjectChangeSet.equals:189 ArrayList.indexOf:216 ArrayList.contains:199 ListContainerPolicy.recordRemoveFromCollectionInChangeRecord:148 OrderedListContainerPolicy.recordUpdateToCollectionInChangeRecord:632 CollectionMapping.updateCollectionChangeRecord:1903 AttributeChangeListener.internalPropertyChange:151 AttributeChangeListener.propertyChange:111 IndirectList.raiseRemoveChangeEvent:159 IndirectList$1.set:562 Collections.sort:163 AdEjb.create:49 NativeMethodAccessorImpl.invoke0:-2 NativeMethodAccessorImpl.invoke:39 DelegatingMethodAccessorImpl.invoke:25 Method.invoke:597 EJBSecurityManager.runMethod:1056 EJBSecurityManager.invoke:1128 BaseContainer.invokeBeanMethod:5292 EjbInvocation.invokeBeanMethod:615 AroundInvokeChainImpl.invokeNext:797 EjbInvocation.proceed:567 SystemInterceptorProxy.doAround:157 SystemInterceptorProxy.aroundInvoke:139 GeneratedMethodAccessor49.invoke DelegatingMethodAccessorImpl.invoke:25 Method.invoke:597 AroundInvokeInterceptor.intercept:858 AroundInvokeChainImpl.invokeNext:797 InterceptorManager.intercept:367 BaseContainer.__intercept:5264 BaseContainer.intercept:5252 EJBLocalObjectInvocationHandler.invoke:190 EJBLocalObjectInvocationHandlerDelegate.invoke:84 $Proxy132.create AdminServlet.doPost:1220 HttpServlet.service:754 HttpServlet.service:847 StandardWrapper.service:1523 ApplicationFilterChain.internalDoFilter:343 ApplicationFilterChain.doFilter:215 RequestLogFilter.doFilter:62 ApplicationFilterChain.internalDoFilter:256 ApplicationFilterChain.doFilter:215 MainFilter.doFilter:41 ApplicationFilterChain.internalDoFilter:256 ApplicationFilterChain.doFilter:215 StandardWrapperValve.invoke:277 StandardContextValve.invoke:188 StandardPipeline.invoke:641 WebPipeline.invoke:97 PESessionLockingStandardPipeline.invoke:85 StandardHostValve.invoke:185 CoyoteAdapter.doService:325 CoyoteAdapter.service:226 ContainerMapper.service:165 ProcessorTask.invokeAdapter:791 ProcessorTask.doProcess:693 ProcessorTask.process:954 DefaultProtocolFilter.execute:170 DefaultProtocolChain.executeProtocolFilter:135 DefaultProtocolChain.execute:102 DefaultProtocolChain.execute:88 HttpProtocolChain.execute:76 ProtocolChainContextTask.doCall:53 SelectionKeyContextTask.call:57 ContextTask.run:69 AbstractThreadPool$Worker.doWork:330 AbstractThreadPool$Worker.run:309 Thread.run:662

        Activity

        Hide
        Mitesh Meswani added a comment -

        Please post the entity for which you are getting the exception.

        Have you tried your app with latest version of GlassFish/EclipseLink. There are many improvements in this area of the code which might have already fixed the issue you are facing.

        Show
        Mitesh Meswani added a comment - Please post the entity for which you are getting the exception. Have you tried your app with latest version of GlassFish/EclipseLink. There are many improvements in this area of the code which might have already fixed the issue you are facing.
        Hide
        tmpsa added a comment -

        Sorry, I thought that I'm using the lastest (released) version of Glassfish/EclipseLink (3.0.1).
        What would be a later version?

        And, as I said, this crash is never before seen, and I guess it will show up very seldom.
        So even if I use some beta of an upcoming release, the chance of observing the problem is still small. Hope that it is possible to locate the bug anyway.

        Here's a snippet of the code in 'AdAjb' where I get the crasch:

        Advertiser advertiser = advertiserLocal.find4sure(advertiserId);
        Ad ad = new Ad();
        ad.setName(name);
        ad.setAdvertiser(advertiser);
        ad.setDisplayTime(displayTime);
        ad.setCreatedDate(new Date());
        persist(ad);
        advertiser.getAds().add(ad);
        Collections.sort(advertiser.getAds(), nameOrder);

        where 'nameOrder' is a generic method of a superclass:

        public static final Comparator<HasName> nameOrder = new Comparator<HasName>() {
        public int compare(HasName x, HasName y)

        { return x.getName().compareTo(y.getName()); }

        };

        Here below is the entity 'Ad', as requested.

        Hope this helps. I'll be happy to provide more information if needed.

        package com.facilitylabs.controlserver.entities.fpdb;

        import com.facilitylabs.controlserver.entities.HasId;
        import com.facilitylabs.controlserver.entities.HasName;

        import javax.persistence.*;
        import java.util.List;
        import java.util.LinkedList;
        import java.util.Date;

        @Entity
        @Table(name = "ads")
        public class Ad implements HasId, HasName {

        private int id;
        private String filename;
        private String name;
        private String mimetype;
        private int displayTime;
        private Date createdDate;
        private Date approvedDate;
        private String approvedUsername;
        private Advertiser advertiser;
        private List<Schedule> schedules = new LinkedList<Schedule>();

        @Id
        @Column(name="id")
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        public int getId()

        { return id; }

        public void setId(int id)

        { this.id = id; }

        public String getFilename()

        { return filename; }

        public void setFilename(String filename)

        { this.filename = filename; }

        public String getName()

        { return name; }

        public void setName(String name)

        { this.name = name; }

        public String getMimetype()

        { return mimetype; }

        public void setMimetype(String mimetype)

        { this.mimetype = mimetype; }

        @Column(name="display_time")
        public int getDisplayTime()

        { return displayTime; }

        public void setDisplayTime(int displayTime)

        { this.displayTime = displayTime; }

        @Column(name="created_date")
        @Temporal(TemporalType.TIMESTAMP)
        public Date getCreatedDate()

        { return createdDate; }

        public void setCreatedDate(Date createdDate)

        { this.createdDate = createdDate; }

        @ManyToOne
        @JoinColumn(name="advertiser_id")
        public Advertiser getAdvertiser()

        { return advertiser; }

        @Column(name="approved_date")
        @Temporal(TemporalType.DATE)
        public Date getApprovedDate()

        { return approvedDate; }

        public void setApprovedDate(Date approvedDate)

        { this.approvedDate = approvedDate; }

        @Column(name="approved_username")
        public String getApprovedUsername()

        { return approvedUsername; }

        public void setApprovedUsername(String approvedUsername)

        { this.approvedUsername = approvedUsername; }

        public void setAdvertiser(Advertiser advertiser)

        { this.advertiser = advertiser; }

        @OneToMany(mappedBy="ad")
        public List<Schedule> getSchedules()

        { return schedules; }

        public void setSchedules(List<Schedule> schedules)

        { this.schedules = schedules; }

        @Transient
        public boolean isApproved()

        { return approvedUsername != null && approvedUsername.length() != 0; }

        @Transient
        public int getDisplaySeconds()

        { return displayTime / 1000; }

        }

        Show
        tmpsa added a comment - Sorry, I thought that I'm using the lastest (released) version of Glassfish/EclipseLink (3.0.1). What would be a later version? And, as I said, this crash is never before seen, and I guess it will show up very seldom. So even if I use some beta of an upcoming release, the chance of observing the problem is still small. Hope that it is possible to locate the bug anyway. Here's a snippet of the code in 'AdAjb' where I get the crasch: Advertiser advertiser = advertiserLocal.find4sure(advertiserId); Ad ad = new Ad(); ad.setName(name); ad.setAdvertiser(advertiser); ad.setDisplayTime(displayTime); ad.setCreatedDate(new Date()); persist(ad); advertiser.getAds().add(ad); Collections.sort(advertiser.getAds(), nameOrder); where 'nameOrder' is a generic method of a superclass: public static final Comparator<HasName> nameOrder = new Comparator<HasName>() { public int compare(HasName x, HasName y) { return x.getName().compareTo(y.getName()); } }; Here below is the entity 'Ad', as requested. Hope this helps. I'll be happy to provide more information if needed. package com.facilitylabs.controlserver.entities.fpdb; import com.facilitylabs.controlserver.entities.HasId; import com.facilitylabs.controlserver.entities.HasName; import javax.persistence.*; import java.util.List; import java.util.LinkedList; import java.util.Date; @Entity @Table(name = "ads") public class Ad implements HasId, HasName { private int id; private String filename; private String name; private String mimetype; private int displayTime; private Date createdDate; private Date approvedDate; private String approvedUsername; private Advertiser advertiser; private List<Schedule> schedules = new LinkedList<Schedule>(); @Id @Column(name="id") @GeneratedValue(strategy = GenerationType.IDENTITY) public int getId() { return id; } public void setId(int id) { this.id = id; } public String getFilename() { return filename; } public void setFilename(String filename) { this.filename = filename; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getMimetype() { return mimetype; } public void setMimetype(String mimetype) { this.mimetype = mimetype; } @Column(name="display_time") public int getDisplayTime() { return displayTime; } public void setDisplayTime(int displayTime) { this.displayTime = displayTime; } @Column(name="created_date") @Temporal(TemporalType.TIMESTAMP) public Date getCreatedDate() { return createdDate; } public void setCreatedDate(Date createdDate) { this.createdDate = createdDate; } @ManyToOne @JoinColumn(name="advertiser_id") public Advertiser getAdvertiser() { return advertiser; } @Column(name="approved_date") @Temporal(TemporalType.DATE) public Date getApprovedDate() { return approvedDate; } public void setApprovedDate(Date approvedDate) { this.approvedDate = approvedDate; } @Column(name="approved_username") public String getApprovedUsername() { return approvedUsername; } public void setApprovedUsername(String approvedUsername) { this.approvedUsername = approvedUsername; } public void setAdvertiser(Advertiser advertiser) { this.advertiser = advertiser; } @OneToMany(mappedBy="ad") public List<Schedule> getSchedules() { return schedules; } public void setSchedules(List<Schedule> schedules) { this.schedules = schedules; } @Transient public boolean isApproved() { return approvedUsername != null && approvedUsername.length() != 0; } @Transient public int getDisplaySeconds() { return displayTime / 1000; } }
        Hide
        Mitesh Meswani added a comment -

        By latest release version, I meant promoted build of GlassFish 3.1 .

        I am assuming that following is being executed in a single EJB method

        Advertiser advertiser = advertiserLocal.find4sure(advertiserId);
        Ad ad = new Ad();
        ad.setName(name);
        ad.setAdvertiser(advertiser);
        ad.setDisplayTime(displayTime);
        ad.setCreatedDate(new Date());
        persist(ad);
        advertiser.getAds().add(ad);
        Collections.sort(advertiser.getAds(), nameOrder);

        Can you try with a data set where Collections.sort(advertiser.getAds(), nameOrder); does result in the newly added ad to be moved withing collection. That might reproduce the issue

        Show
        Mitesh Meswani added a comment - By latest release version, I meant promoted build of GlassFish 3.1 . I am assuming that following is being executed in a single EJB method Advertiser advertiser = advertiserLocal.find4sure(advertiserId); Ad ad = new Ad(); ad.setName(name); ad.setAdvertiser(advertiser); ad.setDisplayTime(displayTime); ad.setCreatedDate(new Date()); persist(ad); advertiser.getAds().add(ad); Collections.sort(advertiser.getAds(), nameOrder); Can you try with a data set where Collections.sort(advertiser.getAds(), nameOrder); does result in the newly added ad to be moved withing collection. That might reproduce the issue
        Hide
        tmpsa added a comment -

        Single EJB? Well, the code snippet is executed in a @stateless EJB. (And it calls another via a @Local interface, as you can see).

        I just ran a little test with data that should cause Collections.sort(...) to re-order the list. Worked fine. No problem.

        Show
        tmpsa added a comment - Single EJB? Well, the code snippet is executed in a @stateless EJB. (And it calls another via a @Local interface, as you can see). I just ran a little test with data that should cause Collections.sort(...) to re-order the list. Worked fine. No problem.

          People

          • Assignee:
            Mitesh Meswani
            Reporter:
            tmpsa
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: