xiedaode / jenabean

Automatically exported from code.google.com/p/jenabean
0 stars 0 forks source link

NullPointerException upon Bean2RDF.saveDeep(myBean) #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. trying to save my Jenabean class to RDF
2.
3.

What is the expected output? What do you see instead?
I expect it to save to Jena database, as my other Jenabean classes have

Please use labels and text to provide additional information.
I get this error.  It seems to be a problem with my Jenabean class.  Not
sure what I am doing wrong.  Can you figure what would cause this
NullPointerException?  My Jenabean class does have a lot of null values but
that shouldn't matter.  It has a proper
@Namespace("http://inqle.org/ns/v1/") declaration.  My getId() method
produces a string value and my Jenabean is of the expected class.  It
receives the @Id attribute through a superclass.  This has worked for me in
the past.  Thanks if anything springs to mind.

java.lang.NullPointerException
        at thewebsemantic.TypeWrapper.getAnnotation(TypeWrapper.java:122)
        at thewebsemantic.TypeWrapper.uri(TypeWrapper.java:117)
        at thewebsemantic.PropertyContext.uri(PropertyContext.java:26)
        at
thewebsemantic.PropertyContext.existsInModel(PropertyContext.java:46)
        at thewebsemantic.Base.toRdfProperty(Base.java:37)
        at thewebsemantic.Bean2RDF.saveOrUpdate(Bean2RDF.java:167)
        at thewebsemantic.Bean2RDF.write(Bean2RDF.java:161)
        at thewebsemantic.Bean2RDF._write(Bean2RDF.java:120)
        at thewebsemantic.Bean2RDF.write(Bean2RDF.java:113)
        at thewebsemantic.Bean2RDF.saveDeep(Bean2RDF.java:99)
        at
org.inqle.data.rdf.jenabean.JenabeanWriter.toString(JenabeanWriter.java:19)

Original issue reported on code.google.com by drdono...@gmail.com on 1 Mar 2008 at 4:06

GoogleCodeExporter commented 9 years ago
I did some testing and I isolated the offending method to this one

public void setPersister(Persister persister)

When I comment this method out, the NullPointerException goes away, and
Bean2RDF.saveDeep(myBean) works properly

So this Persister class is not a Jenabean, and not intended to be saved.  

Is this a bug?  Should Jenabean ignore fields that it cannot handle?  Or is 
there a
way to annotate the persister field and the setPersister() method to make 
Jenabean
ignore it?

Original comment by drdono...@gmail.com on 1 Mar 2008 at 2:03

GoogleCodeExporter commented 9 years ago
>Should Jenabean ignore fields that it cannot handle?  
Yes, it really should.  It's just a matter of indicated which ones they are.

We can do several things...annotation based @ignore, use the java feature of 
marking
the field as "transient", or only save properties that are "serializable", or 
only
persist fields that are annotated with @RdfProperty.  

Original comment by thewebse...@gmail.com on 4 Mar 2008 at 3:53

GoogleCodeExporter commented 9 years ago

Original comment by thewebse...@gmail.com on 4 Mar 2008 at 3:54

GoogleCodeExporter commented 9 years ago

Original comment by thewebse...@gmail.com on 6 Nov 2008 at 4:20