Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Package with uri 'null' not found ERROR(An error occured while i was reading a XML file into SymptomDatabase)
Package with uri 'null' not found ERROR [message #550646] Wed, 04 August 2010 02:54 Go to next message
No real name is currently offline No real nameFriend
Messages: 5
Registered: August 2010
Junior Member
My code is as below:

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
//import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
import org.eclipse.emf.ecore.xmi.impl.*;

import org.eclipse.hyades.models.symptom.SymptomPackage;
import org.eclipse.hyades.models.symptom.impl.*;

public class hello{
public static void main(String arg[]){

ResourceSet resourceSet = new ResourceSetImpl();

Resource.Factory.Registry registry = resourceSet.getResourceFactoryRegistry();
registry.getExtensionToFactoryMap().put("xml", new XMLResourceFactoryImpl());

SymptomPackage symPack = SymptomPackageImpl.init();
System.out.println(symPack.eNS_URI);
System.out.println(symPack.eINSTANCE);

EPackage.Registry reg = resourceSet.getPackageRegistry();
reg.put(symPack.getNsURI(), symPack);
System.out.println(symPack.getNsURI());

resourceSet.getResource(URI.createFileURI("d:\\symptomdb.xml "), true);
}
}

The error message is as below:

Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'null' not found. (file:/d:/symptomdb.xml, 52, 18)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDe mandLoadException(ResourceSetImpl.java:315)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:274)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
at eclipseworld.tutorial.demo.analysis.engine.DemoSymptomDataba se.loadDatabase(DemoSymptomDatabase.java:329)
at eclipseworld.tutorial.demo.analysis.engine.DemoSymptomDataba se.merge(DemoSymptomDatabase.java:127)
at eclipseworld.tutorial.demo.analysis.engine.DemoSymptomDataba se.main(DemoSymptomDatabase.java:74)
Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'null' not found. (file:/d:/symptomdb.xml, 52, 18)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1307)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1468)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1019)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unk nown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unkn own Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanSt artElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatc her.scanRootElementHook(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$Fragme ntContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDo cument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1494)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1282)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
... 4 more

The XML file is as below:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE symptomDatabase [

<!ELEMENT symptomDatabase (runtime+)>

<!ELEMENT runtime (symptom+ , solution+ , directive*)>
<!ATTLIST runtime
id ID #REQUIRED
name CDATA #IMPLIED
symptomUrl CDATA #IMPLIED
localExternalFileLocation CDATA #IMPLIED>

<!ELEMENT symptom (matchPattern+)>
<!ATTLIST symptom
id ID #REQUIRED
description CDATA #IMPLIED
solutions IDREFS #REQUIRED>

<!ELEMENT matchPattern EMPTY>
<!ATTLIST matchPattern
name CDATA #IMPLIED
value CDATA #REQUIRED>

<!ELEMENT solution EMPTY>
<!ATTLIST solution
id ID #REQUIRED
description CDATA #IMPLIED
directives IDREFS #IMPLIED>

<!ELEMENT directive EMPTY>
<!ATTLIST directive
id ID #REQUIRED
description CDATA #IMPLIED
directiveString CDATA #REQUIRED>
]>

<!-- Created on Thursday, December 09, 2004 at 9:00:53:0315 PM EST -->

<!-- NOTE: Do not translate any content in this XML file. -->

<symptomDatabase>
<runtime id="Runtime_0" name="symptomDB" symptomUrl="http://www.eclipse.org" localExternalFileLocation="www.eclipse.org">

<!-- Symptoms: -->

<symptom id="Symptom_0" description="Could not determine server name" solutions="Solution_0">
<matchPattern name="null" value="httpd: Could not determine the server&apos;s fully qualified domain name"/>
</symptom>
<symptom id="Symptom_1" description="File does not exist" solutions="Solution_1">
<matchPattern name="null" value="File does not exist:"/>
</symptom>

<!-- Solutions: -->

<solution id="Solution_0" description="Add Severname &apos;servername&apos; to httpd.conf and enter the&#xD;&#xA;corresponding entry for &apos;servername&apos; in /etc/hosts file.&#xD;&#xA;&#xD;&#xA;Where &apos;servername&apos; is the name of your server." />
<solution id="Solution_1" description="Try reinstalling the apache server." directives="Directive_0"/>

<!-- Directives: -->

<directive id="Directive_0" description="Contact your local administrator." directiveString=""/>
</runtime>
</symptomDatabase>
Re: Package with uri 'null' not found ERROR [message #550647 is a reply to message #550646] Wed, 04 August 2010 02:56 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 5
Registered: August 2010
Junior Member
Why the package is with "null" uri? Where should i change the uri value? How can i fix the error?

[Updated on: Wed, 04 August 2010 07:50]

Report message to a moderator

Re: Package with uri 'null' not found ERROR [message #550873 is a reply to message #550646] Wed, 04 August 2010 13:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
It's highly likely that the Symptom package has a specialized resource
factory Impl that you'll need to register.


jobsheng@gmail.com wrote:
> My code is as below:
>
> import org.eclipse.emf.common.util.URI;
> import org.eclipse.emf.ecore.EPackage;
> import org.eclipse.emf.ecore.resource.Resource;
> import org.eclipse.emf.ecore.resource.ResourceSet;
> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
> //import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
> import org.eclipse.emf.ecore.xmi.impl.*;
>
> import org.eclipse.hyades.models.symptom.SymptomPackage;
> import org.eclipse.hyades.models.symptom.impl.*;
>
> public class hello{
> public static void main(String arg[]){
>
> ResourceSet resourceSet = new ResourceSetImpl();
> Resource.Factory.Registry registry =
> resourceSet.getResourceFactoryRegistry();
> registry.getExtensionToFactoryMap().put("xml", new
> XMLResourceFactoryImpl());
>
> SymptomPackage symPack = SymptomPackageImpl.init();
> System.out.println(symPack.eNS_URI);
> System.out.println(symPack.eINSTANCE);
> EPackage.Registry reg = resourceSet.getPackageRegistry();
> reg.put(symPack.getNsURI(), symPack);
> System.out.println(symPack.getNsURI());
>
> resourceSet.getResource(URI.createFileURI("d:\\symptomdb.xml "), true);
> }
> }
>
> The error message is as below:
>
> Exception in thread "main"
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos
> ticWrappedException:
> org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri
> 'null' not found. (file:/d:/symptomdb.xml, 52, 18)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDe
> mandLoadException(ResourceSetImpl.java:315)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo
> adHelper(ResourceSetImpl.java:274)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou
> rce(ResourceSetImpl.java:397)
> at eclipseworld.tutorial.demo.analysis.engine.DemoSymptomDataba
> se.loadDatabase(DemoSymptomDatabase.java:329)
> at eclipseworld.tutorial.demo.analysis.engine.DemoSymptomDataba
> se.merge(DemoSymptomDatabase.java:127)
> at eclipseworld.tutorial.demo.analysis.engine.DemoSymptomDataba
> se.main(DemoSymptomDatabase.java:74)
> Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package
> with uri 'null' not found. (file:/d:/symptomdb.xml, 52, 18)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType
> (XMLHandler.java:1307)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM
> LHandler.java:1468)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML
> Handler.java:1019)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa
> ndler.java:1001)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa
> ndler.java:712)
> at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unk
> nown Source)
> at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unkn
> own Source)
> at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanSt
> artElement(Unknown Source)
> at org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatc
> her.scanRootElementHook(Unknown Source)
> at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$Fragme
> ntContentDispatcher.dispatch(Unknown Source)
> at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDo
> cument(Unknown Source)
> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
> at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.
> java:181)
> at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes
> ourceImpl.java:180)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour
> ceImpl.java:1494)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour
> ceImpl.java:1282)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo
> ad(ResourceSetImpl.java:255)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo
> adHelper(ResourceSetImpl.java:270)
> ... 4 more
>
> The XML file is as below:
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!DOCTYPE symptomDatabase [
>
> <!ELEMENT symptomDatabase (runtime+)>
>
> <!ELEMENT runtime (symptom+ , solution+ , directive*)>
> <!ATTLIST runtime
> id ID #REQUIRED
> name CDATA #IMPLIED
> symptomUrl CDATA #IMPLIED
> localExternalFileLocation CDATA #IMPLIED>
>
> <!ELEMENT symptom (matchPattern+)>
> <!ATTLIST symptom
> id ID #REQUIRED
> description CDATA #IMPLIED
> solutions IDREFS #REQUIRED>
>
> <!ELEMENT matchPattern EMPTY>
> <!ATTLIST matchPattern
> name CDATA #IMPLIED
> value CDATA #REQUIRED>
>
> <!ELEMENT solution EMPTY>
> <!ATTLIST solution
> id ID #REQUIRED
> description CDATA #IMPLIED
> directives IDREFS #IMPLIED>
>
> <!ELEMENT directive EMPTY>
> <!ATTLIST directive
> id ID #REQUIRED
> description CDATA #IMPLIED
> directiveString CDATA #REQUIRED>
> ]>
>
> <!-- Created on Thursday, December 09, 2004 at 9:00:53:0315 PM EST -->
>
> <!-- NOTE: Do not translate any content in this XML file. -->
>
> <symptomDatabase>
> <runtime id="Runtime_0" name="symptomDB"
> symptomUrl="http://www.eclipse.org"
> localExternalFileLocation="www.eclipse.org">
> <!-- Symptoms: -->
> <symptom id="Symptom_0" description="Could not
> determine server name" solutions="Solution_0">
> <matchPattern name="null" value="httpd: Could not determine
> the server&apos;s fully qualified domain name"/>
> </symptom> <symptom id="Symptom_1" description="File
> does not exist" solutions="Solution_1">
> <matchPattern name="null" value="File does not
> exist:"/> </symptom>
>
> <!-- Solutions: -->
> <solution id="Solution_0" description="Add Severname
> &apos;servername&apos; to httpd.conf and enter the
> corresponding entry for &apos;servername&apos; in /etc/hosts file.
>
> Where &apos;servername&apos; is the name of your server." />
> <solution id="Solution_1" description="Try reinstalling the
> apache server." directives="Directive_0"/>
> <!-- Directives: -->
>
> <directive id="Directive_0" description="Contact your local
> administrator." directiveString=""/>
> </runtime>
> </symptomDatabase>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Package with uri 'null' not found ERROR [message #550875 is a reply to message #550647] Wed, 04 August 2010 13:42 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
The namespace of the root element is null, so the resource
implementation you've registered will look for a package registered for
the null nsURI. That's why I expect there's a specialized resource
factory you'll need to use. If you can't find it, ask on the TPTP
newsgroup where it is.


jobsheng@gmail.com wrote:
> Why the package is with "null" uri? How can i fix the error?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Package with uri 'null' not found ERROR [message #551048 is a reply to message #550873] Thu, 05 August 2010 02:34 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 5
Registered: August 2010
Junior Member
Thanks for your help. But still i don't know where and how to register a factory. I printed the nsURI out, it shows:nsURI: http://www.eclipse.org/hyades/models/symptom1_0
Why in the error message it shows:uri:"NULL"? I post the problem in TPTP board for more help.

[Updated on: Thu, 05 August 2010 02:38]

Report message to a moderator

Re: Package with uri 'null' not found ERROR [message #551050 is a reply to message #551048] Thu, 05 August 2010 02:50 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
You've read the overview articles and you've looked at the FAQ?

jobsheng@gmail.com wrote:
> Thanks for your help. But still i don't know where and how to register
> a factory.a


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Package with uri 'null' not found ERROR [message #551053 is a reply to message #551050] Thu, 05 August 2010 03:14 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 5
Registered: August 2010
Junior Member
Yes,after reading the FAQ, i added the code below to register the package:
> SymptomPackage symPack = SymptomPackageImpl.init();
> System.out.println(symPack.eNS_URI);
> System.out.println(symPack.eINSTANCE);
> EPackage.Registry reg = resourceSet.getPackageRegistry();
> reg.put(symPack.getNsURI(), symPack)

Maybe i didn't quite understand it?

Re: Package with uri 'null' not found ERROR [message #551174 is a reply to message #551053] Thu, 05 August 2010 13:46 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030908020701060907050504
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

You need to find the resource factory implementation that Hyades uses to
load. If you're writing a stand alone application, you'll want to read
this and take note that I've mentioned several times the need to
register the correct resource factory.

2.16 How do I use EMF in standalone applications (such as an
ordinary main)?
< http://wiki.eclipse.org/index.php/EMF/FAQ#How_do_I_use_EMF_i n_standalone_applications_.28such_as_an_ordinary_main.29.3F>


jobsheng@gmail.com wrote:
> Yes,after reading the FAQ, i added the code below to register the
> package:
>> SymptomPackage symPack = SymptomPackageImpl.init();
>> System.out.println(symPack.eNS_URI);
>> System.out.println(symPack.eINSTANCE);
>> EPackage.Registry reg = resourceSet.getPackageRegistry();
>> reg.put(symPack.getNsURI(), symPack)
>
> Maybe i didn't quite understand it?
>
>

--------------030908020701060907050504
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
You need to find the resource factory implementation that Hyades uses
to load.  If you're writing a stand alone application, you'll want to
read this and take note that I've mentioned several times the need to
register the correct resource factory.<br>
<blockquote><a
href=" http://wiki.eclipse.org/index.php/EMF/FAQ#How_do_I_use_EMF_i n_standalone_applications_.28such_as_an_ordinary_main.29.3F"><span
class="tocnumber">2.16</span> <span class="toctext">How do I use EMF
in standalone applications (such as an ordinary main)?</span></a><br>
</blockquote>
<br>
<a class="moz-txt-link-abbreviated" href="mailto:jobsheng@gmail.com">jobsheng@gmail.com</a> wrote:
<blockquote cite="mid:i3daba$ssu$1@build.eclipse.org" type="cite">Yes,after
reading the FAQ, i added the code below to register the package:
<br>
<blockquote type="cite">SymptomPackage symPack =
SymptomPackageImpl.init(); System.out.println(symPack.eNS_URI);
<br>
System.out.println(symPack.eINSTANCE);
<br>
EPackage.Registry reg = resourceSet.getPackageRegistry();
<br>
reg.put(symPack.getNsURI(), symPack)
<br>
</blockquote>
<br>
Maybe i didn't quite understand it?
<br>
<br>
<br>
</blockquote>
</body>
</html>

--------------030908020701060907050504--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Model Importer Implementation
Next Topic:[EMF] Create a model instance from a DynamicEObject
Goto Forum:
  


Current Time: Thu Mar 28 11:29:29 GMT 2024

Powered by FUDForum. Page generated in 0.07840 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top