Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » ClassNotFoundError of exception when running Acceleo in standalone mode
ClassNotFoundError of exception when running Acceleo in standalone mode [message #1834376] Mon, 09 November 2020 11:09 Go to next message
Alejandro Rueda is currently offline Alejandro RuedaFriend
Messages: 4
Registered: October 2020
Junior Member
Hi,

I'm having the following problem when I try to run Generate.java to be able to run the acceleo standalone:

nested exception is java.lang.NoClassDefFoundError: org/eclipse/core/runtime/spi/RegistryStrategy] with root cause

java.lang.ClassNotFoundException: org.eclipse.core.runtime.spi.RegistryStrategy
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588) ~[na:na]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151) ~[sirius-web-sample-application-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na]
at org.eclipse.emf.ecore.plugin.EcorePlugin.computePlatformResourceToPlatformPluginMap(EcorePlugin.java:320) ~[org.eclipse.emf.ecore-2.18.0.jar!/:na]
at org.eclipse.emf.ecore.plugin.EcorePlugin.computePlatformURIMap(EcorePlugin.java:572) ~[org.eclipse.emf.ecore-2.18.0.jar!/:na]
at org.eclipse.emf.ecore.plugin.EcorePlugin.computePlatformURIMap(EcorePlugin.java:521) ~[org.eclipse.emf.ecore-2.18.0.jar!/:na]
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.initialize(AbstractAcceleoGenerator.java:434) ~[org.eclipse.acceleo.engine-3.5.0-SNAPSHOT.jar!/:na]
at org.eclipse.sirius.web.spring.controllers.Generate.<init>(Generate.java:76) ~[sirius-web-spring-0.1.0-SNAPSHOT.jar!/:0.1.0-SNAPSHOT]

This is part of the content of my Generate.java file:

    public static void main(String[] args) {
		try {
		URI modelURI = URI.createFileURI(args[0]);
		File targetFolder = new File(args[1]);
		Generate generator = new Generate(modelURI, targetFolder, Collections.emptyList());
		generator.doGenerate(new BasicMonitor());
         } catch (Exception e) {
            e.printStackTrace();
        }
    }   
 @Override
    public void registerPackages(ResourceSet resourceSet) {
        super.registerPackages(resourceSet);
        if (!isInWorkspace(VanthPackage.class)) {
            resourceSet.getPackageRegistry().put(VanthPackage.eINSTANCE.getNsURI(), VanthPackage.eINSTANCE);
        }
    }

    /**
     * This can be used to update the resource set's resource factory registry with all needed factories.
     * 
     * @param resourceSet
     *            The resource set which registry has to be updated.
     * @generated
     */
    @Override
    public void registerResourceFactories(ResourceSet resourceSet) {
        super.registerResourceFactories(resourceSet);

        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("vanth",new XMIResourceFactoryImpl());

        /*
         * Some metamodels require a very complex setup for standalone usage. For example, if you want to use a generator
         * targetting UML models in standalone, you NEED to use the following:
         */ 
        // UMLResourcesUtil.init(resourceSet)
    }


This from my pom.xml:

			
                     <plugin>
				<groupId>org.eclipse.acceleo</groupId>
				<artifactId>org.eclipse.acceleo.maven</artifactId>
				<version>3.5.2</version>
				<configuration>
				<useBinaryResources>false</useBinaryResources>
				<usePlatformResourcePath>true</usePlatformResourcePath>
				<acceleoProject>
					<root>${project.basedir}</root>
					<entries>
					<entry>
						<input>src</input>
						<output>target/classes</output>
					</entry>
					</entries>
				</acceleoProject>
				<packagesToRegister>
					<packageToRegister>vanth.VanthPackage</packageToRegister>
				</packagesToRegister>
				<uriHandler>org.eclipse.acceleo.maven.AcceleoURIHandler</uriHandler>
				</configuration>
			</plugin>


Re: ClassNotFoundError of exception when running Acceleo in standalone mode [message #1834381 is a reply to message #1834376] Mon, 09 November 2020 12:35 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Running Acceleo in standalone mode does not use a pom.xml. I suggest you first debug your bad classpath in a conventional context before trying the more troublesome Maven context.

Regards

Ed Willink
Re: ClassNotFoundError of exception when running Acceleo in standalone mode [message #1834455 is a reply to message #1834376] Tue, 10 November 2020 15:28 Go to previous messageGo to next message
Alejandro Rueda is currently offline Alejandro RuedaFriend
Messages: 4
Registered: October 2020
Junior Member
I executed it without maven packing the jar as you said, and I managed to solve the problem. Now I'm getting the following error when I try to run it with the emtl:
I have version 3.7.10 of aceleo and 2.22 of EMF:

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.UnresolvedReferenceException: Unresolved reference '/0/generateElementPHPDelete/e'. (jar:file:/SNAPSHOT.jar!/BOOT-INF/lib/vanth2api-1.0.0.jar!/vanth2api/main/generate.emtl, 146, 114)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils.java:391)
at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils.java:356)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.initialize(AbstractAcceleoGenerator.java:472)
at vanth2api.main.Generate.<init>(Generate.java:76)

Thanks!!
Re: ClassNotFoundError of exception when running Acceleo in standalone mode [message #1834462 is a reply to message #1834455] Tue, 10 November 2020 17:58 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

This looks a bit like the longstanding off-by-one error that we eventually fixed. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=559060

But your versions are more recent. Without a repro it's hard to tell. But a *.emtl in a jar file is challenging. It could well be that your *.emtl is stale; it can be really hard to persuade the Acceleo builder to build correctly. I'm not sure if anyone has ever succeeded with Maven. I always recommend building in an 'interactive' context and then treating the result as a 'source'.

Regards

Ed Willink
Previous Topic:Read Stereotype / compare Stereotype
Next Topic:[Acceleo] Write in linked folder
Goto Forum:
  


Current Time: Thu Apr 25 16:05:18 GMT 2024

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

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

Back to the top