Andrew Hall Andrew Hall - 3 months ago 85
Java Question

Spring Boot requiresUnpack is not upacking at runtime

I'm building an executable jar via the spring-boot maven plugin. I need to unpack one of the dependent jar so that xml files can be properly read at runtime. I followed the documentation regarding unpacking libs. My plugin config is as follows:

<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<requiresUnpack>
<dependency>
<groupId>com.deep6analytics.pipeline</groupId>
<artifactId>pipeline-services-ctakes</artifactId>
</dependency>
</requiresUnpack>
</configuration>
</plugin>
</plugins>


I checked the contents of the jar and verified that the unpacking information was encoded in the jar:

$ zipnote target/pipeline-apps-annotation-server-1.0-SNAPSHOT.jar | grep -C 1 UNPACK
@ BOOT-INF/lib/pipeline-services-ctakes-1.0-SNAPSHOT.jar
UNPACK:1e6eda0ca9f1b740c4aba6058cac74a5084f1706
@ (comment above this line)


According to the documentation, at runtime, I expected to see a "spring-boot-libs" directory within my $TMPDIR:


Specify each library as a <dependency> with a <groupId> and a <artifactId> and they will be unpacked at runtime in $TMPDIR/spring-boot-libs.


However, when I run the application, I check the $TMPDIR and do not see the unpacked directory. As a consequence, my application fails to start:

ls -la $TMPDIR

drwxr-xr-x 3 staff 102 Aug 10 23:40 pipeline-apps-annotation-server-1.0-SNAPSHOT.jar-spring-boot-libs-96fe7360-b23b-4caa-a2ce-75aa0300a417
drwxr-xr-x 3 staff 102 Aug 10 23:27 pipeline-apps-annotation-server-1.0-SNAPSHOT.jar-spring-boot-libs-a06a2373-0694-42e9-bee1-29191b3b764a
drwxr-xr-x 4 staff 136 Aug 10 20:54 sp_update
drwx------ 2 staff 68 Aug 10 11:30 ssh-azEJDYkZH6ho
drwxr-xr-x 3 staff 102 Aug 10 15:05 tomcat.104726406473930572.8085
drwxr-xr-x 3 staff 102 Aug 10 23:38 tomcat.1527552147767629466.8080
drwxr-xr-x 3 staff 102 Aug 10 23:13 tomcat.1546871599966723864.8080


Does anyone see what I'm doing wrong, or am I misunderstanding something?

Answer

The documentation is a little misleading. The unpacked directories are there:

drwxr-xr-x    3  staff      102 Aug 10 23:40 pipeline-apps-annotation-server-1.0-SNAPSHOT.jar-spring-boot-libs-96fe7360-b23b-4caa-a2ce-75aa0300a417
drwxr-xr-x    3  staff      102 Aug 10 23:27 pipeline-apps-annotation-server-1.0-SNAPSHOT.jar-spring-boot-libs-a06a2373-0694-42e9-bee1-29191b3b764a

Those directories should contain the jars files that you have marked as needing to be unpacked from your executable jar.

I've opened an issue to correct the documentation.

Comments