Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Problems Using XText Language in Java project.
Problems Using XText Language in Java project. [message #1736104] Sun, 26 June 2016 06:35 Go to next message
Sam Patterson is currently offline Sam PattersonFriend
Messages: 18
Registered: June 2016
Junior Member
Hello,

I followed Sebastian Zarnekow's guide on how to export an XText language and use it in a standalone project.

However I'm getting the following error when attempting to validate the language:

"The string resource '_UI_DiagnosticRoot_diagnostic' could not be located"

Could it be something to do with how the JAR is exported? When exporting I chose the "Export required libraries into generated JAR", however if I use 2nd option eclipse tells me it cannot find the main class for the project.

Anyone help is appreciated Smile

Re: Problems Using XText Language in Java project. [message #1736280 is a reply to message #1736104] Tue, 28 June 2016 08:17 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Did you use the Library handling option "Package required libraries into generated JAR"? It is not the default option.
Re: Problems Using XText Language in Java project. [message #1736281 is a reply to message #1736104] Tue, 28 June 2016 08:18 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1814
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 27/06/2016 13:57, Sam Patterson wrote:
> Hello,
>
> I followed Sebastian Zarnekow's guide on how to export an XText language
> and use it in a standalone project.
>
> However I'm getting the following error when attempting to validate the
> language:
>
> "The string resource '_UI_DiagnosticRoot_diagnostic' could not be located"
>
> Could it be something to do with how the JAR is exported? When exporting
> I chose the "Export required libraries into generated JAR", however if I
> use 2nd option eclipse tells me it cannot find the main class for the
> project.
>
> Anyone help is appreciated :)
>
>

Hi

If I remember correctly, you should export the jar with all dependencies
packed as jars into the exported jar, and NOT as extracted into the
packed jars. Otherwise the properties files and manifests will override
each others and EMF won't be able to find the properties containing the
substitutions for the strings.

hope this helps
Lorenzo

--
Prof. Lorenzo Bettini, Computer Science, DISIA, Univ. Firenze
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Re: Problems Using XText Language in Java project. [message #1736289 is a reply to message #1736281] Tue, 28 June 2016 09:31 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Yes, the option I stated above is exactly for the case that the libraries are packaged in the jar and are not unpacked. I also think that it is the failure reason.

Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: Problems Using XText Language in Java project. [message #1738010 is a reply to message #1736289] Fri, 15 July 2016 03:53 Go to previous messageGo to next message
Sam Patterson is currently offline Sam PattersonFriend
Messages: 18
Registered: June 2016
Junior Member
I tried both extracting and packaging the JAR, however when I package the JAR none of the imports are recognized (mainly the XText and google ones), so I can't even run the program. However if I extract the JAR then the imports do work but of course I get the original error message.
Re: Problems Using XText Language in Java project. [message #1738071 is a reply to message #1738010] Fri, 15 July 2016 14:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14729
Registered: July 2009
Senior Member
that about simply create a valid plugin.propertties manually with the required entries ?!?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Problems Using XText Language in Java project. [message #1738082 is a reply to message #1738071] Fri, 15 July 2016 15:37 Go to previous messageGo to next message
Sam Patterson is currently offline Sam PattersonFriend
Messages: 18
Registered: June 2016
Junior Member
Well the problem still lies in the fact that packaging the JAR(as people stated I should be doing) causes the required imports to not be recognized, so I'm not able to get to a point where the program can be executed, therefore even if creating a plugin.properties file fixes the original '_UI_DiagnosticRoot_diagnostic error at run time, I still can't execute the application.
Re: Problems Using XText Language in Java project. [message #1738085 is a reply to message #1738082] Fri, 15 July 2016 15:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14729
Registered: July 2009
Senior Member
Please describe step by step what to do to reproduce

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Problems Using XText Language in Java project. [message #1738088 is a reply to message #1738085] Fri, 15 July 2016 16:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14729
Registered: July 2009
Senior Member
p.s. i did the following

(1) create a new xtext project.
(2) adapt workflow to generate java main for generator
(3) generate lang
(4) run generated java main once
(5) use the export as runnable jar file, tell it to create a ant file
(6) copy the ant file to the project
(7) adapted the ant file to include another file at the end

       		<fileset dir="${dir.workspace}/org.xtext.example.mydsl2/">
       			<include name="plugin.properties"/>
       		</fileset>


(Cool create org.xtext.example.mydsl2/plugin.properties as follows
_UI_DiagnosticRoot_diagnostic=Dont Care


well i was too lazy to look up the real values and the other key value pairs

(9) rerun ant file
(10) have fun

if id be an ant wizard i would somehow adapt the build.xml to create a plugin.properties that contains all plugin.properties of the unpacked files merged
unfortunately i am not an ant wizard


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Problems Using XText Language in Java project. [message #1738117 is a reply to message #1738088] Fri, 15 July 2016 19:58 Go to previous messageGo to next message
Sam Patterson is currently offline Sam PattersonFriend
Messages: 18
Registered: June 2016
Junior Member
I did all the steps you mentioned above, but again the Xtext, EMF and google imports cannot be resolved.

FYI The process I'm using for adding the JAR to the standalone project is by adding it as a Library via the Build Path.
Re: Problems Using XText Language in Java project. [message #1738118 is a reply to message #1738117] Fri, 15 July 2016 20:09 Go to previous messageGo to next message
Sam Patterson is currently offline Sam PattersonFriend
Messages: 18
Registered: June 2016
Junior Member
So I was able to resolve the imports but it required extracting the generated JAR file and adding all the JARs it contained to my projects build path, I'm not sure why eclipse is not reading them from the Xtext JAR.
Re: Problems Using XText Language in Java project. [message #1738122 is a reply to message #1738118] Fri, 15 July 2016 20:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14729
Registered: July 2009
Senior Member
Cause jars in jars are not allowed in java

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Problems Using XText Language in Java project. [message #1738130 is a reply to message #1738122] Fri, 15 July 2016 22:54 Go to previous messageGo to next message
Sam Patterson is currently offline Sam PattersonFriend
Messages: 18
Registered: June 2016
Junior Member
Does that mean that I will always have to add every required JAR to the build path regardless of what export method I use for the JAR containing my DSL?
Re: Problems Using XText Language in Java project. [message #1738133 is a reply to message #1738130] Sat, 16 July 2016 02:08 Go to previous message
Sam Patterson is currently offline Sam PattersonFriend
Messages: 18
Registered: June 2016
Junior Member
What I ended up doing was using the extract option and simply adding the _UI_Diagnostic line to the plugin.properties file, slightly annoying that simply trying to use a DSL in a standalone project is this troublesome, thank you for the assistance nonetheless.
Previous Topic:how to override and bind ImportUriResolver
Next Topic:Xtext Nodeutil undefined error
Goto Forum:
  


Current Time: Sat Nov 09 02:12:11 GMT 2024

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

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

Back to the top