4

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?

Andrew Hall
  • 153
  • 1
  • 7

2 Answers2

4

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.

Andy Wilkinson
  • 108,729
  • 24
  • 257
  • 242
  • 1
    Ok - I also thought the jar would be "exploded" so that each of the resources within the jar would reside as a file on disk. So some clarity around what "unpacking" actually entails would helpful. As a follow on - how do I extract the resources within the jar onto the file system so they can read directly? – Andrew Hall Aug 11 '16 at 15:42
  • 1
    I'm not sure why you'd want to do it, but you can access a resource via ClassLoader.getResourceAsStream() and then write it out to a file. You can do that without the intermediate unpacking step, though – Andy Wilkinson Aug 11 '16 at 18:00
  • 2
    Unfortunately, I'm using an infrastructure that recurses through nested xml documents - it assumes that all the included documents reside on the file system. So there isn't anything I can do to change that fact. So the short of it is that I need these files pulled from the jar and placed on the file system. – Andrew Hall Aug 11 '16 at 18:32
0

On linux it is just /tmp folder. This variable : $TMPDIR did not worked for me

masterdany88
  • 5,041
  • 11
  • 58
  • 132