Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » NPE in StoreResource.java:473
NPE in StoreResource.java:473 [message #58482] Fri, 20 October 2006 22:24 Go to next message
Eclipse UserFriend
Originally posted by: sprakash.tibco.com

Hello Martin,

I have a simple HibernateResource with a query, which as I see in my
debugger, Hibernate executes correctly and returns a single result.
However, Teneo NPEs while trying to make a list for the Hibernate
resource. Here is the exception (with some Hibernate debug log prepended):


Creating resource with query string:
hibernate://?dsname=matrix&query1=FROM Enterprise ent LEFT JOIN FETCH
ent.resourceConfigurations r WHERE r.id=11
6189 [main] DEBUG org.hibernate.SQL - select
enterprise0_."simpleeditableentity_id" as id1_1_0_,
resourceco2_."simpleeditableentity_id" as id1_1_1_, enterprise0_2_._vn_ as
column2_1_0_, enterprise0_2_."name" as name3_1_0_,
enterprise0_2_."description" as descript4_1_0_, enterprise0_1_."createdby"
as createdby2_4_0_, enterprise0_1_."modifiedby" as modifiedby3_4_0_,
enterprise0_1_."creationdate" as creation4_4_0_,
enterprise0_1_."modificationdate" as modifica5_4_0_,
enterprise0_."admincluster_id" as adminclu2_36_0_, resourceco2_2_._vn_ as
column2_1_1_, resourceco2_2_."name" as name3_1_1_,
resourceco2_2_."description" as descript4_1_1_, resourceco2_1_."createdby"
as createdby2_4_1_, resourceco2_1_."modifiedby" as modifiedby3_4_1_,
resourceco2_1_."creationdate" as creation4_4_1_,
resourceco2_1_."modificationdate" as modifica5_4_1_, resourceco2_."type"
as type2_55_1_, resourceco2_."contents" as contents3_55_1_,
resourceco2_.econtainer_class as econtainer4_55_1_,
resourceco2_.e_container as e5_55_1_, resourceco2_.e_container_featureid
as e6_55_1_, case when resourceco2_3_."resourceconfiguration_id" is not
null then 22 when resourceco2_."simpleeditableentity_id" is not null then
11 end as clazz_1_, resourceco1_.id as id0__, resourceco1_.elt as elt0__,
resourceco1_."enterprise_resourceconfigurations_idx" as enterprise3_0__
from "enterprise" enterprise0_ inner join "simpleeditableentity"
enterprise0_1_ on
enterprise0_."simpleeditableentity_id"=enterprise0_1_."adminentity_id "
inner join "adminentity" enterprise0_2_ on
enterprise0_."simpleeditableentity_id"=enterprise0_2_."id " left outer join
enterprise_resourceconfiguration resourceco1_ on
enterprise0_."simpleeditableentity_id"=resourceco1_.id left outer join
"resourceconfiguration" resourceco2_ on
resourceco1_.elt=resourceco2_."simpleeditableentity_id" left outer join
"simpleeditableentity" resourceco2_1_ on
resourceco2_."simpleeditableentity_id"=resourceco2_1_."adminentity_id "
left outer join "adminentity" resourceco2_2_ on
resourceco2_."simpleeditableentity_id"=resourceco2_2_."id " left outer join
"servicebustransportconfiguration" resourceco2_3_ on
resourceco2_."simpleeditableentity_id"=resourceco2_3_."resourceconfiguration_id "
where resourceco2_."simpleeditableentity_id"=11
6299 [main] DEBUG org.hibernate.SQL - select adminclust0_.e_id as
e1_86_0_, adminclust0_._vn_ as column2_86_0_, adminclust0_."clustername"
as clustern3_86_0_, adminclust0_.econtainer_class as econtainer4_86_0_,
adminclust0_.e_container as e5_86_0_, adminclust0_.e_container_featureid
as e6_86_0_ from "admincluster" adminclust0_ where adminclust0_.e_id=?
Exception in thread "main" java.lang.NullPointerException
at
org.eclipse.emf.teneo.resource.StoreResource.attachedHelper( StoreResource.java:473)
at
org.eclipse.emf.teneo.resource.StoreResource.attached(StoreR esource.java:425)
at
org.eclipse.emf.teneo.resource.StoreResource.load(StoreResou rce.java:252)

The exception seems to occur because StoreResource.attachedHelper is
handed a null object. This in turn happens because
getNonResolvingContent(eObject).basicIterator() returns an iterator which
has null objects in it. What exactly is getNonResolvingContent(eObject)?
eObject in my case has the real object i.e. the only result that Hibernate
returned.

When I put an NPE check in StoreResource.attachedHelper, everything is
fine. Is this a good enough fix (and should I file a bug report), or is
the problem happening in the first place because of some earlier mistake
on my part?

Thanks much,

Sundeep
Re: NPE in StoreResource.java:473 [message #58484 is a reply to message #58482] Fri, 20 October 2006 22:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sprakash.tibco.com

Sorry, the line numbers are wrong. It should be Line# 467 (that gives the
NPE). Also this is from the build titled I200609141628 (Thu, 14 Sep 2006
-- 16:28 (-0400)). The method doesnt appear to be different even in the
current build:

for (Iterator it = eObject.eClass().getEAllReferences().iterator();
it.hasNext();) {
Re: NPE in StoreResource.java:473 [message #58486 is a reply to message #58484] Sat, 21 October 2006 05:37 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Sundeep,
When an eobject is attached all its children are also attached to a resource. The basicIterator of
getNonResolvingContent(eObject) ensures that lazily loaded elists are not loaded in this step.

The npe you encounter seems to be a bug in the basicIterator (see the method call getFeatureIterator
in StoreResource). I checked and the local implementation of the FeatureIteratorImpl (created in
getFeatureIterator) seems to be misaligned with the implementation in ecore. I have changed this but
do not know if this solves your npe.

Can you enter a bugzilla for this?

I can do a new build. Do you maybe have time/the possibility to test if this new build solves the npe?

gr. Martin

Sundeep Prakash wrote:
> Sorry, the line numbers are wrong. It should be Line# 467 (that gives
> the NPE). Also this is from the build titled I200609141628 (Thu, 14 Sep
> 2006 -- 16:28 (-0400)). The method doesnt appear to be different even in
> the current build:
>
> for (Iterator it = eObject.eClass().getEAllReferences().iterator();
> it.hasNext();) {
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: NPE in StoreResource.java:473 [message #59137 is a reply to message #58486] Tue, 24 October 2006 22:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sprakash.tibco.com

Thanks Martin,
The bug number is 162150. Yes I can check to see if your fix works. Please
let me know which build your fix is in.

Sundeep
Re: NPE in StoreResource.java:473 [message #59799 is a reply to message #59137] Wed, 01 November 2006 06:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sprakash.tibco.com

Martin,
I was told that the latest build (26th Oct) solved this NPE (Bugzilla
162150). But apparently it still does not, in my tests. Do you expect to
be resolving this bug anytime soon?

Thanks,

Sundeep
Re: NPE in StoreResource.java:473 [message #59842 is a reply to message #59799] Wed, 01 November 2006 07:38 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Sundeep,
Well afaics I told you that I was not sure that my changes would solve this issue. Also the bugzilla
is not set to fixed (because I was not sure).

This npe occurs when a new eobject is attached to the resource. The iterator returns null
apparently. The iterator is an innerclass of StoreResource which basically does the same as a
standard EMF iterator.
What you can try is see if the emf iterator also results in a npe (I don't expect this but need to
be sure). To test this you can add the following code to the attached method (in the beginning):
for (Iterator tree = new EContentsEList(eObject).basicIterator(); tree.hasNext();) {
System.err.println(tree.next().getClass().getName());
}


If you want to debug some more. The error can be in the hasNext() method in the featureiterator (see
anonymous class decl. in the StoreResource.getFeatureIterator method). The hasNext returns true
while there is no next (guessing here).
The difference with the standard emf implementation is in this piece of code:
if (feature.isMany()) {
Object value = eObject.eGet(feature, resolve());
if (value instanceof PersistableDelegateList
&& !((PersistableDelegateList) value).isLoaded()) {
continue;
}
if (value instanceof PersistableEMap && !((PersistableEMap) value).isLoaded()) {
continue;
}
}

If you have a reproducable test case/model which you provide then you can also send that to me so I
can try it out.

gr. Martin

Sundeep Prakash wrote:
> Martin,
> I was told that the latest build (26th Oct) solved this NPE (Bugzilla
> 162150). But apparently it still does not, in my tests. Do you expect to
> be resolving this bug anytime soon?
>
> Thanks,
>
> Sundeep
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: NPE in StoreResource.java:473 [message #594521 is a reply to message #58482] Fri, 20 October 2006 22:53 Go to previous message
Sundeep Prakash is currently offline Sundeep PrakashFriend
Messages: 14
Registered: July 2009
Junior Member
Sorry, the line numbers are wrong. It should be Line# 467 (that gives the
NPE). Also this is from the build titled I200609141628 (Thu, 14 Sep 2006
-- 16:28 (-0400)). The method doesnt appear to be different even in the
current build:

for (Iterator it = eObject.eClass().getEAllReferences().iterator();
it.hasNext();) {
Re: NPE in StoreResource.java:473 [message #594530 is a reply to message #58484] Sat, 21 October 2006 05:37 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Sundeep,
When an eobject is attached all its children are also attached to a resource. The basicIterator of
getNonResolvingContent(eObject) ensures that lazily loaded elists are not loaded in this step.

The npe you encounter seems to be a bug in the basicIterator (see the method call getFeatureIterator
in StoreResource). I checked and the local implementation of the FeatureIteratorImpl (created in
getFeatureIterator) seems to be misaligned with the implementation in ecore. I have changed this but
do not know if this solves your npe.

Can you enter a bugzilla for this?

I can do a new build. Do you maybe have time/the possibility to test if this new build solves the npe?

gr. Martin

Sundeep Prakash wrote:
> Sorry, the line numbers are wrong. It should be Line# 467 (that gives
> the NPE). Also this is from the build titled I200609141628 (Thu, 14 Sep
> 2006 -- 16:28 (-0400)). The method doesnt appear to be different even in
> the current build:
>
> for (Iterator it = eObject.eClass().getEAllReferences().iterator();
> it.hasNext();) {
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: NPE in StoreResource.java:473 [message #594770 is a reply to message #58486] Tue, 24 October 2006 22:20 Go to previous message
Sundeep Prakash is currently offline Sundeep PrakashFriend
Messages: 14
Registered: July 2009
Junior Member
Thanks Martin,
The bug number is 162150. Yes I can check to see if your fix works. Please
let me know which build your fix is in.

Sundeep
Re: NPE in StoreResource.java:473 [message #595055 is a reply to message #59137] Wed, 01 November 2006 06:29 Go to previous message
Sundeep Prakash is currently offline Sundeep PrakashFriend
Messages: 14
Registered: July 2009
Junior Member
Martin,
I was told that the latest build (26th Oct) solved this NPE (Bugzilla
162150). But apparently it still does not, in my tests. Do you expect to
be resolving this bug anytime soon?

Thanks,

Sundeep
Re: NPE in StoreResource.java:473 [message #595066 is a reply to message #59799] Wed, 01 November 2006 07:38 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Sundeep,
Well afaics I told you that I was not sure that my changes would solve this issue. Also the bugzilla
is not set to fixed (because I was not sure).

This npe occurs when a new eobject is attached to the resource. The iterator returns null
apparently. The iterator is an innerclass of StoreResource which basically does the same as a
standard EMF iterator.
What you can try is see if the emf iterator also results in a npe (I don't expect this but need to
be sure). To test this you can add the following code to the attached method (in the beginning):
for (Iterator tree = new EContentsEList(eObject).basicIterator(); tree.hasNext();) {
System.err.println(tree.next().getClass().getName());
}


If you want to debug some more. The error can be in the hasNext() method in the featureiterator (see
anonymous class decl. in the StoreResource.getFeatureIterator method). The hasNext returns true
while there is no next (guessing here).
The difference with the standard emf implementation is in this piece of code:
if (feature.isMany()) {
Object value = eObject.eGet(feature, resolve());
if (value instanceof PersistableDelegateList
&& !((PersistableDelegateList) value).isLoaded()) {
continue;
}
if (value instanceof PersistableEMap && !((PersistableEMap) value).isLoaded()) {
continue;
}
}

If you have a reproducable test case/model which you provide then you can also send that to me so I
can try it out.

gr. Martin

Sundeep Prakash wrote:
> Martin,
> I was told that the latest build (26th Oct) solved this NPE (Bugzilla
> 162150). But apparently it still does not, in my tests. Do you expect to
> be resolving this bug anytime soon?
>
> Thanks,
>
> Sundeep
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:EODM tutorial
Next Topic:Teneo : persistence of objects URI
Goto Forum:
  


Current Time: Thu Apr 25 10:41:48 GMT 2024

Powered by FUDForum. Page generated in 0.04484 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top