Skip to content

Commit cf14da4

Browse files
committed
Remove Use of Endorsed Directory
Previously, the tomcat logging support was added to Tomcat via an endorsed directory. In Java 9, the endorsed directory concept has been removed, so another strategy was necessary to add JARs to the Tomcat classpath. This change moves that functionality to the `setenv.sh` file for all Tomcat instances. [resolves cloudfoundry#530]
1 parent 233ffe2 commit cf14da4

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

lib/java_buildpack/container/tomcat/tomcat_logging_support.rb

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@ class TomcatLoggingSupport < JavaBuildpack::Component::VersionedDependencyCompon
2525

2626
# (see JavaBuildpack::Component::BaseComponent#compile)
2727
def compile
28-
download_jar(jar_name, endorsed)
28+
download_jar(jar_name, bin)
29+
write_set_env
2930
end
3031

3132
# (see JavaBuildpack::Component::BaseComponent#release)
32-
def release
33-
@droplet.java_opts.add_system_property 'java.endorsed.dirs',
34-
"$PWD/#{endorsed.relative_path_from(@droplet.root)}"
35-
end
33+
def release; end
3634

3735
protected
3836

@@ -43,14 +41,28 @@ def supports?
4341

4442
private
4543

46-
def endorsed
47-
@droplet.sandbox + 'endorsed'
44+
def bin
45+
@droplet.sandbox + 'bin'
4846
end
4947

5048
def jar_name
5149
"tomcat_logging_support-#{@version}.jar"
5250
end
5351

52+
def setenv
53+
bin + 'setenv.sh'
54+
end
55+
56+
def write_set_env
57+
setenv.open('w') do |f|
58+
f.write <<~SH
59+
#!/bin/sh
60+
61+
CLASSPATH=$CLASSPATH:#{(bin + jar_name).relative_path_from(@droplet.root)}
62+
SH
63+
end
64+
end
65+
5466
end
5567

5668
end

spec/java_buildpack/container/tomcat/tomcat_logging_support_spec.rb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,20 @@
3333

3434
component.compile
3535

36-
expect(sandbox + "endorsed/tomcat_logging_support-#{version}.jar").to exist
36+
expect(sandbox + "bin/tomcat_logging_support-#{version}.jar").to exist
3737
end
3838

39-
it 'sets java.endorsed.dirs during release' do
40-
component.release
39+
it 'creates setenv.sh',
40+
cache_fixture: 'stub-logging-support.jar' do
41+
42+
component.compile
43+
44+
expect(sandbox + 'bin/setenv.sh').to exist
45+
expect((sandbox + 'bin/setenv.sh').read).to eq <<~SH
46+
#!/bin/sh
4147
42-
expect(java_opts).to include('-Djava.endorsed.dirs=$PWD/.java-buildpack/tomcat/endorsed')
48+
CLASSPATH=$CLASSPATH:#{(sandbox + "bin/tomcat_logging_support-#{version}.jar").relative_path_from(app_dir)}
49+
SH
4350
end
4451

4552
end

0 commit comments

Comments
 (0)