Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Server throws exception that it is unable to resolve class(Referring to the Helloworld example - client is ok but server is not)
Server throws exception that it is unable to resolve class [message #1701616] Tue, 14 July 2015 13:12 Go to next message
Ravikanth Somayaji is currently offline Ravikanth SomayajiFriend
Messages: 49
Registered: July 2009
Location: Oxford
Member
I am running the "org.eclipse.emf.emfstore.example.helloworld.Application", and have included another model similar to a pom model. I'm able to add the root element to the modelElements and call save, which indicates that the client resource is able to resolve the model object. I can see the objects persisted in the "project.ecp" file as well.

However, when I invoke commit, the server throws an exception that it is unable to resolve the model elements
Caused by: org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'DocumentRoot' is not found or is abstract. (file:///C:/Working/luna/eclipse/virtualResource.xmi, 1, 598)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObjectFromFactory(XMLHandler.java:2280)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.validateCreateObjectFromFactory(XMLHandler.java:2404)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTypeName(XMLHandler.java:2135)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHandler.java:2067)
	at org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHandler.java:128)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLHandler.java:1850)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1030)
	at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:81)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
	at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:163)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:379)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2786)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:648)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:332)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
	... 29 more


In the Helloworld application - the server runs on the same vm and should have resolved all the meta-models, the client did. Can you kindly help me understand if I've missed out on anything or if there is a problem.

Please note that the namespace prefix for the model that Document root belongs to is blank ("")

The project.ecp on the client profile looks like this
<?xml version="1.0" encoding="UTF-8"?>
<org.eclipse.emf.emfstore.internal.common.model:Project xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:org.eclipse.emf.emfstore.internal.common.model="http://eclipse.org/emf/emfstore/common/model" xmlns:org.eclipse.example.bowling="http://org/eclipse/example/bowling" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <modelElements xsi:type="Model" xmi:id="_4PMjeSonEeWib4n6_tnF-A"/>
  <modelElements xsi:type="DocumentRoot" xmi:id="_4P8xYConEeWib4n6_tnF-A">
   </modelElements>
  <modelElements xsi:type="org.eclipse.example.bowling:League" xmi:id="_4QPsVConEeWib4n6_tnF-A" name="Suprbowling League">
    <players xmi:id="_4QZdVConEeWib4n6_tnF-A" name="Maximilian"/>
    <players xmi:id="_4QZdYyonEeWib4n6_tnF-A" name="Ottgar"/>
  </modelElements>
</org.eclipse.emf.emfstore.internal.common.model:Project>


Thanks

[Updated on: Tue, 14 July 2015 14:35]

Report message to a moderator

Re: Server throws exception that it is unable to resolve class [message #1701779 is a reply to message #1701616] Wed, 15 July 2015 14:23 Go to previous messageGo to next message
Edgar Mueller is currently offline Edgar MuellerFriend
Messages: 89
Registered: March 2011
Member
Hi,

if the server and client are running in same JVM instance, as you said,
this should work, of course (and it does for the demo case).
Can you share the respective code with that starts the server as well
the one where the client initiates the commit?
Did you also make sure that there aren't multiple servers running?

Thanks,
Edgar

--
Edgar Mueller

Get Professional Eclipse Support:
http://eclipsesource.com/en/services/developer-support/
Re: Server throws exception that it is unable to resolve class [message #1701815 is a reply to message #1701779] Thu, 16 July 2015 01:01 Go to previous messageGo to next message
Ravikanth Somayaji is currently offline Ravikanth SomayajiFriend
Messages: 49
Registered: July 2009
Location: Oxford
Member
Please find the code that starts the server and the client -
/*******************************************************************************
 * Copyright 2011 Chair for Applied Software Engineering,
 * Technische Universitaet Muenchen.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 * Florian Pirchner
 * Maximilian Koegel
 ******************************************************************************/
package org.eclipse.emf.emfstore.example.helloworld;

import java.io.IOException;

import org.eclipse.b3.p2.maven.pom.DocumentRoot;
import org.eclipse.b3.p2.maven.pom.Model;
import org.eclipse.b3.p2.maven.pom.PomFactory;
import org.eclipse.b3.p2.maven.pom.PomPackage;
import org.eclipse.b3.p2.maven.pom.util.PomResourceFactoryImpl;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
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.util.EcoreUtil;
import org.eclipse.emf.emfstore.bowling.BowlingFactory;
import org.eclipse.emf.emfstore.bowling.League;
import org.eclipse.emf.emfstore.bowling.Player;
import org.eclipse.emf.emfstore.client.ESLocalProject;
import org.eclipse.emf.emfstore.client.ESRemoteProject;
import org.eclipse.emf.emfstore.client.ESServer;
import org.eclipse.emf.emfstore.client.ESUsersession;
import org.eclipse.emf.emfstore.client.ESWorkspace;
import org.eclipse.emf.emfstore.client.ESWorkspaceProvider;
import org.eclipse.emf.emfstore.client.exceptions.ESServerNotFoundException;
import org.eclipse.emf.emfstore.client.exceptions.ESServerStartFailedException;
import org.eclipse.emf.emfstore.common.ESSystemOutProgressMonitor;
import org.eclipse.emf.emfstore.server.exceptions.ESException;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;

/**
 * An application that runs the demo.<br>
 * Run a client and local server that demo the basic features of EMFStore.
 */
public class Application implements IApplication {

	/**
	 * {@inheritDoc}
	 */
	public Object start(IApplicationContext context) {

		try {
			// Create a client representation for a local server and start a local server.
			ESServer localServer = ESServer.FACTORY.createAndStartLocalServer();
			// Run a client on the local server that shows the basic features of the EMFstore
			runClient(localServer);
		} catch (ESServerStartFailedException e) {
			System.out.println("Server start failed!");
			e.printStackTrace();
		} catch (ESException e) {
			// If there is a problem with the connection to the server,
			// e.g., a network, a specific EMFStoreException will be thrown.
			System.out.println("Connection to Server failed!");
			e.printStackTrace();
		}
		return IApplication.EXIT_OK;
	}

	/**
	 * Run an EMFStore Client connecting to the given server.
	 * 
	 * @param server the server
	 * @throws ESException if the server connection fails
	 */
	public static void runClient(ESServer server) throws ESException {
		System.out.println("Client starting...");

		// The workspace is the core controller to access local and remote projects.
		// A project is a container for models and their elements (EObjects).
		// To get started, we obtain the current workspace of the client.
		ESWorkspace workspace = ESWorkspaceProvider.INSTANCE.getWorkspace();

		// The workspace stores all available servers that have been configured. We add the local server that has
		// already
		// been started on the workspace.
		workspace.addServer(server);
		// Next, we remove all other existing servers
		for (ESServer existingServer : workspace.getServers()) {
			if (existingServer != server) {
				try {
					workspace.removeServer(existingServer);
				} catch (ESServerNotFoundException e) {
					e.printStackTrace();
				}
			}
		}

		// The workspace also contains a list of local projects that have either been created locally or checked out
		// from a server.
		// We create a new local project. The project new created is not yet shared with the server.
		ESLocalProject demoProject = workspace.createLocalProject("DemoProject");

		// We delete all projects from the local workspace other than the one just created.
		for (ESLocalProject existingLocalProject : workspace.getLocalProjects()) {
			if (existingLocalProject != demoProject) {
				try {
					existingLocalProject.delete(new ESSystemOutProgressMonitor());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}

		// Next, we create a user session by logging in to the local EMFStore server with default super user
		// credentials.
		ESUsersession usersession = server.login("super", "super");

		// Now we can share the created local project to our server.
		ESRemoteProject remoteDemoProject = demoProject.shareProject(usersession, new ESSystemOutProgressMonitor());

		// We also retrieve a list of existing (and accessible) remote projects on the server.
		// Remote projects represent a project that is currently available on the server.
		// We delete all remote projects to clean up remaining projects from previous launches.
		for (ESRemoteProject existingRemoteProject : server.getRemoteProjects(usersession)) {
			if (!existingRemoteProject.getGlobalProjectId().equals(remoteDemoProject.getGlobalProjectId())) {
				existingRemoteProject.delete(usersession, new NullProgressMonitor());
			}
		}

		// Now we are all set: we have a client workspace with one server configured and exactly one project shared to a
		// server with only this one project.

		// We start working now with the local project and later we will synchronize it with the copy of the project we
		// just checked out.
		// We create some EObjects and add them to the project, that is, to project�s containment tree. Everything
		// that
		// is
		// in the project�s containment tree (spanning tree on containment references) is considered part of the
		// project. We will use an example model about bowling.

		// First we add a league and set the league name.
		League league = BowlingFactory.eINSTANCE.createLeague();
		league.setName("Suprbowling League");

		ResourceSet rset = new ResourceSetImpl();
		rset.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new PomResourceFactoryImpl());
		rset.getPackageRegistry().put(PomPackage.eNS_URI, PomPackage.eINSTANCE);

		Resource resource = rset.getResource(URI.createFileURI("C:\\tmp1\\JIRA Testing\\XCPBLD-19887\\Test1\\pom.xml"),
			true);

		EObject eObject = resource.getContents().get(0);
		EcoreUtil.remove(eObject);

		if (eObject instanceof DocumentRoot) {
			DocumentRoot dr = (DocumentRoot) eObject;
			demoProject.getModelElements().add(dr.getProject());
		}

		// Next we add the league to the root of the project. The project has a containment feature called model
		// element that holds all root elements of a project. This list is comparable to the content list in EMF
		// Resources that
		// you can retrieve with getContents(). Adding something to the list will add it to the project.
		demoProject.getModelElements().add(league);

		// Then we create two players.
		Player player1 = BowlingFactory.eINSTANCE.createPlayer();
		player1.setName("Maximilian");
		Player player2 = BowlingFactory.eINSTANCE.createPlayer();
		player2.setName("Ottgar");

		// Finally, we add the players to the league. Since the league is already part of the project and League.players
		// is a containment feature, the players also become part of the project.
		league.getPlayers().add(player1);
		league.getPlayers().add(player2);

		demoProject.save();


		// To synchronize the local changes of the client with the server, we will commit the project.
		demoProject.commit("My message", null,
			new ESSystemOutProgressMonitor());
	}

	/**
	 * {@inheritDoc}
	 */
	public void stop() {
	}
}


I did check and there isn't any other server that is running. Please let me know if there is any further information that I can provide.

Thanks

[Updated on: Thu, 16 July 2015 01:02]

Report message to a moderator

Re: Server throws exception that it is unable to resolve class [message #1701892 is a reply to message #1701815] Thu, 16 July 2015 13:23 Go to previous messageGo to next message
Edgar Mueller is currently offline Edgar MuellerFriend
Messages: 89
Registered: March 2011
Member
Hi Ravikanth,
I cloned the b3 repo that contains the model you are using in your
example and tested this with the code you posted and it works for me.
So I guess it must be something else causing the error.
Did you change anything else, for instance the model? What EMFStore
version are you using? And does this also happen if you create a
stand-alone running instance of EMFStore (with the model bundle included
in the running config)?

Thanks,
Edgar

--
Edgar Mueller

Get Professional Eclipse Support:
http://eclipsesource.com/en/services/developer-support/
Re: Server throws exception that it is unable to resolve class [message #1701980 is a reply to message #1701892] Fri, 17 July 2015 09:18 Go to previous messageGo to next message
Ravikanth Somayaji is currently offline Ravikanth SomayajiFriend
Messages: 49
Registered: July 2009
Location: Oxford
Member
Thanks, Edgar for testing this out. Can you please send me the snippet where you use the b3 code?

EMFStore version - I've cloned out the 1.5.0 from the git repo. I did this last month and don't see any incoming changes now.

Also, if you noticed the pom file that got committed to the client/server has its formatting changed.

For e.g.

From
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>tes</groupId>
  <artifactId>test1</artifactId>
  <version>1.0.0</version>
  <packaging>war</packaging>
  <name>test1</name>
  <description/>
  <url>http://www.emc.com/xcp</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  	<creationDate>2015-07-16T09:31:42.031+0530</creationDate>  	
  </properties>


has become
  <modelElements xsi:type="Model" xmi:id="_9yoKJSxjEeWBx63P-plRhA" modelVersion="4.0.0" groupId="t1" artifactId="Test1" packaging="war" name="Test1" version="1.0.0" description="" url="http://www.emc.com/xcp">
    <build xmi:id="_9yni0CxjEeWBx63P-plRhA" finalName="t1-Test1-${project.version}">
 


Is there any way to retain the element structure(on the client xmi)? Would I need to overwrite the resourceset provider to add some XML resource options?

I also noticed that the b3 plugins did not have
  <extension point="org.eclipse.emf.ecore.generated_package">
    <package 
       uri = "http://maven.apache.org/POM/4.0.0" 
       class = "org.eclipse.b3.p2.maven.pom.PomPackage" /> 
  </extension>

So this is the only change that i did.

I shall try running it again with a standalone EMFStore server instance as you suggest and update my findings.

Thanks again for looking into this.

[Updated on: Fri, 17 July 2015 09:22]

Report message to a moderator

Re: Server throws exception that it is unable to resolve class [message #1702448 is a reply to message #1701980] Wed, 22 July 2015 12:24 Go to previous message
Edgar Mueller is currently offline Edgar MuellerFriend
Messages: 89
Registered: March 2011
Member
Hi Ravikanth,

I essentially used the same snippet as you did, but it wasn't clear to
me that you would like to maintain the document structure of the
pom.xml. I only was concerned about the unsuccessful commit, which
didn't happen for me.
Currently, EMFStore does not provide any API to alter the EMF resource
save options, but since you have cloned the repo anyways you could try
to change the resource options directly. So, in
ModelUtil#getResourceSaveOptions and ModelUtil#getResourceLoadOptions
you might want to add this additional option, which I think does what
you are after:
resourceSaveOptions.put(XMLResource.OPTION_EXTENDED_META_DATA,
Boolean.TRUE);

Cheers,
Edgar


Am 17.07.2015 um 11:18 schrieb Ravikanth Somayaji:
> Thanks, Edgar for testing this out. Can you please send me the snippet
> where you use the b3 code?
> I've checked out the 1.5.0 from the git repo. I did this last month and
> don't see any incoming changes.
>
> Also, if you noticed the pom file that got commited to the client/server
> has it formatting changed.
>
> For e.g.
> From
>
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
> <modelVersion>4.0.0</modelVersion>
> <groupId>tes</groupId>
> <artifactId>test1</artifactId>
> <version>1.0.0</version>
> <packaging>war</packaging>
> <name>test1</name>
> <description/>
> <url>http://www.emc.com/xcp</url>
> <properties>
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> <creationDate>2015-07-16T09:31:42.031+0530</creationDate>
> </properties>
>
>
> has become
>
> <modelElements xsi:type="Model" xmi:id="_9yoKJSxjEeWBx63P-plRhA"
> modelVersion="4.0.0" groupId="t1" artifactId="Test1" packaging="war"
> name="Test1" version="1.0.0" description="" url="http://www.emc.com/xcp">
> <build xmi:id="_9yni0CxjEeWBx63P-plRhA"
> finalName="t1-Test1-${project.version}">
>
>
> Is there any way to retain the element structure(on the client xmi)?
> Would I need to overwrite the resourceset provider to add some XML
> resource options?
> I also noticed that the b3 plugins did not have
> <extension point="org.eclipse.emf.ecore.generated_package">
> <package uri = "http://maven.apache.org/POM/4.0.0" class
> = "org.eclipse.b3.p2.maven.pom.PomPackage" /> </extension>
>
> So this is the only change that i did.
>
> I shall try running it again with a standalone EMFStore server instance
> as you suggest and update my findings.
> Thanks again for looking into this.


--
Edgar Mueller

Get Professional Eclipse Support:
http://eclipsesource.com/en/services/developer-support/
Previous Topic:Edapt - Diff-based metamodel migration
Next Topic:[Teneo] two small enhancements in SerializableDynamicEObjectImpl
Goto Forum:
  


Current Time: Mon May 25 22:24:03 GMT 2020

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

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

Back to the top