Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Configure Standalone (Problem Xtext program standalone no JAR file)
Configure Standalone [message #1860520] Fri, 11 August 2023 17:38 Go to next message
Eclipse UserFriend
I am trying to use my Xtext from Ecore in a standalone manner in a Maven project. I follow the steps in:
https://github.com/echebbi/standalone-xtext-example

Which seems very comprehensive after a lot of research. However, when I get to "You must also add the JAR located under org.xtext.example.mydsl/target as a project's dependency.", there is no JAR file

I have a file ending in .target and the pom.xlm file in this folder, nothing more.

Thanks for the help.
Re: Configure Standalone [message #1860524 is a reply to message #1860520] Sat, 12 August 2023 01:18 Go to previous messageGo to next message
Eclipse UserFriend
Please check what the new project wizard generates when you select language server fat jar.
Then exchange the main class with your main class and you should be fine
Re: Configure Standalone [message #1860550 is a reply to message #1860524] Tue, 15 August 2023 12:24 Go to previous messageGo to next message
Eclipse UserFriend
Thank you! I created a new project with FAT JAR. Then follow run>maven install on the parent folder, add the JAR under org.xtext.example.mydsl/target and now I can recognise the DSL classes on Maven.

However, when I run the main.java in Maven there are lots of errors related to the line:

Injector injector = new MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();

Do you have any idea what this error mean/ how to solve it?

Thank you again!

(I attach the main function from Maven as run.java)


  • Attachment: 1FatJar.jpg
    (Size: 60.49KB, Downloaded 111 times)
  • Attachment: 2 Error.jpg
    (Size: 513.83KB, Downloaded 112 times)
  • Attachment: run.java
    (Size: 0.99KB, Downloaded 102 times)
Re: Configure Standalone [message #1860559 is a reply to message #1860550] Wed, 16 August 2023 23:38 Go to previous messageGo to next message
Eclipse UserFriend
Can you provide complete error log
Re: Configure Standalone [message #1860566 is a reply to message #1860559] Thu, 17 August 2023 07:23 Go to previous messageGo to next message
Eclipse UserFriend
Yes, I share all the code and error I got here: https://github.com/Gricel-lee/Xtext-Maven
Thank you!

[Updated on: Thu, 17 August 2023 07:25] by Moderator

Re: Configure Standalone [message #1860572 is a reply to message #1860566] Thu, 17 August 2023 15:28 Go to previous messageGo to next message
Eclipse UserFriend
What do you mean by run
How do you execute the jar
And the run thing

Maybe using the default package is a bad idea with java 17 and modules

[Updated on: Thu, 17 August 2023 16:21] by Moderator

Re: Configure Standalone [message #1860573 is a reply to message #1860572] Thu, 17 August 2023 17:11 Go to previous messageGo to next message
Eclipse UserFriend
I have the .JAR file located under zzz.example.mydsl1/target as a project's dependency in Maven.

By run I mean I run the main class in my Maven project as a Java application.

I changed the name of the package, but same error.

Thank you for following
Re: Configure Standalone [message #1860574 is a reply to message #1860573] Thu, 17 August 2023 17:59 Go to previous messageGo to next message
Eclipse UserFriend
I assume you need to configure something in the project to make correct use of the java module system
Unfortunately I don't have the time to reproduce / research

https://stackoverflow.com/questions/41265266/how-to-solve-inaccessibleobjectexception-unable-to-make-member-accessible-m

[Updated on: Thu, 17 August 2023 18:04] by Moderator

Re: Configure Standalone [message #1860602 is a reply to message #1860574] Mon, 21 August 2023 06:39 Go to previous messageGo to next message
Eclipse UserFriend
Well, I still stuck here after trying multiple configurations of the version in the .pom file and Java,
but thank you for the help!
Re: Configure Standalone [message #1860616 is a reply to message #1860602] Mon, 21 August 2023 23:21 Go to previous message
Eclipse UserFriend
questions:
- why do you use the normal jar and not the uber jar
- file should be "./example.mydsl1"
- other xtext deps in example project not needed

=> unclear what you try to achieve
maybe you can do 2 steps back and describe what you want to achieve

with move of run.java to a package
it works for me

- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
- <classpathentry kind="lib" path="/Users/grisv/GitHub/KanoaV2/Resources/zzz.example.mydsl1.parent/zzz.example.mydsl1/target/zzz.example.mydsl1-1.0.0-SNAPSHOT.jar"/>
+ <classpathentry kind="lib" path="/home/dietrich/tmp/Xtext-Maven/zzz.example.mydsl1.parent/zzz.example.mydsl1.ide/target/zzz.example.mydsl1.ide-1.0.0-SNAPSHOT-ls.jar"/>


umbenannt: Examplemaven/src/main/java/run.java -> Examplemaven/src/main/java/demo/run.java

it diff Examplemaven/src/main/java/demo/run.java
diff --git a/Examplemaven/src/main/java/demo/run.java b/Examplemaven/src/main/java/demo/run.java
index 3035a07..22dd3cd 100644
--- a/Examplemaven/src/main/java/demo/run.java
+++ b/Examplemaven/src/main/java/demo/run.java
@@ -1,3 +1,4 @@
+package demo;
import java.util.ArrayList;

import org.eclipse.emf.common.util.EList;
@@ -18,14 +19,12 @@ public class run {

Injector injector = new MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
- Resource resource = resourceSet.getResource(URI.createFileURI("./example.mydsl"), true);
+ Resource resource = resourceSet.getResource(URI.createFileURI("./example.mydsl1"), true);

Model model = (Model) resource.getContents().get(0);

- @SuppressWarnings("unchecked")
- EList<Greeting> gs = (EList<Greeting>) new ArrayList();

- for (Greeting g : gs) {
+ for (Greeting g : model.getGreetings()) {
System.out.println(g.toString());
}

git diff Examplemaven/pom.xml
diff --git a/Examplemaven/pom.xml b/Examplemaven/pom.xml
index 22a0d3f..c047ad8 100644
--- a/Examplemaven/pom.xml
+++ b/Examplemaven/pom.xml
@@ -4,23 +4,7 @@
<artifactId>zzzzmaven</artifactId>
<version>0.0.1-SNAPSHOT</version>

- <dependencies>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- <version>2.10.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- <version>2.10.0</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.xtext</groupId>
- <artifactId>org.eclipse.xtext</artifactId>
- <version>2.12.0</version>
- </dependency>
-</dependencies>
+

[Updated on: Mon, 21 August 2023 23:27] by Moderator

Previous Topic:Formatting: Best practices around ownership of surrounding hidden regions
Next Topic:Xtext 2.32.0 was released
Goto Forum:
  


Current Time: Fri Jun 20 13:50:36 EDT 2025

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

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

Back to the top