Commit Graph

93 Commits (5e1913576e3ad597f64b79e90de8c195ae01e03b)

Author SHA1 Message Date
Phillip Webb d4d3ffa93c Unify versions in POMs started by the invoker
Unify the versions used in integration tests launched by the
maven-invoker-plugin. Allows for already cached local copies to be
used, hopefully speeding up the build.
11 years ago
Phillip Webb 1a475102de Polish 11 years ago
Andy Wilkinson ee08667e81 Exclude Java agent jars from class path of launching class loader
ExecutableArchiveLauncher creates a ClassLoader that is used by the
Launcher to load an application’s classes. During the creation of this
ClassLoader URLs from another ClassLoader are copied over. This was
resulting in Java agents that are added to the system class loader
via the -javaagent launch option being available on both the system
class loader and the created class loader. Java agents are intended to
always be loaded by the system class loader. Making them available on
another class loader breaks this model.

This commit updates ExecutableArchiveLauncher so that it skips the URLs
of any Java agents (found by examining the JVM’s input arguments) when
copying URLs over to the new classloader, thereby ensuring that Java
agents are only ever loaded by the system class loader.

Fixes #863
11 years ago
Phillip Webb 8bcda1bcbe Polish 11 years ago
Phillip Webb 2cadf4165f Merge branch '1.0.x'
Conflicts:
	spring-boot-dependencies/pom.xml
	spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java
11 years ago
Phillip Webb 6a644e2e23 Protect against malformed URLs on Windows
Update JarFile to correctly create system independent URLs to prevent
potential URISyntaxExceptions when running on Windows.

Fixes gh-836
11 years ago
Dave Syer 845a86d548 Monkey with JarUrlConnection to make it work when LANG unset
The problem all along has been in AsciiBytes, so the fix in
commit ce3aaf was just a stop gap for a system where multi-byte
characters are supported but the default encoding is not UTF-8 (e.g.
most Windows systems). The real solution is not to leave it to
chance and always pick an encoding for the JarEntry names (i.e.
in AsciiBytes).

(Cherry picked from commit 06e364a9ff)

Fixes gh-764
11 years ago
Dave Syer 06e364a9ff Monkey with JarUrlConnection to make it work when LANG unset
The problem all along has been in AsciiBytes, so the fix in
commit ce3aaf was just a stop gap for a system where multi-byte
characters are supported but the default encoding is not UTF-8 (e.g.
most Windows systems). The real solution is not to leave it to
chance and always pick an encoding for the JarEntry names (i.e.
in AsciiBytes).

Fixes gh-764
11 years ago
Phillip Webb f53ee406c1 Merge branch '1.0.x' 11 years ago
Artem Bilan 471e6af2af Make `loader` Windows compatible
The encoding of UTF-8 (et al.) chars in the
JarUrlConnection has to be made explicit, otherwise
Wdinows apparently does not pick the default(?).

Fixes gh-711, Fixes gh-753
11 years ago
Phillip Webb 6025f45aa0 Polish 11 years ago
Dave Syer 689eb3e148 Add URLs from parent classloader in executable jar
$ (cd spring-boot-tools; mvn clean install -DskipTests=true)
$ (cd spring-boot-samples/spring-boot-sample-simple/; mvn clean package)
$ java -jar spring-boot-samples/spring-boot-sample-simple/target/spring-boot-sample-simple-1.1.0.BUILD-SNAPSHOT.jar

(vanilla executable jar archive: works)

$ java -cp spring-boot-samples/spring-boot-sample-simple/target/spring-boot-sample-simple-1.1.0.BUILD-SNAPSHOT.jar:spring-boot-tools/spring-boot-loader/src/test/resources/jars/app.jar org.springframework.boot.loader.JarLauncher

(jar archive plus vanilla plugin: works)

$ (cd spring-boot-samples/spring-boot-sample-simple/target; rm -rf app && mkdir $_ && cd $_ && jar -xf ../*.jar)
$ java -cp spring-boot-samples/spring-boot-sample-simple/target/app/ org.springframework.boot.loader.JarLauncher

(exploded directory: works)

$ java -cp spring-boot-tools/spring-boot-loader/s:spring-boot-tools/spring-boot-loader/src/test/resources/jars/app.jar org.springframework.boot.loader.JarLauncher

(exploded directory with plugin jar: works)

Potential fix for gh-529
11 years ago
Artem Bilan da5eae3ca5 Make `loader` Windows compatible
The encoding of UTF-8 (et al.) chars in the
JarUrlConnection has to be made explicit, otherwise
Wdinows apparently does not pick the default(?).

Fixes gh-711, Fixes gh-753
11 years ago
sopov.ivan 174b654faf minor test fixes
Reverting arguments in assertEquals where constant was placed on
the "actual" place. Replacing assertEquals with assertFalse, assertTrue
and assertNull where applicable.

Fixes gh-735
11 years ago
Dave Syer 34604a9602 Add assertion about non-special resource 11 years ago
Phillip Webb 488b03387f Polish POM formatting 11 years ago
Martin Lau 53cb8ccde2 Escape URL characters in JAR URLs
Update the spring-boot-loader JarURLConnection class to decode entry
names in the same way as the stock JDK class. This allows encoded
entry names in the form `%c3%ab` to be loaded.

Fixes gh-556
11 years ago
Phillip Webb ca0a12cedb Polish 11 years ago
Dave Syer ae512193bf Add missing test mannifest 11 years ago
Dave Syer 935131cdab Clarification regarding format of loader.path 11 years ago
Dave Syer a1d3bac7c8 More changes to teh way ExplodedArchive works in non-recursive mode
It is sufficient for most purposes (e.g. the ones PropertieLauncher needs)
to only read the META-INF directory (not the whole file tree). So a quick
fix is to make META-INF a special case when initializing non-recursive
entries.

Fixes gh-520
11 years ago
Dave Syer 2c60449836 Be defensive with File.listFiles() 11 years ago
Phillip Webb 80ac1fb0cd Polish 11 years ago
Dave Syer a71c9b5de7 Add escape hatch for ClassLoader.findResource() for invalid path
The source of the exception is in sun.misc (so hard to track down precisely)
but it's clear that the LaunchedJarURLClassLoader needs to be more
defensive and return null from findResource() if it can't find it.

Fixes gh-486
11 years ago
Dave Syer 8168e8a327 Special case for root of classpath resource in archive
This turns out to affect JPA, but only because it looks for a URL for the
root of the classpath using ClassLoader.getResource("") which barfs in
an app launched from an executable JAR. It's easy to make a special case
for "" in the class loader, so I went ahead and did that. Possibly need
to think what the implication of getResources("") is as well (not
tested in an app yet).

Fixes gh-420
11 years ago
Dave Syer f0f73a4ead Current directory (lodaer.path=.) pathology workaround
It turns out that loader.path=. was pathological and before this
change ended up making the classpath empty (loader.path=.,lib/
would have fixed it). With this change the old behaviour is still
supported, but if the only user-supplied path entry is "." (or
empty) then it is now kept, and translates into the root of the
current archive if running as "java -jar ...".

Fixes gh-270
11 years ago
Phillip Webb 865c51d7ac Revert "Omit jar: prefix from jarFileUrl"
Restore previous behavior where JarFile URLs are always prefixed with
"jar:". I believe that the prefix is required in order to remain
compatible with standard JAR URLs.

This reverts commit 825fc2f7df.
11 years ago
Dave Syer 825fc2f7df Omit jar: prefix from jarFileUrl 11 years ago
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
11 years ago
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
11 years ago
Phillip Webb 1552759584 Fix package tangle by moving AsciiBytes 11 years ago
Phillip Webb 3e7af3ddb8 Improve exception messages on nested jar failure
Updates gh-284
11 years ago
Phillip Webb 14bc06a387 Pull-up duplicated code to Launcher 11 years ago
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()`.
11 years ago
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
11 years ago
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
11 years ago
Phillip Webb 0afdb71345 Better getRootJar exception capturing 11 years ago
Dave Syer 91998d5942 Add loader.args to PropertiesLauncher
Also new section of README for propery keys used by the
launcher.
11 years ago
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
11 years ago
Phillip Webb c1f8fd2bac Fix some compile warnings 11 years ago
Phillip Webb 43e54d38f7 Make fields private where possible 11 years ago
Phillip Webb ac54d7fe3c Final polish before 1.0.0.RC1 11 years ago
Phillip Webb 853b0a8027 Fix some maven warnings 11 years ago
Phillip Webb cdda330acd Update copyright header for files changed in 2014 11 years ago
Phillip Webb 4fc9dfc2d5 Revert "Add launcher.count as useful performance testing aid"
This reverts commit e1605b4691.
11 years ago
Dave Syer e1605b4691 Add launcher.count as useful performance testing aid 11 years ago
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
11 years ago
Phillip Webb 47da8a817a Polish 11 years ago
Dave Syer 7b58718453 Add missing YAML file for test 11 years ago
Dave Syer 4e1245d9ee Restore changes from 0332501 (fix class loader test failure) 11 years ago