Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Please help me: Parse failed: ERROR in (packageDeclarationCS): (Unable to find package: ( uml))
Please help me: Parse failed: ERROR in (packageDeclarationCS): (Unable to find package: ( uml)) [message #35641] Mon, 20 August 2007 09:57 Go to next message
Eclipse UserFriend
Originally posted by: dh_eclipseng.hellekalek.com

Hello,

I am working on a web application that evaluates OCL statements on UML
models. Unfortunately, I always get this error:
Parse failed: ERROR in (packageDeclarationCS): (Unable to find package: (
uml))
It works fine in eclipse, and I put all the EMF/OCL/UML2 plugin files in the
web application's classpath and don't get any "Class not found" problems.

The top part of the stacktrace:
org.eclipse.ocl.SemanticException: ERROR in (packageDeclarationCS): (Unable
to find package: ( uml))
at org.eclipse.ocl.internal.parser.OCLParser.ERR(OCLParser.java :596)
at org.eclipse.ocl.internal.parser.OCLParser.ERROR(OCLParser.ja va:605)
at
org.eclipse.ocl.internal.parser.OCLParser.packageDeclaration CS(OCLParser.java:1085)
at
org.eclipse.ocl.internal.parser.OCLParser.parsePackageDeclar ationCS(OCLParser.java:822)
at org.eclipse.ocl.OCL.parse(OCL.java:243)
....

I think it is caused because "env =
environmentFactory.createPackageContext(environment, pathname);" is null in
OCLParser.packageDeclarationCS.
In "EcoreEnvironment" there is a function "findPackage" that seems to get
called and does not find the package uml, this seems to be the "real root
cause" (due to that, env is null, and due to that, OCLParser throws an
Exception)

Unfortunately, this is where I started to fail to continue. I don't know
what I would have to change to make "findPackage" succeed.

The OCL define starts like this:
package uml context Class
....

I use this function for the settings:
private void loadModules()
{
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
UMLPackage.eINSTANCE);
Map extensionToFactoryMap =
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap();
extensionToFactoryMap.put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);
extensionToFactoryMap.put("ecore", new EcoreResourceFactoryImpl());
extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_ EXTENSION, new
XMIResourceFactoryImpl());
}

If you can help me by pointing out possible causes and solutions, or giving
me ideas what to try, I would really appreciate it.

Best regards,
David Hellekalek
Re: Please help me: Parse failed: ERROR in (packageDeclarationCS): (Unable to find package: ( uml)) [message #35675 is a reply to message #35641] Mon, 20 August 2007 15:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, David,

If you are using the UML environment implementation
(org.eclipse.ocl.uml.OCL), then you will additionally need to make other
resources available to the parser at run-time, most especially the UML
representation of the UML metamodel (UML.metamodel.uml, not UML.ecore).
This is what the package look-up is actually looking for.

You mentioned the EcoreEnvironment class in your post, so perhaps this isn't
quite your problem, but other resources are needed.

You can find an example of stand-alone (Eclipse-free) parsing that works in
the OCL CVS repository: check out the org.eclipse.ocl.standalone.tests
project from the

/cvsroot/modeling/org.eclipse.mdt/org.eclipse.ocl/tests

module. This project uses PDE only to assemble the classpath.

There is one class in this project, "AllTests", that runs the OCL Ecore,
UML, and 1.0 compatibility test suites in an Eclipse-free runtime
environment. The static initializer of the AllTests class sets up package
registrations (including a compatibility for UML 2.0.0 namespace), URI
mappings, and much else. Have a look in there for ideas of what you might
be missing.

HTH,

Christian


David Hellekalek wrote:

> Hello,
>
> I am working on a web application that evaluates OCL statements on UML
> models. Unfortunately, I always get this error:
> Parse failed: ERROR in (packageDeclarationCS): (Unable to find package: (
> uml))
> It works fine in eclipse, and I put all the EMF/OCL/UML2 plugin files in
> the web application's classpath and don't get any "Class not found"
> problems.
>
> The top part of the stacktrace:
> org.eclipse.ocl.SemanticException: ERROR in (packageDeclarationCS):
> (Unable to find package: ( uml))
> at org.eclipse.ocl.internal.parser.OCLParser.ERR(OCLParser.java :596)
> at org.eclipse.ocl.internal.parser.OCLParser.ERROR(OCLParser.ja va:605)
> at
>
org.eclipse.ocl.internal.parser.OCLParser.packageDeclaration CS(OCLParser.java:1085)
> at
>
org.eclipse.ocl.internal.parser.OCLParser.parsePackageDeclar ationCS(OCLParser.java:822)
> at org.eclipse.ocl.OCL.parse(OCL.java:243)
> ...
>
> I think it is caused because "env =
> environmentFactory.createPackageContext(environment, pathname);" is null
> in OCLParser.packageDeclarationCS.
> In "EcoreEnvironment" there is a function "findPackage" that seems to get
> called and does not find the package uml, this seems to be the "real root
> cause" (due to that, env is null, and due to that, OCLParser throws an
> Exception)
>
> Unfortunately, this is where I started to fail to continue. I don't know
> what I would have to change to make "findPackage" succeed.
>
> The OCL define starts like this:
> package uml context Class
> ...
>
> I use this function for the settings:
> private void loadModules()
> {
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
> UMLPackage.eINSTANCE);
> Map extensionToFactoryMap =
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap();
> extensionToFactoryMap.put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
> extensionToFactoryMap.put("ecore", new EcoreResourceFactoryImpl());
> extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_ EXTENSION, new
> XMIResourceFactoryImpl());
> }
>
> If you can help me by pointing out possible causes and solutions, or
> giving me ideas what to try, I would really appreciate it.
>
> Best regards,
> David Hellekalek
Re: Please help me: Parse failed: ERROR in (packageDeclarationCS): (Unable to find package: ( uml)) [message #35775 is a reply to message #35675] Tue, 21 August 2007 20:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dh_eclipseng.hellekalek.com

Hello Christian,

Of course I use the UML environment, seems I got lost in the jungle of
packages, sorry.

Your post helped me to understand the things a lot better, yet I did not
manage to make it work.

I copied and adapted the parts of the standalone-test to match the
directory structure of my server, and made sure that i.e. the
"getUMLResourcesJar()" pointed to the right path.
Nevertheless it continues to give me the error saying it can't find the
package uml.

I had to remove the function "configurePlatformProtocol()" due to the part
"URL.setURLStreamHandlerFactory ...", since that can be done only once,
and JBoss seems to do that first. Could that be the reason, and if it is,
what would you recommend to do as a workaround?

Thanks for your fast reply,
Best regards,

David

Christian W. Damus wrote:

> Hi, David,

> If you are using the UML environment implementation
> (org.eclipse.ocl.uml.OCL), then you will additionally need to make other
> resources available to the parser at run-time, most especially the UML
> representation of the UML metamodel (UML.metamodel.uml, not UML.ecore).
> This is what the package look-up is actually looking for.

> You mentioned the EcoreEnvironment class in your post, so perhaps this isn't
> quite your problem, but other resources are needed.

> You can find an example of stand-alone (Eclipse-free) parsing that works in
> the OCL CVS repository: check out the org.eclipse.ocl.standalone.tests
> project from the

> /cvsroot/modeling/org.eclipse.mdt/org.eclipse.ocl/tests

> module. This project uses PDE only to assemble the classpath.

> There is one class in this project, "AllTests", that runs the OCL Ecore,
> UML, and 1.0 compatibility test suites in an Eclipse-free runtime
> environment. The static initializer of the AllTests class sets up package
> registrations (including a compatibility for UML 2.0.0 namespace), URI
> mappings, and much else. Have a look in there for ideas of what you might
> be missing.

> HTH,

> Christian


> David Hellekalek wrote:

>> Hello,
>>
>> I am working on a web application that evaluates OCL statements on UML
>> models. Unfortunately, I always get this error:
>> Parse failed: ERROR in (packageDeclarationCS): (Unable to find package: (
>> uml))
>> It works fine in eclipse, and I put all the EMF/OCL/UML2 plugin files in
>> the web application's classpath and don't get any "Class not found"
>> problems.
>>
>> The top part of the stacktrace:
>> org.eclipse.ocl.SemanticException: ERROR in (packageDeclarationCS):
>> (Unable to find package: ( uml))
>> at org.eclipse.ocl.internal.parser.OCLParser.ERR(OCLParser.java :596)
>> at org.eclipse.ocl.internal.parser.OCLParser.ERROR(OCLParser.ja va:605)
>> at
>>
>
org.eclipse.ocl.internal.parser.OCLParser.packageDeclaration CS(OCLParser.java:1085)
>> at
>>
>
org.eclipse.ocl.internal.parser.OCLParser.parsePackageDeclar ationCS(OCLParser.java:822)
>> at org.eclipse.ocl.OCL.parse(OCL.java:243)
>> ...
>>
>> I think it is caused because "env =
>> environmentFactory.createPackageContext(environment, pathname);" is null
>> in OCLParser.packageDeclarationCS.
>> In "EcoreEnvironment" there is a function "findPackage" that seems to get
>> called and does not find the package uml, this seems to be the "real root
>> cause" (due to that, env is null, and due to that, OCLParser throws an
>> Exception)
>>
>> Unfortunately, this is where I started to fail to continue. I don't know
>> what I would have to change to make "findPackage" succeed.
>>
>> The OCL define starts like this:
>> package uml context Class
>> ...
>>
>> I use this function for the settings:
>> private void loadModules()
>> {
>> ResourceSet resourceSet = new ResourceSetImpl();
>> resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
>> UMLPackage.eINSTANCE);
>> Map extensionToFactoryMap =
>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap();
>> extensionToFactoryMap.put(UMLResource.FILE_EXTENSION,
>> UMLResource.Factory.INSTANCE);
>> extensionToFactoryMap.put("ecore", new EcoreResourceFactoryImpl());
>> extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_ EXTENSION, new
>> XMIResourceFactoryImpl());
>> }
>>
>> If you can help me by pointing out possible causes and solutions, or
>> giving me ideas what to try, I would really appreciate it.
>>
>> Best regards,
>> David Hellekalek
Re: Please help me: Parse failed: ERROR in (packageDeclarationCS): (Unable to find package: ( uml)) [message #35809 is a reply to message #35775] Tue, 21 August 2007 21:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dh_eclipseng.hellekalek.com

>
> I had to remove the function "configurePlatformProtocol()" due to the part
> "URL.setURLStreamHandlerFactory ...", since that can be done only once,
> and JBoss seems to do that first. Could that be the reason, and if it is,
> what would you recommend to do as a workaround?
>

A small update/extra information: I managed to fix that part, but actually
it seems that an URL with the platform protocol never gets used ...
I really don't know whats wrong ... :-(((
Re: Please help me: Parse failed: ERROR in (packageDeclarationCS): (Unable to find package: ( uml)) [message #35842 is a reply to message #35775] Wed, 22 August 2007 12:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, david,

Yeah, I'm not really sure whether the tests needed to mess with the
platform: URL protocol, either, because registering mappings for the
platform:/plugin/org.eclipse.uml2.uml... URIs should obviate that.

I'm not very familiar with managing the classpath in a JBoss world, but I
imagine that J2EE containers' management of class loaders can't be so very
different from OSGi? I don't suppose that your problem could really be a
classpath one.

Do you have an IDE in which you can effectively debug your server
application? It would be good to know whether/why the
OCLUMLUtil::getUMLMetamodel(ResourceSet) method is failing to load the
UML.metamodel.uml resource in your resource set. Somehow, I imagine the
problem must be in there.

HTH,

Christian


David Hellekalek wrote:

> Hello Christian,
>
> Of course I use the UML environment, seems I got lost in the jungle of
> packages, sorry.
>
> Your post helped me to understand the things a lot better, yet I did not
> manage to make it work.
>
> I copied and adapted the parts of the standalone-test to match the
> directory structure of my server, and made sure that i.e. the
> "getUMLResourcesJar()" pointed to the right path.
> Nevertheless it continues to give me the error saying it can't find the
> package uml.
>
> I had to remove the function "configurePlatformProtocol()" due to the part
> "URL.setURLStreamHandlerFactory ...", since that can be done only once,
> and JBoss seems to do that first. Could that be the reason, and if it is,
> what would you recommend to do as a workaround?
>
> Thanks for your fast reply,
> Best regards,
>
> David

--------8<-------
Re: Please help me: Parse failed: ERROR in (packageDeclarationCS): (Unable to find package: ( uml)) [message #36114 is a reply to message #35641] Wed, 22 August 2007 16:12 Go to previous message
Eclipse UserFriend
Originally posted by: dh_eclipseng.hellekalek.com

Hi again,

We solved it, it seems it was the fault of JBoss' classloader.

best regards,
David

"David Hellekalek" <dh_eclipseng@hellekalek.com> schrieb im Newsbeitrag
news:faboea$ivv$1@build.eclipse.org...
> Hello,
>
> I am working on a web application that evaluates OCL statements on UML
> models. Unfortunately, I always get this error:
> Parse failed: ERROR in (packageDeclarationCS): (Unable to find package:
> ( uml))
> It works fine in eclipse, and I put all the EMF/OCL/UML2 plugin files in
> the web application's classpath and don't get any "Class not found"
> problems.
>
> The top part of the stacktrace:
> org.eclipse.ocl.SemanticException: ERROR in (packageDeclarationCS):
> (Unable to find package: ( uml))
> at org.eclipse.ocl.internal.parser.OCLParser.ERR(OCLParser.java :596)
> at org.eclipse.ocl.internal.parser.OCLParser.ERROR(OCLParser.ja va:605)
> at
> org.eclipse.ocl.internal.parser.OCLParser.packageDeclaration CS(OCLParser.java:1085)
> at
> org.eclipse.ocl.internal.parser.OCLParser.parsePackageDeclar ationCS(OCLParser.java:822)
> at org.eclipse.ocl.OCL.parse(OCL.java:243)
> ...
>
> I think it is caused because "env =
> environmentFactory.createPackageContext(environment, pathname);" is null
> in OCLParser.packageDeclarationCS.
> In "EcoreEnvironment" there is a function "findPackage" that seems to get
> called and does not find the package uml, this seems to be the "real root
> cause" (due to that, env is null, and due to that, OCLParser throws an
> Exception)
>
> Unfortunately, this is where I started to fail to continue. I don't know
> what I would have to change to make "findPackage" succeed.
>
> The OCL define starts like this:
> package uml context Class
> ...
>
> I use this function for the settings:
> private void loadModules()
> {
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
> UMLPackage.eINSTANCE);
> Map extensionToFactoryMap =
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap();
> extensionToFactoryMap.put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
> extensionToFactoryMap.put("ecore", new EcoreResourceFactoryImpl());
> extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_ EXTENSION, new
> XMIResourceFactoryImpl());
> }
>
> If you can help me by pointing out possible causes and solutions, or
> giving me ideas what to try, I would really appreciate it.
>
> Best regards,
> David Hellekalek
>
Previous Topic:OCLHelperPackage misses in 2.2 EMF/OCL
Next Topic:OCL 2.0 question
Goto Forum:
  


Current Time: Fri Apr 26 10:23:15 GMT 2024

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

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

Back to the top