How to run mwe.utils.StandaloneSetup in server

202 views Asked by At

I'm working in a web project that uses a XText grammar but every time I run it on Apache Tomcat I find the same error

java.lang.ClassNotFoundException: co.edu.uniandes.enar.picture.Model at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1324) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1177) at co.edu.uniandes.picture.webpicture.servlet.util.UploadDownloadFileServlet.doPost(UploadDownloadFileServlet.java:75) at javax.servlet.http.HttpServlet.service(HttpServlet.java:644) at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) ...

I already did the steps mentioned in http://www.eclipse.org/forums/index.php/t/489925/ to generate the Jar file but again it does not work

Thanks in advance

1

There are 1 answers

0
hellspawn On

Solved

  1. Export all the Xtext grammar project into a whole .jar
  2. Export the MWE2 as a runnable jar
  3. Put those jar files in your web project
  4. Modify the code for loading the model as follows

//new org.eclipse.emf.mwe.utils.StandaloneSetup().setPlatformUri("../"); ->Leave it in comments

Injector injector = new co.edu.uniandes.enar.PictureStandaloneSetup().createInjectorAndDoEMFRegistration(); XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class); resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE); Resource resource = resourceSet.getResource(URI.createURI(path), true); Model model = (ModelImpl) resource.getContents().get(0);

There you go the model is loaded in the web project but it tends to consume a lot of memory :(