Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Configure Standalone (Problem Xtext program standalone no JAR file)
Configure Standalone [message #1860520] Fri, 11 August 2023 21:38 Go to next message
Gricel Vazquez is currently offline Gricel VazquezFriend
Messages: 5
Registered: August 2023
Junior Member
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 05:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Configure Standalone [message #1860550 is a reply to message #1860524] Tue, 15 August 2023 16:24 Go to previous messageGo to next message
Gricel Vazquez is currently offline Gricel VazquezFriend
Messages: 5
Registered: August 2023
Junior Member
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 65 times)
  • Attachment: 2 Error.jpg
    (Size: 513.83KB, Downloaded 72 times)
  • Attachment: run.java
    (Size: 0.99KB, Downloaded 59 times)
Re: Configure Standalone [message #1860559 is a reply to message #1860550] Thu, 17 August 2023 03:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
Can you provide complete error log

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Configure Standalone [message #1860566 is a reply to message #1860559] Thu, 17 August 2023 11:23 Go to previous messageGo to next message
Gricel Vazquez is currently offline Gricel VazquezFriend
Messages: 5
Registered: August 2023
Junior Member
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 11:25]

Report message to a moderator

Re: Configure Standalone [message #1860572 is a reply to message #1860566] Thu, 17 August 2023 19:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Thu, 17 August 2023 20:21]

Report message to a moderator

Re: Configure Standalone [message #1860573 is a reply to message #1860572] Thu, 17 August 2023 21:11 Go to previous messageGo to next message
Gricel Vazquez is currently offline Gricel VazquezFriend
Messages: 5
Registered: August 2023
Junior Member
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 21:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Thu, 17 August 2023 22:04]

Report message to a moderator

Re: Configure Standalone [message #1860602 is a reply to message #1860574] Mon, 21 August 2023 10:39 Go to previous messageGo to next message
Gricel Vazquez is currently offline Gricel VazquezFriend
Messages: 5
Registered: August 2023
Junior Member
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] Tue, 22 August 2023 03:21 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
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>
+


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Tue, 22 August 2023 03:27]

Report message to a moderator

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


Current Time: Wed Dec 04 22:09:05 GMT 2024

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

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

Back to the top