HeidelTime / heideltime

A multilingual, cross-domain temporal tagger developed at the Database Systems Research Group at Heidelberg University.
GNU General Public License v3.0
342 stars 67 forks source link

Can't open resources folder when running jar #76

Open MMel1ssa opened 6 years ago

MMel1ssa commented 6 years ago

Hello, I'm having this error when I try to run a jar that uses heideltime

> java -jar myProject.jar
> HeidelTimeStandalone                     : HeidelTimeStandalone initialized with language french
> HeidelTimeStandalone                     : trying to read in file config.props
java.lang.NullPointerException
        at de.unihd.dbs.uima.annotator.heideltime.resources.NormalizationManager.<init>(NormalizationManager.java:63)
        at de.unihd.dbs.uima.annotator.heideltime.resources.NormalizationManager.getInstance(NormalizationManager.java:76)
        at de.unihd.dbs.uima.annotator.heideltime.HeidelTime.initialize(HeidelTime.java:153)
        at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.initialize(HeidelTimeStandalone.java:236)
        at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.<init>(HeidelTimeStandalone.java:179)
       ....
> HeidelTimeStandalone                     : HeidelTime could not be initialized

It seems that the program cannot read the content of the resources folder Any solutions ?

vidyaramanathan commented 6 years ago

Hi - We are having a springboot app that uses Heideltime and experiencing the same NPE when booting the app. When I was debugging, I figured out that the

de.unihd.dbs.uima.annotator.heideltime.resources.ResourceScanner

is not able to get the jarFilePath to load the normalization resources (may be since its a jar inside jar).

Is there any workaround to load the language resources or pass the resource path to the HeideltimeStandalone from config.props ?

2018-07-26T22:13:19.929Z severity="INFO" logger="HeidelTimeStandalone" HeidelTimeStandalone initialized with language english  

java.lang.NullPointerException
    at de.unihd.dbs.uima.annotator.heideltime.resources.NormalizationManager.<init>(NormalizationManager.java:63)
    at de.unihd.dbs.uima.annotator.heideltime.resources.NormalizationManager.getInstance(NormalizationManager.java:76)
kno10 commented 6 years ago

jar inside jar never works well with Java. The built-in resource loader of Java does not support this for all I know, so don't do that. Make sure the resources folder can be located using the standard Java mechanisms.

AlJohri commented 6 years ago

@vidyaramanathan @kno10 I ran into this exact same issue with spring boot. It works perfectly fine with mvn spring-boot:run but if I try to run it using java -jar target/myapp.jar I get the same error shown above.

You can see the (dockerized) app here: https://github.com/AlJohri/heideltime-api

Any insight into how I can get this to work with java -jar? I even tried a package spring-boot-jar-resources to no avail

Sources:

brykneval commented 5 years ago

HeidelTimeStandalone.java

public static void readConfigFile(String configPath) {
        InputStream configStream = null;
        try {
            logger.log(Level.INFO, "trying to read in file "+configPath);
            configStream = ### new FileInputStream(configPath);

FileInputStream doesn't work well jar

TheFrisbeeHamster commented 4 years ago

Is there any solution for this? I have the same problem but with a UIMA pipeline built with DKPro.

Here is the exception stack trace:


        at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:268)
        at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initialize(PrimitiveAnalysisEngine_impl.java:175)
        at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
        at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
        at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
        at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:407)
        at org.apache.uima.analysis_engine.asb.impl.ASB_impl.setup(ASB_impl.java:256)
        at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initASB(AggregateAnalysisEngine_impl.java:435)
        at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initializeAggregateAnalysisEngine(AggregateAnalysisEngine_impl.java:379)
        at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initialize(AggregateAnalysisEngine_impl.java:192)
        at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
        at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
        at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
        at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:407)
        at org.apache.uima.analysis_engine.asb.impl.ASB_impl.setup(ASB_impl.java:256)
        at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initASB(AggregateAnalysisEngine_impl.java:435)
        at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initializeAggregateAnalysisEngine(AggregateAnalysisEngine_impl.java:379)
        at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initialize(AggregateAnalysisEngine_impl.java:192)
        at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
        at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
        at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
        at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:331)
        at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:448)
        at org.apache.uima.fit.pipeline.SimplePipeline.runPipeline(SimplePipeline.java:166)
        at de.ubt.ai4.ma.pipeline.MainPipeline.runMainPipelineClient(MainPipeline.java:90)
        at de.ubt.ai4.ma.application.AnnotatorRESTController.annotate(AnnotatorRESTController.java:56)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1591)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
        at de.unihd.dbs.uima.annotator.heideltime.resources.NormalizationManager.<init>(NormalizationManager.java:63)
        at de.unihd.dbs.uima.annotator.heideltime.resources.NormalizationManager.getInstance(NormalizationManager.java:76)
        at de.unihd.dbs.uima.annotator.heideltime.HeidelTime.initialize(HeidelTime.java:153)
        at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:261)
        ... 75 more```
kno10 commented 4 years ago

@TheFrisbeeHamster I don't think this actually is a Heideltime issue, but supposedly a re-packaging issue on your side (or by DKPro).

Heideltime can't load its resource files. Either you lost them when building your jar, or you have jar-inside-jar, which is also problematic and should rather be avoided.

The trivial workaround is to provide the resources by other means, such as extracting them and including them in your packaging manually, as you would do if you customize them. Or you add the original heideltime jar to your classpath directly, that should also work.

TheFrisbeeHamster commented 4 years ago

@kno10 Thank you for your answer. Yes, I have a jar inside a jar. But I can't figure out how to put this to work. Earlier, I tried it with Maven:

<dependency>
    <groupId>com.github.heideltime</groupId>
    <artifactId>heideltime</artifactId>
    <version>2.2.1</version>
</dependency>

But this gave me the error in my last post.

I tried to put the heideltime-2.2.1.jar into my classpath as a Referenced Library and installed it like described here and put it like this into my pom.xml:

<dependency>
    <groupId>com.github.heideltime</groupId>
    <artifactId>heideltime</artifactId>
    <version>2.2.1</version>
    <scope>system</scope>
<systemPath>C:\Users\Username\.m2\repository\com\github\heideltime\heideltime\2.2.1\heideltime-2.2.1.jar</systemPath>
</dependency>

Now I am getting this exception stack trace:

java.lang.ClassNotFoundException: de.unihd.dbs.uima.annotator.treetagger.TreeTaggerWrapper
        at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.8.0_231]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_231]
        at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:92) ~[masterarbeit-pipeline-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_231]
        at de.ubt.ai4.ma.annotator.NestedNamedEntityAnnotator.setupNERAnnotator(NestedNamedEntityAnnotator.java:54) ~[classes!/:0.0.1-SNAPSHOT]
        at de.ubt.ai4.ma.pipeline.PipelineFactory.createPipeline(PipelineFactory.java:131) ~[classes!/:0.0.1-SNAPSHOT]
        at de.ubt.ai4.ma.pipeline.MainPipeline.runMainPipelineClient(MainPipeline.java:86) ~[classes!/:0.0.1-SNAPSHOT]
        at de.ubt.ai4.ma.application.AnnotatorRESTController.annotate(AnnotatorRESTController.java:56) ~[classes!/:0.0.1-SNAPSHOT]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_231]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_231]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_231]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_231]
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) ~[spring-webmvc-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888) ~[spring-webmvc-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) ~[spring-webmvc-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) ~[tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.29.jar!/:9.0.29]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.2.RELEASE.jar!/:5.2.2.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526) [tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) [tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) [tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367) [tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860) [tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1591) [tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_231]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_231]
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.29.jar!/:9.0.29]
        at java.lang.Thread.run(Unknown Source) [na:1.8.0_231]

@kno10 Could you describe how you would extract and include the resources of heideltime in the packaging manually in more detail, please? I am using Maven and the Spring Boot Maven Plugin. I also tried to use the Maven Shade Plugin and the Maven Assembly Plugin but I always had errors with them, too.

kno10 commented 4 years ago

@TheFrisbeeHamster "ClassNotFoundException" obviously shows that you didn't succeed at adding the jar to your runtime (!) classpath. This almost certainly is due to the way Spring Boot builds the jar. Because I've never used Spring, I cannot help you there. Nor do I used Tomcat. So I really cannot help you to build a correct jar with these tools. All that I can tell you is that the classes respectively the resources do not seem to be correctly in the jar.

TheFrisbeeHamster commented 4 years ago

@kno10 Thanks. How do you package HeidelTime in general then, regardless of Spring Boot or if it is the Standalone or the UIMA version? I am refering to the initial issue question here now (https://github.com/HeidelTime/heideltime/issues/76#issue-337825509). At the end of an application, there is a final jar mostly. And when I put the HeidelTime dependency into my pom.xml, HeidelTime will always be a jar inside a jar and I can't do anything about it. Or can I? Has anybody successfully built and packaged a project with HeidelTime? I can't imagine that this is not possible.

kno10 commented 4 years ago

"jar in jar" is not natively supported by Java, that is not Heideltimes fault. If you absolutely insist of having a single jar, then you need to take care of repacking everything. If you lose the resources when repacking, you will get above NPE; but that is because you lost some files... that is why so many tools for "fat jars", "shadow jars" etc. exist, but none seems to be the ultimate and reliable solution... With modularization in Java 9, it seems more clear than before that the intended way is to actually have multiple jars on your classpath. I usually keep all jars in a folder, and then use java -cp jars/* - i.e., I manage the classpath. This way, I can use all the original jars; it would even be possible to update a dependency (assuming no API changes) without recompiling anything.

TheFrisbeeHamster commented 4 years ago

Thanks again for your answer. After quite a few hours I solved my problem with the Spring Boot Maven Plugin. The plugin has a parameter called <requiresUnpack>. Adding this parameter with the heideltime-dependency lets me package my application and run it successfully.

Here is the important snippet from my pom.xml:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <mainClass>${start-class}</mainClass>
        <layout>ZIP</layout>
        <requiresUnpack>
            <dependency>
                <groupId>com.github.heideltime</groupId>
                <artifactId>heideltime</artifactId>
            </dependency>
        </requiresUnpack>
    </configuration>
</plugin>
kno10 commented 4 years ago

Thanks for sharing the solution. This may also help @MMel1ssa, @vidyaramanathan, and @AlJohri.