-
Notifications
You must be signed in to change notification settings - Fork 60
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
java.lang.ExceptionInInitializerError - META-INF? #167
Comments
Hi, thanks for reaching out. I think the problem here is how you try to include my library in your script. Have you already tried to create a simple Java application that is built by Maven or Gradle? You can then include my library as a dependency in the usual way and then run the Please try this approach. I'm pretty sure it will work. |
Hi Peter, Thank you for your fast answer. I have created a Java maven project, added the jar to dependencies and then created a basic main to call
But I get the same error. I have tried to use the jar as standalone, as well as other Lingua functions in the very same main (such as the examples in the README) and all these worked fine, even using Language.GALICIAN (the language I added to the .kt files). Is there any example of how to call Thank you again and best regards, María |
Hi María, I don't have time to run your project but why do you always try to add the file <dependency>
<groupId>com.github.pemistahl</groupId>
<artifactId>lingua</artifactId>
<version>1.2.2</version>
</dependency> Maven will then download Lingua and its transitive dependencies from Maven Central automatically for you. There is no need to put the JAR file in a lib folder in your project. This standalone JAR file is only meant to be used in Java projects which do not make use of Maven or Gradle at all. There might be something wrong with the standalone JAR, I will check it as soon as I have time. But until then, simply don't use the standalone JAR and let Maven do the work for you. Another important thing: |
Thank you again for the reply. The reason why I add the .jar file because I am trying to add a new language (Galician), so I added all the required information of this language to the .kt files as mentioned in the "10.1 How to add new languages?" section in the readme, so now I can use Language.GALICIAN. Then I compiled the .jar file, but found the error when calling to LanguageModelFilesWriter.createAndWriteLanguageModelFiles. In any case, I tested also the original .jar in the last release and the maven dependency and the error persists when calling LanguageModelFilesWriter, so it looks like some internal problem only in that part of the code, since the language detection works fine. Hope I am more clear know, probably I didn't explain myself correctly before. |
Hah, I was totally on the wrong track. I looked closer at your stack trace and after asking Google, it looks like there is a compatibility problem between the Moshi library that performs the JSON (de)serialization and the Gradle Shadow plugin which creates the JAR file. I just don't know how to fix it yet. In the meantime, you can try to call the |
Thank you again for your patience! I have tried to do so but the same error appears, probably because I am not familiar with Kotlin and I am using Java dependencies somewhere. I will try to check the Moshi/plugin compatibility problem. |
I've just tried and it works fine for me if I execute the code within an IDE such as IntelliJ IDEA. Just stop building the JAR with all dependencies for now. In the file fun main() {
LanguageModelFilesWriter.createAndWriteLanguageModelFiles(
inputFilePath = Path("/Users/pemistahl/training.txt"),
outputDirectoryPath = Path("/Users/pemistahl/language-models"),
language = Language.ENGLISH
)
} You can also run Does that work for you in IntelliJ IDEA or VSCode? What IDE or editor are you using? |
Alright, so updating the Gradle ShadowJar plugin has fixed your problem. I've just verified it locally. Just create the JAR with dependencies again from the updated main branch and you should be fine. |
Great, thank you so much! It works smoothly now, I close the issue. |
We are following the instructions in "10.1 How to add new languages?" section in the readme in order to add the Galician language. Nevertheless, we got stuck in step 5. We correctly included Galician in all the required files and built the jar file with dependencies. Nevertheless, when trying to call LanguageModelFilesWriter.createAndWriteLanguageModelFiles with the following script:
We get the following error:
Do you know the reason?
Thank you and best regards,
María
The text was updated successfully, but these errors were encountered: