我编写了一个将数据转换为RDF的函数,我需要将此RDF上传到fuseki服务器。
我尝试从here实现代码,如下所示
public class GenerateRDF {
public void setRDF(String[] personalData ) {
String serviceURI = "http://localhost:3030/Date";
DatasetAccessorFactory factory = null;
DatasetAccessor accessor;
accessor = factory.createHTTP(serviceURI);
String name = personalData[0];
String nationality = personalData[1];
String date = personalData[2];
String address = personalData[3];
String mobile = personalData[4];
String email = personalData[5];
String website = personalData[6];
String profesional = personalData[7];
String education = personalData[8];
String communication = personalData[9];
String digital = personalData[10];
String professional = personalData[11];
String management = personalData[12];
String certifications = personalData[13];
InputStream in = null;
Model model = ModelFactory.createDefaultModel();
Resource node = model.createResource(personURI)
.addProperty(FOAF.name, name)
.addProperty(FOAF.member, nationality)
.addProperty(FOAF.birthday, date)
.addProperty(FOAF.homepage, address)
.addProperty(FOAF.phone, mobile)
.addProperty(FOAF.yahooChatID, email)
.addProperty(FOAF.weblog, website)
.addProperty(FOAF.plan, profesional)
.addProperty(FOAF.knows, education)
.addProperty(FOAF.depiction, communication)
.addProperty(FOAF.interest, digital)
.addProperty(FOAF.publications, professional)
.addProperty(FOAF.maker, management)
.addProperty(FOAF.made, certifications);
String base = "http://test-projects.com/";
model.read(in, base, "RDF/XML");
accessor.putModel(model);
model.write(System.out);
}
}
返回以下异常:
线程中的异常" AWT-EventQueue-0"显示java.lang.NullPointerException at java.io.FilterInputStream.read(Unknown Source) at org.apache.xerces.impl.XMLEntityManager $ RewindableInputStream.readAndBuffer(Unknown Source) 在org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(未知来源) at org.apache.xerces.impl.XMLEntityManager.startEntity(未知来源) at org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(未知来源) at org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(Unknown Source) 在org.apache.xerces.parsers.DTDConfiguration.parse(未知来源) 在org.apache.xerces.parsers.DTDConfiguration.parse(未知来源) 在org.apache.xerces.parsers.XMLParser.parse(未知来源) 在org.apache.xerces.parsers.AbstractSAXParser.parse(未知来源) 在com.hp.hpl.jena.rdf.arp.impl.RDFXMLParser.parse(RDFXMLParser.java:151) 在com.hp.hpl.jena.rdf.arp.ARP.load(ARP.java:119) 在org.apache.jena.riot.lang.LangRDFXML.parse(LangRDFXML.java:142) at org.apache.jena.riot.RDFParserRegistry $ ReaderRIOTFactoryImpl $ 1.read(RDFParserRegistry.java:142) 在org.apache.jena.riot.RDFDataMgr.process(RDFDataMgr.java:760) 在org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:258) 在org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:244) 在org.apache.jena.riot.adapters.RDFReaderRIOT.read(RDFReaderRIOT.java:69) 在com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:274) 在GenerateRDF.setRDF(GenerateRDF.java:59) 在PersonalInfo $ 2.actionPerformed(PersonalInfo.java:251) 在javax.swing.AbstractButton.fireActionPerformed(未知来源) at javax.swing.AbstractButton $ Handler.actionPerformed(Unknown Source) 在javax.swing.DefaultButtonModel.fireActionPerformed(未知来源) 在javax.swing.DefaultButtonModel.setPressed(未知来源) 在javax.swing.plaf.basic.BasicButtonListener.mouseReleased(未知来源) at java.awt.Component.processMouseEvent(Unknown Source) 在javax.swing.JComponent.processMouseEvent(未知来源) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) 在java.awt.EventQueue.access $ 500(未知来源) 在java.awt.EventQueue $ 3.run(未知来源) 在java.awt.EventQueue $ 3.run(未知来源) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain $ JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain $ JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) 在java.awt.EventQueue $ 4.run(未知来源) 在java.awt.EventQueue $ 4.run(未知来源) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain $ JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 在java.awt.EventDispatchThread.run(未知来源)
有没有办法解决这个错误?我对解决方案持开放态度......
答案 0 :(得分:0)
您可能需要查看此处:https://hub.docker.com/r/stain/jena-fuseki/
数据加载有一部分可以指导您。
更具体地说,可以在此处找到load.sh和tdbloader:https://github.com/stain/jena-docker/tree/master/jena-fuseki
当你提到“将文件上传到fuseki”但你的代码没有引用任何文件时,我对你的问题感到有些困惑......