Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue in generating AST #97

Open
sundar-sarvam opened this issue Aug 21, 2023 · 4 comments
Open

Issue in generating AST #97

sundar-sarvam opened this issue Aug 21, 2023 · 4 comments

Comments

@sundar-sarvam
Copy link

sundar-sarvam commented Aug 21, 2023

Exception in thread "main" java.lang.NoClassDefFoundError: org/antlr/v4/runtime/tree/ParseTree
        at CobolParserDemo.parseCobolFile(App.java:27)
        at CobolParserDemo.main(App.java:14)
Caused by: java.lang.ClassNotFoundException: org.antlr.v4.runtime.tree.ParseTree
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
        ... 2 more

The issue seems to be pointing that the ANTLR4 library is not available to be referenced.

I have added Proleap-cobol-parser.4.0.0.jar as "Referenced libraries" to the Java project (not Maven project). It was created after successfully building the proleap-cobol-parser repo locally. I think I need to add Proleap-cobol-parser-sources.jar as "Referenced libraries" as well but when I add it in Visual Studio Code, it's not getting added.

Is this a common issue and any workaround to it?

@uwol
Copy link
Owner

uwol commented Aug 21, 2023

Hi @sundar-sarvam ,

the problem is that in your setup the ANTLR library is not on the class path as a dependency.

This project uses Maven for dependency management. When importing the code into Eclipse or Intellij IDEA, those IDEs should automatically recognize the Maven pom.xml and fetch all dependencies, including ANTLR as configured in here.

To my understanding you try to use Visual Studio Code for Java here -> support for larger Maven projects in Visual Studio Code was problematic for me in the past -> I definitely recommend Intellij or Eclipse!

Best
Ulrich

@sundar-sarvam
Copy link
Author

sundar-sarvam commented Aug 21, 2023

Thanks @uwol . I realised that for some reason Proleap-cobol-parser-sources.jar wasn't importable (tried different ways: created a java project, maven project and tried to add dependencies, copied the .jars to lib directory of the workspace, etc. but didn't work). At the end, I download jar for ANTLR4 and slf4j-api separately and then the ANTLR issue got resolved.

Screenshot 2023-08-21 at 7 37 27 PM

But now I am facing the below warning:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Level Number: 1

On referring this link: https://www.slf4j.org/codes.html#StaticLoggerBinder, it seems to not be an issue (right?).

I am new to Java but very comfortable with VSC, so can't change IDE so easily. I am able to successfully run this example: https://stackoverflow.com/questions/49353699/getting-static-function-call-graph-of-a-cobol-program-in-java and Hello world example using the above dependency workaround.

@uwol
Copy link
Owner

uwol commented Aug 21, 2023

Yes, Logback is missing from your dependencies.

@sundar-sarvam
Copy link
Author

Screenshot 2023-08-21 at 7 54 07 PM On the left you see that I have include `logbook` and `junit` dependency as well but I still get the above warning: `SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants