Well, the app is actually a Tapestry 5 app... so maybe there is an
issue with serialization. I will check. However, a few lines before,
I fetched another entity without any trouble.
Now, the DataContext is an attribute of a class I instantiate from a
Tapestry page. The DataContext is simply created doing a new
DataContext(). I would understand the problem if my page was being
serialized and deserialized, but the crash happens during the first
request (actually, it is a page from which I upload an XML file which
will be parsed and data inserted in the database, using a freshly
created DataContext).
But what you are saying is DataContext has a null EntityResolver.
This could come from deserializing a DataContext.
What else could make the DataContext loose the EntityResolver? Is
there one EntityResolver per DataContext or per Entity?
Thanks,
Alex
Le 31 août 07 à 17:40, Andrus Adamchik a écrit :
> The line numbers from 2.0 branch should match:
>
> https://svn.apache.org/repos/asf/cayenne/main/branches/STABLE-2.0/
>
> Looking at the code, it seems to come down to DataContext having a
> null EntityResolver. A random thought - is there a serialization/
> deserialization cycle somewhere in your app, so that the
> DataContext somehow loses its EntityResolver and can't properly
> reattach?
>
> (I almost feel like we should throw an exception early from within
> DataContext.awakeFromDeserialization() if the context failed to
> acquire an EntityResolver).
>
> Andrus
>
> On Aug 31, 2007, at 6:15 PM, Alexander Lamb (dev) wrote:
>
>> Initially, it was a static method to fetch a Patient from the
>> primary key (give the DataContext, the String, returns the Patient
>> or null).
>>
>> Since whatever I was doing would crash Cayenne, I simply tried to
>> do fetch all patients:
>>
>> Here is the function (will all my experiments commented out :-)
>>
>> Oviously, I simply want to fetch a Patient from his key (a varchar
>> of approx. 35 characters).
>>
>> public static Patient patientWithPKInContext(String pk,
>> DataContext dataContext) {
>> //Expression q = ExpressionFactory.matchExp
>> (Patient.BIRTH_CITY_PROPERTY,"Bitola");
>> //Expression q = Expression.fromString("patientPk = '" + pk +
>> "'");
>> // Patient p = (Patient)DataObjectUtils.objectForPK(dataContext,
>> "Patient", pk);
>> //System.out.println("--- found object: " + p);
>> //return p;
>>
>> // System.out.println("EXP:" + q.toString());
>> // SelectQuery s = new SelectQuery(Patient.class,q);
>> // List patients = dataContext.performQuery(s);
>> SelectQuery allPatients = new SelectQuery(Patient.class);
>> List patients = dataContext.performQuery(allPatients);
>>
>> if(patients.size() == 0)
>> return null;
>> else
>> return (Patient)patients.get(0);
>>
>> }
>>
>> Le 31 août 07 à 17:07, Michael Gentry a écrit :
>>
>>> Hi Alex,
>>>
>>> I'm curious as to why:
>>>
>>> at ch.rodano.msbase.model.Patient.patientWithPKInContext
>>> (Patient.java:30)
>>>
>>> is in your stack trace? What does that method do?
>>>
>>> Thanks,
>>>
>>> /dev/mrg
>>>
>>>
>>> On 8/31/07, Alexander Lamb (dev) <alam..ac.com> wrote:
>>>> Hello list,
>>>>
>>>> We are experimenting a Cayenne crash and wondering how to get
>>>> around it.
>>>>
>>>> Here is the place of the crash:
>>>>
>>>> java.lang.NullPointerException
>>>> at org.apache.cayenne.query.BaseQueryMetadata.resolve
>>>> (BaseQueryMetadata.java:97)
>>>> at org.apache.cayenne.query.SelectQuery.getMetaData
>>>> (SelectQuery.java:
>>>> 151)
>>>> at org.apache.cayenne.util.ObjectContextQueryAction.<init>
>>>> (ObjectContextQueryAction.java:69)
>>>> at org.apache.cayenne.access.DataContextQueryAction.<init>
>>>> (DataContextQueryAction.java:46)
>>>> at org.apache.cayenne.access.DataContext.onQuery
>>>> (DataContext.java:1387)
>>>> at org.apache.cayenne.access.DataContext.performQuery
>>>> (DataContext.java:1376)
>>>> at ch.rodano.msbase.model.Patient.patientWithPKInContext
>>>> (Patient.java:30)
>>>>
>>>> I am not certain how to check the line were it crashed (looking at
>>>> the code repository on-line does not probably garantee the line
>>>> number is the same).
>>>>
>>>> We are simply trying to get a list of objects:
>>>>
>>>> SelectQuery allPatients = new SelectQuery(Patient.class);
>>>> List patients = dataContext.performQuery(allPatients);
>>>>
>>>> Probably something is wrong with our model, but what? How to
>>>> find out?
>>>> The only different thing we did (which we did already
>>>> previously) is
>>>> that the primary key for Patient is a varchar (String) and is not
>>>> hidden in the Java Class.
>>>>
>>>> Thanks for any hints (we regenerated everyting, etc... always the
>>>> same crash)
>>>>
>>>> Alex
>>
>
This archive was generated by hypermail 2.0.0 : Sat Sep 01 2007 - 02:51:59 EDT