Errors when running Language-Solution in MPS - dsl

I'm developing an DSL with jetbrains MPS. It's not obvious to use, but I succeeded so far with the design-part.
It's possible to right-click on a solutions node and "run" it, assuming the language is executable (extends executing.util). Plus I use a seperately developed jar as a library (used by the generator).
I build a new project to test, as simple as possible, added some extra nodes and loops in the generator, the error occures and it can't be undone.
As far as I can see, there are several possible sources of errors.
dependencies (they are tricky in MPS)
my jar
wrong cached files or so
Executing "run" causes the following error:
error: could not find or load main class MySolution.package.map_concept
Has some of you out there experience with this?
Tell me, if there are some extra information that would help.

It seems that you have added the jar file as a model to the language, which makes it invisible for the solution. Following the instructions at https://confluence.jetbrains.com/display/MPSD32/Getting+the+dependencies+right#Gettingthedependenciesright-AddingexternalJavaclassesandjarstoaprojectruntimesolutions and creating a separate library solution worked for me.

To me this looks like a problem of the generator. Have you fully rebuilt the project - right-click on the "project" node in the structure tree?
Is the root mapping template correct? If you can share your project, I can have a look.

A small tip that could have saved me some time and might also solve this problem for someone else, even if you followed the instructions in other answers.
When prompted to add your libraries to modules after including the libraries on Java tab, dismiss the window if you already included them in the first place on the Common tab. Otherwise they are listed once despite having been added twice, leading to a compilation failure.

Related

Recommended way to find out what Liferay module provides a class

In my Liferay module, I want to use Liferay's SomeConvenientClass.
What is the recommended way to find out what module provides that class?
So that I can quickly add it to my build.gradle.
Ideally it should either:
return the module's group/name/version,
or say with certitude that this class does not exist in Liferay or is not exported.
Until now I go by trial-and-error and copy/paste from build.gradle files found in the wild, but I am looking for a more reliable method.
I have Liferay installed, and the source code of the exact same Liferay version, if that helps.
I tried mvnrepository but it does not seem to return anything, example: https://mvnrepository.com/search?q=AuditMessageProcessor
Have you tried http://search.maven.org/#advancedsearch ?
For example:
http://search.maven.org/#search|ga|1|c:"AuditMessageProcessor"
This is more an option than a real thing, but this is how I normally do:
be familiar with package naming conventions used by liferay and
inside apps: api, service, web...
be familiar with the bundle structure used by liferay, as their
use of resource folders, which are not so obvious sometimes...
With that in mind, normally on github is enough to navigate: portal->(kernel/impl/services/apps)->app service/api/web...
But this is a natural process that comes when you spend your day inside the code.
Normally, online jar locators help, but quite often I just rely on my IDE.
On my IDE I have all set-up with Spring dependency management, after I extracted the dependencies using Gogo shell with a running bundle. With Gogo you will not find classes, but modules and packs will be listed. (Gogo is probably what you are looking for btw, as it is able to list with version numbers)
Bottom line, if you need a list as a picture of a running environment, use Gogo.
With regards to the master code, just do not trust it! When it comes to modularity and bundles versioning Liferay is pretty messy (read The dependency management problem here: https://www.e-systems.tech/blog/-/blogs/liferay-digital-experience-platform-review-7-0-ga4).
For your step 7, you will need to chose an api version and code against it. The apis are more stable. You can impose a limit for compatibility on you bnd file, which will cause the system to issue warnings. On your environment, you can catch api changes earlier, let's say, you can ask gradle to use a module with an version number but any patch (using the "+" sing), when you build with a fresh cache or if you change gradle resolution strategy to download you dependencies more frequently, if the build breaks, well, you will see it.
Helpful start point: https://dev.liferay.com/pt/develop/reference/-/knowledge_base/7-0/using-the-felix-gogo-shell
This is how I do, it is slow and manual, so don't hesitate to suggest other methods.
Download Liferay's source code if you don't have it already.
Run find . -name SomeConvenientClass.java. If nothing is found, you can be sure the class is not part of Liferay.
In the path to the class, find the src folder level, and go just under that, so for instance if it is modules/apps/collaboration/document-library/document-library-web/src/main/java/com/liferay/document/library/web/portlet/action/DLViewMVCRenderCommand.java then go to modules/apps/collaboration/document-library/document-library-web/.
Hopefully there is a bnd.bnd file there, open it.
If the package of the class is not in the Export-Package section, then either give up (duplicate Liferay's code into your module), or use some dark tricks. If you believe the class should be exported, you can explain your case at https://issues.liferay.com/browse/LPS-70480 for future generations to enjoy.
Module name is the value of Bundle-SymbolicName.
Version is the value of Bundle-Version.
Group is probably com.liferay, although sometimes it is com.liferay.portal, not sure how to tell.
Build. Sometimes it fails because Maven repositories are missing a version, for instance com.liferay.document.library.web 1.0.11 is not available despite being used by DXP fix pack 30. Not sure what to do in such cases except choosing a "similar" version and hoping for the best.

The contents of jar file not found using jar design element of Designer 9

I dropped in an external jar file using the new jar design element of Notes 9.
I tried referencing it from a managed bean, and was able to compile. In runtime, I get a NoClassDefFoundError when I try to use the methods in the jar.
I have refreshed, cleaned, and rebuilded. Version 9 server and designer.
I remember in the past with 8.5.3 there was lots of issues getting the build path correct, but I thought that the new jar design element was supposed to take care of the issues. Most of the research I have found is from the days of 8.5.3 and earlier.
Any advice would be appreciated. (I am purposely not tagging java on this question since I think only XPagers would understand what to advise here)
2 steps to fix a potential issue:
Remove the database from designer. Delete the workspace project (only the project not the entire workspace!)
Add the database back. Check in the Java build path (right click in the navigator view on the database) that the Jar directory is included
Sometimes step 2 alone does the job, so start with that first.
As I remember early R9 versions have had issues with Java/JAR design elements. Put your JARs into WEB-INF folder (Project Browser view), that is my preferred way to use them.
Are JAR files in WebContent/WEB-INF/lib available to Java design elements in Domino Designer?
The solution that Stephan posted worked for my first attempt yesterday, so I am leaving it as the accepted answer. Today, I had to change the package name and the issue cropped up again.
This time nothing that Stephan or Frantisek suggested work to fix the NoClassDefFoundError exception. After trying everything, I came across this blog post. (A big thanks to Panu Haaramo who posted it in the comments in the answer of the SO that Frantisek's links to)
http://lotusandjava.blogspot.fi/2012/10/xpage-javalangnoclassdeffounderror.html
Renaming the jar caused the runtime engine to find the class file properly. Try this as well, as the solutions above to fix this problem. It is certainly an easy fix.

Resolving warnings when building Azure SDK 2.3 project?

I'm getting 110 warnings in my build after installing Azure SDK 2.3 that I don't recall seeing before. They are all for the file "Microsoft.WindowsAzure.targets".
An example of one such warning is:
The element 'PropertyGroup' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003' has invalid child element 'CloudToolsVersion'.
Has anyone else encountered this problem or know the right way to fix it?
Well, it looks like I just needed to close any open editors for msbuild project files to get those to disappear. Other answers I found suggested on the web were to disable schema validation or to extend the schema myself.
Very scary! From your solution and hints from other similar questions, I think I know what's going on: When any build script file (such as a .props) is open in a text editor, it turns on /validate. This is used to see red wavies in the editor and gives the warnings when the project is loaded by any MSBuild task. The schema holds the various element used by the MS targets infrastructure, and doesn't know anything else. I'm not sure what good that is, but there you have it.

C# Accessing classes in a WinForms project from a classes in a Class Library

I have two c# projects within a solution.
The first project is a winforms project with several classes and is called QuantumGUI. The second project is a class library project with several classes and is called QuantumDAL.
My objective is from a class in QuantumDAL to access and set variables in a QuantumGUI class or and in Form.cs.
I have tried adding a reference to QuantumGUI in my QuantumDAL project but received the following error: “A Reference to ‘QuantumGUI’ could not be added. Adding the project as a reference would cause a circular dependency”.
I received a similar error message trying to add Project Dependencies. When you think about it, the error message makes sense.
I’ve tried other, what I consider possible ways of doing this but came up empty. I believe there must be a clever way of getting this done.
If I’m going about this in a wrong way, is there a way to have a “global” class that can be accessed by code in both projects?
Thank you for taking the time to look at this.
There are two problems with what you're trying to do:
First, as the IDE is warning you, you're about to create a circular dependency. This means that the compiler would need to build project A before it can build project B, but it would need to build project B before it can build project A. Neither project can go "first".
The second problem is that your WinForms project is most likely an executable, and you cannot add references to *.exe files via the IDE. You can add those references via the command-line, but the fact that Visual Studio is trying to stop you from doing it should be a red flag that it's a really bad idea.
The correct way to do what you want is to refactor the common classes into a third class library that you reference from both other projects. If needed, you can wire up events (in particular, look at the INotifyPropertyChanged interface and its event) that notify interested observer objects when things change.

Several redeclaration errors occur when AFDownloadRequestOperation is added

When I add AFDownloadRequestOperation I get several errors that result in the inability for me to successfully build my project...
These errors all seem to be of a redeclaration nature. My first mind is to go into the files that display the error and individually delete the other declarations.
But I figured that it may cause more errors and/or not be the best method to resolve my issue. Is anyone familiar with this issue?
I have attached a screenshot of what I see.
My best guess is that Xcode is complaining about there being multiple files in the project that declare the #interface for AFDownloadRequestOperation. Note that AFDownloadRequestOperation has never been a part of the standard AFNetworking library, so I would suggest that you make sure that you are using the most up-to-date version of the canonical source available.
You may find CocoaPods to be helpful for managing your dependencies, as an alternative to manually adding source files to your project.

Resources