You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Rice Yeh <ri...@gmail.com> on 2011/01/21 09:46:50 UTC

java.lang.reflect.Field.getValue() does not work in OSGi environment

Hi,
  I meet a problem that looks quite weird for me. I report it here to see
whether people have similar experience.

  In hibernate, there is a class
org.hibernate.property.DirectPropertyAccessor$DirectGetter, which is used to
directly access a field's value of a domain class. I find this function
fails in osgi environemt because java.lang.reflect.Field.getValue() throws
IllegalArgumentException, which never happen in non-osgi environment.  I
conjecture that this exception has something to do with classloaders. But I
cannot really figure it out.  The following is the exception trace.

caused by: java.lang.IllegalArgumentException: Can not set java.lang.Object
field as.classifier.Classifier.oid to xs.personnel.Citizen$Identity$Type
    at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
    at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
    at
sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37)
    at
sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18)
    at java.lang.reflect.Field.get(Field.java:358)
    at
org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:55)


Rice

Re: java.lang.reflect.Field.getValue() does not work in OSGi environment

Posted by Rice Yeh <ri...@gmail.com>.
Yes, you are right. I just do not import a package because the package is
not in the import statements of the java file and hence bnd does not have it
included in the MANIFEST.MF. Thanks.

Rice



On Fri, Jan 21, 2011 at 5:10 PM, niibasta@gmail.com <ni...@gmail.com>wrote:

>  Hello!
>
> Do you have "Export-Package:  xs.personnel" in your bundle?
>
>
> On 21.01.2011 11:46, Rice Yeh wrote:
>
>> Hi,
>>   I meet a problem that looks quite weird for me. I report it here to see
>> whether people have similar experience.
>>
>>   In hibernate, there is a class
>> org.hibernate.property.DirectPropertyAccessor$DirectGetter, which is used
>> to
>> directly access a field's value of a domain class. I find this function
>> fails in osgi environemt because java.lang.reflect.Field.getValue() throws
>> IllegalArgumentException, which never happen in non-osgi environment.  I
>> conjecture that this exception has something to do with classloaders. But
>> I
>> cannot really figure it out.  The following is the exception trace.
>>
>> caused by: java.lang.IllegalArgumentException: Can not set
>> java.lang.Object
>> field as.classifier.Classifier.oid to xs.personnel.Citizen$Identity$Type
>>     at
>>
>> sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
>>     at
>>
>> sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
>>     at
>>
>> sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37)
>>     at
>>
>> sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18)
>>     at java.lang.reflect.Field.get(Field.java:358)
>>     at
>>
>> org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:55)
>>
>>
>> Rice
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: java.lang.reflect.Field.getValue() does not work in OSGi environment

Posted by "niibasta@gmail.com" <ni...@gmail.com>.
  Hello!

Do you have "Export-Package:  xs.personnel" in your bundle?

On 21.01.2011 11:46, Rice Yeh wrote:
> Hi,
>    I meet a problem that looks quite weird for me. I report it here to see
> whether people have similar experience.
>
>    In hibernate, there is a class
> org.hibernate.property.DirectPropertyAccessor$DirectGetter, which is used to
> directly access a field's value of a domain class. I find this function
> fails in osgi environemt because java.lang.reflect.Field.getValue() throws
> IllegalArgumentException, which never happen in non-osgi environment.  I
> conjecture that this exception has something to do with classloaders. But I
> cannot really figure it out.  The following is the exception trace.
>
> caused by: java.lang.IllegalArgumentException: Can not set java.lang.Object
> field as.classifier.Classifier.oid to xs.personnel.Citizen$Identity$Type
>      at
> sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
>      at
> sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
>      at
> sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37)
>      at
> sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18)
>      at java.lang.reflect.Field.get(Field.java:358)
>      at
> org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:55)
>
>
> Rice
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org