paketo-buildpacks / apache-tomee Goto Github PK
View Code? Open in Web Editor NEWA Cloud Native Buildpack that contributes Apache Tomee and Process Types for the application server
License: Apache License 2.0
A Cloud Native Buildpack that contributes Apache Tomee and Process Types for the application server
License: Apache License 2.0
When you run (e.g. on kubernetes) an image built with this buildback with a readonly filesystem (e.g. readOnlyRootFilesystem: true
), the application crashes on startup with
cannot create unique file, please set java.io.tmpdir to a writable folder or create work folder
Even when you provide a writeable mount (e.g. /tmp
) and point to it with JAVA_TOOL_OPTIONS=-Djava.io.tmpdir=/tmp
this is overwritten and the application crashes.
This happens specifically for the tiny
stack when the command is created to start tomee
.
tomee
uses the temp directory that user provides.
When on a tiny
stack (code), a start command is calculated instead of calling catalina.sh
. This start script sets -Djava.io.tmpdir
to $(CATALINA_HOME)/temp
(code). This potentially overwrites the temp dir the user provided via JAVA_TOOL_OPTIONS
.
It getting clear looking at the log
Picked up JAVA_TOOL_OPTIONS: -Djava.io.tmpdir=/tmp -Djava.security.properties=/layers/paketo-buildpacks_sap-machine/java-security-properties/java-security.properties -XX:+ExitOnOutOfMemoryError -XX:ActiveProcessorCount=8 -XX:MaxDirectMemorySize=10M -Xmx425549K -XX:MaxMetaspaceSize=62450K -XX:ReservedCodeCacheSize=240M -Xss1M -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+PrintNMTStatistics
11-Nov-2022 10:02:23.450 INFO [main] jdk.internal.reflect.NativeMethodAccessorImpl.invoke Command line argument: -Djava.io.tmpdir=/tmp
11-Nov-2022 10:02:23.455 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Djava.io.tmpdir=/layers/paketo-buildpacks_apache-tomee/catalina-base/temp
Caused by: org.apache.openejb.OpenEJBRuntimeException: cannot create unique file, please set java.io.tmpdir to a writable folder or create work folder
java.io.tmpdir
and relying on the default (/tmp
)TMPDIR
) into accounttiny
stackpack build --builder paketobuildpacks/builder:tiny -e BP_JAVA_APP_SERVER=tomee -e BP_MAVEN_BUILT_ARTIFACT="test-jaxrs-tomee/target/*.war" -e test-jaxrs-tomee tomee-example
docker run --read-only -p 8080:8080 tomee-example
It crashes.
docker run -v /tmp:/tmp -e JAVA_TOOL_OPTIONS="-Djava.io.tmpdir=/tmp" -p 8080:8080 tomee-example
Note: You can omit the --read-only
to not have it crashing. You can verify in the log that -Djava.io.tmpdir
is set twice, so the later would win.
Using the feature to use a readonly filesystem in kubernetes or docker should work as long as you provide a writeable temp directory. With that, the user has the control where files are written.
Integration test is failing, see here.
It is failing because of the glibc issue. See this thread in Slack for background: https://paketobuildpacks.slack.com/archives/C011S6EL49L/p1680796577398119
The integration test is building the buildpack from source, which requires CGO_ENABLED=0
to be set. We do this in the pipelines when we build and package the buildpack, but integration tests need to do this as well.
See how it's done in the pipeline here:
https://github.com/paketo-buildpacks/apache-tomee/blob/main/.github/workflows/pb-create-package.yml#L130-L136
I believe integration tests would just need to set that env variable during the test setup.
Run integration tests.
The detect.go
logic is this: https://github.com/paketo-buildpacks/apache-tomee/blob/main/tomee/detect.go#L49-L53
This will work for most cases but fails if the Tomee buildpack is first in the builder/composite group and no app server has been set.
In this case:
It should pass though because in the case where it's listed first in the order group, it should run and contribute Tomee.
The workaround would be to request 'tomee' and then it'll get installed.
See https://github.com/paketo-buildpacks/apache-tomee/actions/runs/7378265147/job/20073179955#step:9:99 as an example.
OR
Pick one of the integration tests & re-run it. It seems to fail around 50% of the time.
It causes hassles when evaluating PRs and wastes time. No one needs that.
Build without warnings.
When building and syft runs, recent versions output a warning:
Command "packages" is deprecated, use `syft scan` instead
Make the suggested change.
Run a build from source. You'll see this logged multiple times. One of the times is from this buildpack.
Go modules should update automatically on a weekly basis through CI.
Presently, the (Update Go Modules job is consistently failing)[https://github.com/paketo-buildpacks/apache-tomee/actions/runs/3672158285].
I have tried to unwind the issue here with the Go module dependencies but there is an issue with a test dependency that I cannot work out.
> go get -u all
go: all: module github.com/docker/docker@upgrade found (v20.10.21+incompatible), but does not contain package github.com/docker/docker/builder/remotecontext/urlutil
I also tried go clean -modcache
which is often suggested online as a fix for issues like this and it didn't help.
Repeat the steps from the failing action locally, which basically amounts to running go get -u all
in the project directory.
Until this is resolved, transitive go modules are not being updated. Dependabot will update direct dependencies, but it does not keep transitive dependencies up-to-date.
Tomee should log to the console. With Tomcat, there is a special handler that is added to accomplish this. It appears like Tomee has it's own handler that does this, so we don't need to add an additional handler.
The Tomcat special handler is added by the Tomee buildpack. It does not appear to be necessary.
If it's truly not needed, remove it. It's one less thing for the buildpack to install.
I think we should also review if the lifecycle helper and the access logging helper are required with Tomee.
The access logging helper simply writes access logs to System.out
, so if there is a way to write access log entires to the Console in Tomee, then we don't need that either.
The lifecycle helper looks to see if there is an application failure while the server is starting. If there is one, then it fails the whole server. That way the container is not started in an inconsistent state. Again, if Tomee can do this out-of-the-box, then the helper can be removed too.
Installing less is more.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.