Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forumsrunning validation from an application (or a junit test)
https://www.eclipse.org/forums/index.php/mv/msg/132608/412679/#msg_412679
I was trying to run validation from an application (also tried from a
junit test) using the extlibrary example, with the following code:
Exception in thread "main" java.lang.ExceptionInInitializerError
at
org.eclipse.emf.validation.internal.service.BatchValidator$D efaultRecursiveTraversalStrategy.initDelegates(BatchValidato r.java:338)
at
org.eclipse.emf.validation.internal.service.BatchValidator$D efaultRecursiveTraversalStrategy.startTraversal(BatchValidat or.java:259)
at
org.eclipse.emf.validation.internal.service.BatchValidator.v alidate(BatchValidator.java:169)
at
org.eclipse.emf.validation.internal.service.BatchValidator.d oValidate(BatchValidator.java:137)
at
org.eclipse.emf.validation.internal.service.AbstractValidato r.validate(AbstractValidator.java:141)
at
org.eclipse.emf.validation.internal.service.AbstractValidato r.validate(AbstractValidator.java:120)
at
org.eclipse.emf.examples.extlibrary.tests.EXTLibraryExample. main(EXTLibraryExample.java:74)
Caused by: java.lang.NullPointerException
at
org.eclipse.emf.validation.internal.EMFModelValidationPlugin .getPluginId(EMFModelValidationPlugin.java:203)
at
org.eclipse.emf.validation.internal.service.TraversalStrateg yManager.initStrategies(TraversalStrategyManager.java:100)
at
org.eclipse.emf.validation.internal.service.TraversalStrateg yManager. <init>(TraversalStrategyManager.java:62)
at
org.eclipse.emf.validation.internal.service.TraversalStrateg yManager. <clinit>(TraversalStrategyManager.java:54)
... 7 more
Lorenzo Bettini wrote:
> Hi
>
> I was trying to run validation from an application (also tried from a
> junit test) using the extlibrary example, with the following code:
>
> EXTLibraryFactory factory = EXTLibraryFactory.eINSTANCE;
>
> Library library = factory.createLibrary();
> Book book = factory.createBook();
>
> book.setTitle("foo");
> library.getBooks().add(book);
>
> System.out.println("book: " + book);
>
> IBatchValidator validator = (IBatchValidator) ModelValidationService
> .getInstance().newValidator(EvaluationMode.BATCH);
>
> IStatus status = validator.validate(library);
>
> System.out.println("result: " + status);
>
> but I get the following error:
>
> Exception in thread "main" java.lang.ExceptionInInitializerError
> at
> org.eclipse.emf.validation.internal.service.BatchValidator$D efaultRecursiveTraversalStrategy.initDelegates(BatchValidato r.java:338)
>
> at
> org.eclipse.emf.validation.internal.service.BatchValidator$D efaultRecursiveTraversalStrategy.startTraversal(BatchValidat or.java:259)
>
> at
> org.eclipse.emf.validation.internal.service.BatchValidator.v alidate(BatchValidator.java:169)
>
> at
> org.eclipse.emf.validation.internal.service.BatchValidator.d oValidate(BatchValidator.java:137)
>
> at
> org.eclipse.emf.validation.internal.service.AbstractValidato r.validate(AbstractValidator.java:141)
>
> at
> org.eclipse.emf.validation.internal.service.AbstractValidato r.validate(AbstractValidator.java:120)
>
> at
> org.eclipse.emf.examples.extlibrary.tests.EXTLibraryExample. main(EXTLibraryExample.java:74)
>
> Caused by: java.lang.NullPointerException
> at
> org.eclipse.emf.validation.internal.EMFModelValidationPlugin .getPluginId(EMFModelValidationPlugin.java:203)
>
> at
> org.eclipse.emf.validation.internal.service.TraversalStrateg yManager.initStrategies(TraversalStrategyManager.java:100)
>
> at
> org.eclipse.emf.validation.internal.service.TraversalStrateg yManager. <init>(TraversalStrategyManager.java:62)
>
> at
> org.eclipse.emf.validation.internal.service.TraversalStrateg yManager. <clinit>(TraversalStrategyManager.java:54)
>
> ... 7 more
>
> what am I doing wrong?
>
> thanks in advance
> Lorenzo
>]]>Ed Merks2007-09-02T16:00:54-00:00Re: running validation from an application (or a junit test)
https://www.eclipse.org/forums/index.php/mv/msg/132608/412690/#msg_412690
> Lorenzo,
>
> I don't think the validation framework supports standalone execution.
> Are you running this as a JUnit Plugin test?
>
>
Hi
you're right: if I run it as a Junit Plugin test it runs without
exception (let alone that I still have problems since no constraint is
used, see my other post "problems with validation tutorial").
When I run my validation code in Eclipse/IBM RSA it runs fine. When I run it headless the validation framework never sets the IStatus to anything but "Status OK: org.eclipse.emf.validation code=10 No constraints were evaluated" The validation is being performed on exactly the same model
The validator itself is just a simple UML Batch validator using IBatchValidator.
Any ideas?
Thanks,
Ronan]]>Ronan B2011-02-21T18:15:44-00:00Re: running validation from an application (or a junit test)
https://www.eclipse.org/forums/index.php/mv/msg/132608/655639/#msg_655639
Comments below.
Ronan wrote:
> Hi,
> I'm just wondering if there is still a limitation on the emf
> validation framework working in a standalone execution environment
> i.e. Headless.
Stand alone and headless don't mean the same thing. The later is
running an Eclipse/Equinox application without a UI the former is
running directly from some Java class' main() method.
>
> When I run my validation code in Eclipse/IBM RSA it runs fine. When I
> run it headless the validation framework never sets the IStatus to
> anything but "Status OK: org.eclipse.emf.validation code=10 No
> constraints were evaluated" The validation is being performed on
> exactly the same model
Perhaps something it's relying on is missing. E.g.,
org.eclipse.core.resources I think is necessary.
>
> The validator itself is just a simple UML Batch validator using
> IBatchValidator.
>
> Any ideas?
>
> Thanks,
> Ronan]]>Ed Merks2011-02-22T06:07:53-00:00Re: running validation from an application (or a junit test)
https://www.eclipse.org/forums/index.php/mv/msg/132608/655900/#msg_655900
My bad Your right I should have said just Headless
Yes I have org.eclipse.core.resources included as a dependency.
With some more debugging we have found that the ClientContext is not getting setup correctly in Headless mode. This means we get no validation rules returned. It looks like perhaps the IBM UMLvalidation code we rely on is creating an EditingDomain that has dependencies on GMF. Obviously this is bad news as GMF has no place in our headless environment. I'll try and follow this up further and report back.