215 Commits

Author SHA1 Message Date
Dave Syer
ed15345df1 Try to make Jetty scan TLDs in nested JARs
Jetty apparently does it differently (different version of
Jasper maybe), so you need a unique jarFileURL for each
nested JAR (previously they were all set to the parent
archive URL).

Also added the root of the main archive as a valid
document root.

For gh-367
2014-02-19 13:41:09 +00:00
Phillip Webb
dfe6de8c1f Fallback to JVM URL handler on exception
Update the executable JAR `Handler` to fallback to the JVM handler if
the jar cannot be opened. This prevents exceptions when trying to
open URLs in the form "jar:jndi:/localhost...".

Fixes gh-347
2014-02-13 11:12:46 -08:00
Phillip Webb
1552759584 Fix package tangle by moving AsciiBytes 2014-02-03 17:26:10 -08:00
Phillip Webb
3e7af3ddb8 Improve exception messages on nested jar failure
Updates gh-284
2014-01-29 23:00:20 -08:00
Phillip Webb
14bc06a387 Pull-up duplicated code to Launcher 2014-01-29 22:46:39 -08:00
Phillip Webb
c852fb5a79 Update packaged JARs to use standard JarLauncher
Change CLI generated JARs to use the standard `JarLauncher` instead of
a custom `JarRunner`. The `PackagedSpringApplicationLauncher` is used
as the `Start-Class` which in turn calls `SpringApplication.run()`.
2014-01-29 16:01:50 -08:00
Andy Wilkinson
96e10104e4 Add a command to produce a self-contained executable JAR for a CLI app
A new command, jar, has been added to the CLI. The command can be
used to create a self-contained executable JAR file from a CLI app.

Basic usage is:

spring jar <jar-name> <source-files>

For example:

spring jar my-app.jar *.groovy

The resulting jar will contain the classes generated by compiling the
source files, all of the application's dependencies, and entries
on the application's classpath.

By default a CLI application has the current working directory on
its classpath. This can be overridden using the --classpath option.
Any file that is referenced directly by the classpath is always
included in the jar. Any file that is found a result of being
contained within a directory that is on the classpath is subject to
filtering to determine whether or not it should be included. The
default includes are public/**, static/**, resources/**,
META-INF/**, *. The default excludes are .*, repository/**, build/**,
target/**. To be included in the jar, a file must match one of the
includes and none of the excludes. The filters can be overridden using
the --include and --exclude options.

Closes #241
2014-01-29 14:05:15 +00:00
Phillip Webb
ef2eb8af6c Fix URL from String creation to work on Windows
Fixed the nested jar URLHandler to correctly deal with files on
Windows.

Fixes gh-269
2014-01-27 21:24:10 -08:00
Phillip Webb
0afdb71345 Better getRootJar exception capturing 2014-01-27 19:59:57 -08:00
Dave Syer
91998d5942 Add loader.args to PropertiesLauncher
Also new section of README for propery keys used by the
launcher.
2014-01-27 13:20:36 +00:00
Phillip Webb
01550fcec6 Allow new URL(String) with nested JARs
Update JarFile to allow the custom registration of a JAR
`URLStreamHandler` that allows `jar:` URLs to be constructed from
Strings. This removes the previous requirement that all nested JAR URLs
be created with a 'context'.

To supported nested JARs the `java.protocol.handler.pkgs` system
property is changed so that our custom URLHandler is picked for 'jar'
protocols in preference to the Java default.

Fixes gh-269
2014-01-26 22:55:22 -08:00
Phillip Webb
c1f8fd2bac Fix some compile warnings 2014-01-26 22:55:07 -08:00
Phillip Webb
43e54d38f7 Make fields private where possible 2014-01-21 16:29:07 -08:00
Phillip Webb
ac54d7fe3c Final polish before 1.0.0.RC1 2014-01-21 16:28:17 -08:00
Phillip Webb
853b0a8027 Fix some maven warnings 2014-01-21 10:56:09 -08:00
Phillip Webb
cdda330acd Update copyright header for files changed in 2014 2014-01-21 10:27:10 -08:00
Phillip Webb
4fc9dfc2d5 Revert "Add launcher.count as useful performance testing aid"
This reverts commit e1605b46919b7452f5af7773a116871a8e475424.
2014-01-15 10:31:08 -08:00
Dave Syer
e1605b4691 Add launcher.count as useful performance testing aid 2014-01-14 13:03:16 +00:00
Phillip Webb
d125357bf6 Protect against JARs with different local headers
Fix JarEntryData to re-read the local header, rather than relying on
the central directory record.

This protects against the situation where a JAR file is written with an
'Extra Field Length' that is different in the local header to the
central directory header.

This appears to be the case with aspectj 1.7.4 which contains the
following central directory file header for ProceedingJoinPoint:

	50 4B 01 02     signature
	14 03           version made by
	0A 00           version required
	00 00           general
	08 00           compress methods
	0E 40 59 43     last modified
	2D 59 20 70     crc
	EC 00 00 00     csize
	8D 01 00 00     size
	2A 00           fname len
	00 00           ext field len
	00 00           file comment len
	00 00           disk num
	00 00           int file att
	00 00 A4 81     ext file att
	97 F3 00 00     relative offset of the local file header
	...             file name

and the following local header:

	50 4B 03 04     signature
	0A 00           version required
	00 00           general
	08 00           compress method
	0E 40 59 43     last modified
	2D 59 20 70     crc
	EC 00 00 00     csize
	8D 01 00 00     size
	2A 00           fname len
	14 00           ext field len
	...             file name
	...             extra field

Note that the 'ext field len' is 0x00 in the central record but 0x14 in
the local record.

Fixes gh-203
2014-01-10 16:57:51 -08:00
Phillip Webb
47da8a817a Polish 2014-01-10 13:06:54 -08:00
Dave Syer
7b58718453 Add missing YAML file for test 2014-01-08 07:30:58 +00:00
Dave Syer
4e1245d9ee Restore changes from 0332501 (fix class loader test failure) 2014-01-08 07:30:09 +00:00
Dave Syer
bf69da3983 Ignore failing test as short term measure 2014-01-07 19:48:56 +00:00
Janne Valkealahti
780397bd6b Fix for wildcard recursive classpath handling
Previous fix for handling wildcard entries in a classpath
imposed a new problem in a case where entry is a directory
with a jar files but also contains a lot of nested directories.

For example entry "./*" resulted for scanning whole disk starting
from "/". In case of default hadoop classpath, it scanned everything
under hadoop's installation. On some cases this deep scan was hidden
and was revealed by NPE's for file access exceptions.

When we want to support wildcard entries we only want to get
jar files from that directory, while boot itself have a need
to travel recursively to find classfiles from an expoded archive.

We handle this case by using recursive(true by default) flag in
ExplodedArchive and this flag is set to false in PropertiesLauncher
if we match wildcard.
2014-01-07 18:05:10 +00:00
Dave Syer
033250195b Allow user to specify classLoader as loader property
PropertiesLauncher now supports creating its own class loader
from looader.classLoader property. It will succeed if the
implementation specified has a default constructor or one
that takes a parent class loader, or one that takes a URL[]
and a parent class loader (like URLClassLoader).
2014-01-06 11:40:20 +00:00
Phillip Webb
1bcd3de7b5 Polish 2014-01-02 12:10:37 -08:00
Janne Valkealahti
da889efde7 Fix PropertiesLauncher for wildcard entries in parent classpath
This small change now plays nice with wildcard classpath
entries coming from a parent classloader as its urls.
2013-12-31 12:01:53 +00:00
Dave Syer
3c7361fb3e Support for wildcard paths in PropertiesLauncher 2013-12-30 16:14:10 +00:00
Dave Syer
ea59976277 Extract package discovery to separate method 2013-12-30 14:24:54 +00:00
Guo Du
2a10503167 fixed ExplodedArchive which fail on windows
* when run 'java org.springframework.boot.loader.JarLauncher'

Fixes gh-176
2013-12-22 09:35:34 +00:00
Dave Syer
99fd32d408 Attempt to make URL comparison windoze proof 2013-12-16 07:02:45 +00:00
Phillip Webb
64f32893bb Source format and clean-up 2013-11-16 00:08:18 -08:00
Phillip Webb
883fd9162f Polish 2013-11-16 00:08:17 -08:00
Phillip Webb
d2678e08de Improve startup performance for nested JARs
Refactor spring-boot-loader to work directly with low level zip data
structures, removing the need to read every byte when the application
loads.

This change was initially driven by the desire to improve tab-completion
time when working with the Spring CLI tool. Local tests show CLI
startup time improving from ~0.7 to ~0.22 seconds.

Startup times for regular Spring Boot applications are also improved,
for example, the tomcat sample application now starts 0.5 seconds
faster.
2013-11-15 16:15:47 -08:00
Andy Wilkinson
b0c6d8060c Remove Git plugin from Spring Boot tools
The Git plugin was primarily being used to provide version information
that Boot's maven plugin can add into the MANIFEST.MF of the uber-jars
that it creates under the Spring-Boot-Commit-Id attribute.

This commit removes the Git plugin from Boot's own projects, but
leaves it in the spring-boot-starter-parent for use by Spring
Boot-based applications.

The attribute in the uber-jars' MANIFEST.MF has been replaced with a
Spring-Boot-Version attribute. The value of this attribute is the
implementation version of Repackager class's package.
2013-10-22 15:54:05 +01:00
Phillip Webb
6220aba983 Allow 'java -jar' to work with signed nested jars
Fix RandomAccessJarFile to correctly read certificate information as
jar entries are loaded. This change allows signed nested jars to be
used as JCE providers.
2013-10-17 17:19:51 -07:00
Phillip Webb
5c6dd52e9a Polish 2013-10-17 14:12:42 -07:00
Dave Syer
fede0d1c98 Add profiles to /env 2013-10-16 13:42:13 -04:00
Dave Syer
47cd5dd679 Tooling for PropertiesLauncher in JAR archives
To use PropertiesLauncher instead of JarLauncher in an
executable JAR we have provided tooling support. In Maven
(using the starter parent to default some of the settings):

    <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <configuration>
        <layout>ZIP</layout>
      </configuration>
    </plugin>

in Gradle:

    apply plugin: "spring-boot"
    springBoot {
        layout = 'ZIP'
      }
    }

[Fixes #58837492] [bs-330] Add tooling for PropertiesLauncher
2013-10-16 08:49:51 -04:00
Dave Syer
ea11dafcbd Extend PropertiesLauncher to load nested archives
PropertiesLauncher can now be used to run an executable jar, and by
default it will pick up nested archives in lib/ (where the Boot
tools puts them). User can provide loader.path (colon-separated)
to change the nested path.

[#58837492] [bs-330] Add tooling for PropertiesLauncher
2013-10-15 11:08:45 -04:00
Dave Syer
d4d9ebcabd Small re-org of PropertiesLauncher 2013-10-15 09:56:52 -04:00
Dave Syer
be1263500d Ensure env vars are consulted for PATH 2013-10-14 16:07:50 -04:00
Dave Syer
281c650251 Add git commit id to MANIFEST in boot tools repackager 2013-10-14 16:06:32 -04:00
Dave Syer
b0c54a6588 Add parent class loader entries if possible
...otherwise you can see cryptic NoClassDefFound errors
because the application class was loaded from the parent
on the file system, but then it doesn't have access to the
child loaders nested jars.
2013-10-14 16:02:04 -04:00
Dave Syer
114b7a5e95 Ensure UPPER_CASE overrides work in PropertiesLauncher 2013-10-14 11:16:40 -04:00
Phillip Webb
35ff983b40 Prevent duplicate resource enumeration form loader
Fix LaunchedURLClassLoader to only enumerate resources from the
rootLoader and the URLs.

Commit cd2c189 (Support javaagent instrumentation with loader) added
a parent classloader and used filtering in the loadClass() method
to ensure classes were loaded from the appropriate location. The change
in parent means that locally packaged resources are found twice, once
from the parent, and once from the self archive URL.

LaunchedURLClassLoader now overrides getResource and getResources to
filter out the parent classloader and instead only add resources from
the root classloader and the URLs.

Issue: #56232870
2013-10-09 11:09:03 -07:00
Phillip Webb
b772f7c2e4 Polish
Minor formatting and consistent copyright header.
2013-10-08 20:30:45 -07:00
Phillip Webb
15bc25dc29 Further re-organization of launcher code 2013-09-24 15:31:24 -07:00
Dave Syer
0e0eb7d3fa Add loader.system (flag to copy properties to System) 2013-09-24 09:23:44 +01:00
Dave Syer
a3af83cf96 Add internal property replacement
E.g. in application.properties (for launcher)

foo: Application
loader.main: my.${foo}
loader.path: etc
2013-09-24 09:15:30 +01:00