You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Dibyanshu Jaiswal <dj...@gmail.com> on 2013/12/05 14:44:33 UTC

How to correct com.hp.hpl.jena.rdf.model.HasNoModelException

Hi!

I using JenaParliament for spatial queries.
My application has a need to add spatial data during the runtime as
specified by the user, for that I am trying to use the following peice of
code to create instances acoordingly.


import
com.bbn.parliament.jena.graph.index.spatial.geosparql.datatypes.GeoSPARQLLiteral;
import
com.bbn.parliament.jena.graph.index.spatial.geosparql.datatypes.WKTLiteral;
import com.bbn.parliament.jena.graph.index.spatial.geosparql.vocabulary.*;

Resource oc2 = (Resource) WKT.Type.Point.asResource();
oc2.addProperty(Geo.asWKT, geom, new WKTLiteral());
//geom=lexical input e.g.: "Point(0 0)"

As per this code the Resource gets created and gives a valid URI for
oc2.getURI();
But when the program reaches oc2.addProperty() it gives an exception as
follows:

Exception in thread "main" com.hp.hpl.jena.rdf.model.HasNoModelException:
http://www.opengis.net/ont/sf#Point
    at
com.hp.hpl.jena.rdf.model.impl.ResourceImpl.mustHaveModel(ResourceImpl.java:146)
    at
com.hp.hpl.jena.rdf.model.impl.ResourceImpl.addProperty(ResourceImpl.java:225)
    at geoApi.AddPolygon.addPolygon(AddPolygon.java:55)
    at geoApi.AddPolygon.createPolygon(AddPolygon.java:21)
    at geoApi.geoQuery4rb.main(geoQuery4rb.java:134)


I am unable to figure out any reason for the same. The RDF file used here
same as given in OGC GeoSparql User Guide.

-- 
*Dibyanshu Jaiswal*
Mb: +91 9038304989
Mb: +91 9674272265

Re: How to correct com.hp.hpl.jena.rdf.model.HasNoModelException

Posted by Martynas Jusevičius <ma...@graphity.org>.
This might happen if the Resource object has been created using
ResourceFactory.createResource(), in which case its getModel() returns
null.

Martynas
graphityhq.com

On Thu, Dec 5, 2013 at 2:44 PM, Dibyanshu Jaiswal <dj...@gmail.com> wrote:
> Hi!
>
> I using JenaParliament for spatial queries.
> My application has a need to add spatial data during the runtime as
> specified by the user, for that I am trying to use the following peice of
> code to create instances acoordingly.
>
>
> import
> com.bbn.parliament.jena.graph.index.spatial.geosparql.datatypes.GeoSPARQLLiteral;
> import
> com.bbn.parliament.jena.graph.index.spatial.geosparql.datatypes.WKTLiteral;
> import com.bbn.parliament.jena.graph.index.spatial.geosparql.vocabulary.*;
>
> Resource oc2 = (Resource) WKT.Type.Point.asResource();
> oc2.addProperty(Geo.asWKT, geom, new WKTLiteral());
> //geom=lexical input e.g.: "Point(0 0)"
>
> As per this code the Resource gets created and gives a valid URI for
> oc2.getURI();
> But when the program reaches oc2.addProperty() it gives an exception as
> follows:
>
> Exception in thread "main" com.hp.hpl.jena.rdf.model.HasNoModelException:
> http://www.opengis.net/ont/sf#Point
>     at
> com.hp.hpl.jena.rdf.model.impl.ResourceImpl.mustHaveModel(ResourceImpl.java:146)
>     at
> com.hp.hpl.jena.rdf.model.impl.ResourceImpl.addProperty(ResourceImpl.java:225)
>     at geoApi.AddPolygon.addPolygon(AddPolygon.java:55)
>     at geoApi.AddPolygon.createPolygon(AddPolygon.java:21)
>     at geoApi.geoQuery4rb.main(geoQuery4rb.java:134)
>
>
> I am unable to figure out any reason for the same. The RDF file used here
> same as given in OGC GeoSparql User Guide.
>
> --
> *Dibyanshu Jaiswal*
> Mb: +91 9038304989
> Mb: +91 9674272265