This is an automated email from the ASF dual-hosted git repository.

fhanik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new 468b6b4  Include Graal configuration files
468b6b4 is described below

commit 468b6b42c42ad7973388966bd667fecd9f74be7a
Author: Filip Hanik <fha...@pivotal.io>
AuthorDate: Tue Apr 14 13:53:51 2020 -0700

    Include Graal configuration files
    
    for embedded jars so that the native-image compiler picks it up
    automatically
    
    Location of Graal native-image files:
    META-INF/native-image/groupId/artifactId
    
    https://www.graalvm.org/docs/reference-manual/native-image/
    Native Image Configuration
    
    This commit contains a sample embedded application, a script to build
    the native image and a script to test the native image for functionality
    
    Known Issues: reflection for JMX has intentionally been left out
---
 build.xml                                          | 40 ++++++++--
 res/graal/README.md                                | 40 ++++++++++
 res/graal/build-tomcat-native-image.sh             | 59 ++++++++++++++
 res/graal/graal-measure.sh                         | 58 ++++++++++++++
 .../native-image/native-image.properties           | 16 ++++
 .../native-image/tomcat-reflection.json            | 65 ++++++++++++++++
 .../native-image/tomcat-resource.json              | 57 ++++++++++++++
 .../native-image/native-image.properties           | 16 ++++
 .../native-image/tomcat-reflection.json            |  3 +
 .../native-image/tomcat-resource.json              | 12 +++
 .../native-image/native-image.properties           | 16 ++++
 .../native-image/tomcat-reflection.json            |  2 +
 .../native-image/tomcat-resource.json              | 11 +++
 .../native-image/native-image.properties           | 16 ++++
 .../native-image/tomcat-reflection.json            |  8 ++
 .../native-image/tomcat-resource.json              | 13 ++++
 .../apache/catalina/startup/EmbeddedTomcat.java    | 91 ++++++++++++++++++++++
 17 files changed, 518 insertions(+), 5 deletions(-)

diff --git a/build.xml b/build.xml
index 43f9dff..0f42f21 100644
--- a/build.xml
+++ b/build.xml
@@ -1405,22 +1405,33 @@
            filesId="files.tomcat-embed-core"
            notice="${tomcat.manifests}/servlet-api.jar.notice"
            license="${tomcat.manifests}/servlet-api.jar.license"
-           addOSGi="true" />
+           addOSGi="true"
+           addGraal="true"
+           graalPrefix="org.apache.tomcat.embed/tomcat-embed-core"
+           graalFiles="res/graal/tomcat-embed-core/native-image"/>
     <jarIt jarfile="${tomcat-embed-jasper.jar}"
            filesDir="${tomcat.classes}"
            filesId="files.tomcat-embed-jasper"
            meta-inf="${tomcat.manifests}/jasper.jar"
-           addOSGi="true" />
+           addOSGi="true"
+           addGraal="true"
+           graalPrefix="org.apache.tomcat.embed/tomcat-embed-jasper"
+           graalFiles="res/graal/tomcat-embed-jasper/native-image"/>
     <jarIt jarfile="${tomcat-embed-el.jar}"
            filesDir="${tomcat.classes}"
            filesId="files.tomcat-embed-el"
-           addOSGi="true" />
+           addOSGi="true"
+           addGraal="true"
+           graalPrefix="org.apache.tomcat.embed/tomcat-embed-el"
+           graalFiles="res/graal/tomcat-embed-el/native-image"/>
     <jarIt jarfile="${tomcat-embed-websocket.jar}"
            filesDir="${tomcat.classes}"
            filesId="files.tomcat-embed-websocket"
            meta-inf="${tomcat.manifests}/tomcat-websocket.jar"
-           addOSGi="true" />
-
+           addOSGi="true"
+           addGraal="true"
+           graalPrefix="org.apache.tomcat.embed/tomcat-embed-websocket"
+           graalFiles="res/graal/tomcat-embed-websocket/native-image"/>
   </target>
 
   <target name="embed-sources"
@@ -3356,6 +3367,12 @@ Read the Building page on the Apache Tomcat 
documentation site for details on ho
                default="${tomcat.manifests}/default" />
     <attribute name="addOSGi" description="generate OSGi metadata"
                default="false" />
+    <attribute name="addGraal" description="add Graal resource/reflection 
files if set"
+               default="false" />
+    <attribute name="graalPrefix" description="Graal resource/reflection 
location prefix (group_id/artifact_id)"
+               default="" />
+    <attribute name="graalFiles" description="Graal resource/reflection file 
location"
+               default="" />
     <sequential>
       <jar jarfile="@{jarfile}" manifest="@{manifest}">
         <fileset dir="@{filesDir}">
@@ -3373,6 +3390,12 @@ Read the Building page on the Apache Tomcat 
documentation site for details on ho
         <param name="jarfile" value="@{jarfile}" />
         <param name="addOSGi" value="@{addOSGi}" />
       </antcall>
+      <antcall target="add-graal">
+        <param name="jarfile" value="@{jarfile}" />
+        <param name="addGraal" value="@{addGraal}" />
+        <param name="graalFiles" value="@{graalFiles}" />
+        <param name="graalPrefix" value="@{graalPrefix}" />
+      </antcall>
     </sequential>
   </macrodef>
 
@@ -3385,6 +3408,13 @@ Read the Building page on the Apache Tomcat 
documentation site for details on ho
     <move file="${jarfile}.tmp" tofile="${jarfile}" />
   </target>
 
+  <target name="add-graal" if="${addGraal}">
+    <echo message="add-graal  ${addGraal} ${jarfile} ${graalFiles} 
${graalPrefix}"></echo>
+    <zip destfile="${jarfile}" update="true">
+      <zipfileset dir="${basedir}/${graalFiles}" 
prefix="META-INF/native-image/${graalPrefix}" includes="*.*"/>
+    </zip>
+  </target>
+
   <!-- Macro, used to create checksum and signature files  -->
   <!-- Requires 'file' as a parameter. -->
   <macrodef name="hashAndSign">
diff --git a/res/graal/README.md b/res/graal/README.md
new file mode 100644
index 0000000..717c761
--- /dev/null
+++ b/res/graal/README.md
@@ -0,0 +1,40 @@
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+
+Introduction
+===
+
+GraalVM is a polyglot virtual machine. In addition to that, it supports Ahead 
of Time,
+AOT, compilation of Java applications into native executable files via its
+[native-image`](https://github.com/oracle/graal/tree/master/substratevm) 
compiler.
+
+Reflection Directives
+===
+
+This directory contains directives to the compiler on what classes use 
reflection.
+These are currently stored in a file called `tomcat-reflection.json` in the 
`META-INF/native-image/groupId/artifactId`
+location.
+
+This directory also contains resource directives, so that resource files 
normally included in a JAR file
+also get compiled into the executable image.
+These are currently stored in a file called `tomcat-resource.json` in the 
`META-INF/native-image/groupId/artifactId`
+location.
+
diff --git a/res/graal/build-tomcat-native-image.sh 
b/res/graal/build-tomcat-native-image.sh
new file mode 100755
index 0000000..7503f2c
--- /dev/null
+++ b/res/graal/build-tomcat-native-image.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+CURDIR=`pwd`
+
+# resolve links - $0 may be a softlink
+PRG="$0"
+while [ -h "$PRG" ]; do
+  ls=`ls -ld "$PRG"`
+  link=`expr "$ls" : '.*-> \(.*\)$'`
+  if expr "$link" : '/.*' > /dev/null; then
+    PRG="$link"
+  else
+    PRG=`dirname "$PRG"`/"$link"
+  fi
+done
+
+# directory of this script
+PRGDIR=`dirname "$PRG"`
+
+cd $PRGDIR/../..
+ant && ant embed && ant test-compile
+
+mkdir -p output/graal
+cd output/testclasses
+jar cvfM ../graal/tomcat-embedded-sample.jar 
org/apache/catalina/startup/EmbeddedTomcat*class
+
+cd ../graal
+
+native-image \
+--verbose \
+--no-server \
+-H:EnableURLProtocols=http \
+--report-unsupported-elements-at-runtime \
+--initialize-at-run-time=org.apache,jakarta.servlet \
+-H:+TraceClassInitialization \
+-H:+PrintClassInitialization \
+-H:Name=tc-graal-image \
+-H:+ReportExceptionStackTraces \
+--allow-incomplete-classpath \
+--no-fallback \
+-cp 
../embed/tomcat-embed-core.jar:../embed/tomcat-embed-websocket.jar:../embed/tomcat-embed-el.jar:tomcat-embedded-sample.jar
 \
+org.apache.catalina.startup.EmbeddedTomcat
+
+cd $CURDIR
\ No newline at end of file
diff --git a/res/graal/graal-measure.sh b/res/graal/graal-measure.sh
new file mode 100755
index 0000000..599f1b5
--- /dev/null
+++ b/res/graal/graal-measure.sh
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+GREEN='\033[0;32m'
+RED='\033[0;31m'
+NC='\033[0m'
+
+CURDIR=`pwd`
+
+# resolve links - $0 may be a softlink
+PRG="$0"
+while [ -h "$PRG" ]; do
+  ls=`ls -ld "$PRG"`
+  link=`expr "$ls" : '.*-> \(.*\)$'`
+  if expr "$link" : '/.*' > /dev/null; then
+    PRG="$link"
+  else
+    PRG=`dirname "$PRG"`/"$link"
+  fi
+done
+
+# directory of this script
+PRGDIR=`dirname "$PRG"`
+
+EXECUTABLE=${PRGDIR}/output/graal/tc-graal-image
+
+./${EXECUTABLE} "$@" 2>&1 &
+PID=$!
+sleep 2
+RESPONSE=`curl -s localhost:8080/`
+if [[ "$RESPONSE" == 'OK: http://localhost:8080/[1]' ]]; then
+  printf "\n${GREEN}SUCCESS${NC}: the servlet is working\n"
+else
+  printf "\n${RED}FAILURE${NC}: the HTTP response of the application does not 
contain the expected value\n"
+fi
+
+RSS=`ps -o rss ${PID} | tail -n1`
+RSS=`bc <<< "scale=1; ${RSS}/1024"`
+echo "RSS memory: ${RSS}M"
+SIZE=`wc -c <"${EXECUTABLE}"`/1024
+SIZE=`bc <<< "scale=1; ${SIZE}/1024"`
+echo "Image size: ${SIZE}M"
+
+kill -9 $PID
\ No newline at end of file
diff --git a/res/graal/tomcat-embed-core/native-image/native-image.properties 
b/res/graal/tomcat-embed-core/native-image/native-image.properties
new file mode 100644
index 0000000..29b501f
--- /dev/null
+++ b/res/graal/tomcat-embed-core/native-image/native-image.properties
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+Args = -H:ReflectionConfigurationResources=${.}/tomcat-reflection.json 
-H:ResourceConfigurationResources=${.}/tomcat-resource.json
\ No newline at end of file
diff --git a/res/graal/tomcat-embed-core/native-image/tomcat-reflection.json 
b/res/graal/tomcat-embed-core/native-image/tomcat-reflection.json
new file mode 100644
index 0000000..e98a55b
--- /dev/null
+++ b/res/graal/tomcat-embed-core/native-image/tomcat-reflection.json
@@ -0,0 +1,65 @@
+[
+{ "name":"jakarta.servlet.http.HttpServlet" },
+{ "name":"org.apache.catalina.AccessLog" },
+{ "name":"org.apache.catalina.AsyncDispatcher" },
+{ "name":"org.apache.catalina.Authenticator" },
+{ "name":"org.apache.catalina.Cluster" },
+{ "name":"org.apache.catalina.Container" },
+{ "name":"org.apache.catalina.Contained" },
+{ "name":"org.apache.catalina.Context" },
+{ "name":"org.apache.catalina.CredentialHandler" },
+{ "name":"org.apache.catalina.DistributedManager" },
+{ "name":"org.apache.catalina.Engine" },
+{ "name":"org.apache.catalina.Executor" },
+{ "name":"org.apache.catalina.Group" },
+{ "name":"org.apache.catalina.Host" },
+{ "name":"org.apache.catalina.JmxEnabled" },
+{ "name":"org.apache.catalina.Lifecycle" },
+{ "name":"org.apache.catalina.LifecycleListener" },
+{ "name":"org.apache.catalina.Loader" },
+{ "name":"org.apache.catalina.Manager" },
+{ "name":"org.apache.catalina.Pipeline" },
+{ "name":"org.apache.catalina.Realm" },
+{ "name":"org.apache.catalina.Role" },
+{ "name":"org.apache.catalina.Server" },
+{ "name":"org.apache.catalina.Service" },
+{ "name":"org.apache.catalina.Session" },
+{ "name":"org.apache.catalina.SessionIdGenerator" },
+{ "name":"org.apache.catalina.SessionListener" },
+{ "name":"org.apache.catalina.Store" },
+{ "name":"org.apache.catalina.StoreManager" },
+{ "name":"org.apache.catalina.User" },
+{ "name":"org.apache.catalina.UserDatabase" },
+{ "name":"org.apache.catalina.Valve" },
+{ "name":"org.apache.catalina.WebResource" },
+{ "name":"org.apache.catalina.WebResourceRoot" },
+{ "name":"org.apache.catalina.WebResourceSet" },
+{ "name":"org.apache.catalina.Wrapper" },
+{ "name":"org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl", 
"methods" : [{"name": "<init>","parameterTypes":[]}] },
+{ "name":"org.apache.catalina.core.StandardContext", "methods" : [{"name": 
"<init>","parameterTypes":[]}] },
+{ "name":"org.apache.catalina.loader.ParallelWebappClassLoader", 
"allPublicMethods":true, 
"methods":[{"name":"<init>","parameterTypes":["java.lang.ClassLoader"] }]},
+{ "name":"org.apache.catalina.servlets.DefaultServlet", 
"allDeclaredFields":true, "allDeclaredMethods":true },
+{ "name":"org.apache.catalina.valves.ErrorReportValve", "methods" : [{"name": 
"<init>","parameterTypes":[]}] },
+{ "name":"org.apache.coyote.http11.Http11NioProtocol", "methods" : [{"name": 
"<init>","parameterTypes":[]}] },
+{ "name":"org.apache.coyote.http11.Http11AprProtocol", 
"allDeclaredConstructors" : true, "allPublicConstructors" : true, 
"allDeclaredMethods" : true, "allPublicMethods" : true},
+{ "name":"org.apache.coyote.UpgradeProtocol" },
+{ "name":"org.apache.coyote.Request", 
"methods":[{"name":"<init>","parameterTypes":[] }] },
+{ "name":"org.apache.coyote.RequestGroupInfo", 
"methods":[{"name":"<init>","parameterTypes":[] }] },
+{ "name":"org.apache.coyote.RequestInfo", "allPublicMethods":true },
+{ "name":"org.apache.coyote.Response", 
"methods":[{"name":"<init>","parameterTypes":[] }]},
+{ "name":"org.apache.juli.AsyncFileHandler", 
"methods":[{"name":"<init>","parameterTypes":[] }] },
+{ "name":"org.apache.naming.factory.EjbFactory", "methods" : [{"name": 
"<init>","parameterTypes":[]}] },
+{ "name":"org.apache.naming.factory.ResourceEnvFactory", "methods" : [{"name": 
"<init>","parameterTypes":[]}] },
+{ "name":"org.apache.naming.factory.ResourceFactory", "methods" : [{"name": 
"<init>","parameterTypes":[]}] },
+{ "name":"org.apache.naming.factory.TransactionFactory", "methods" : [{"name": 
"<init>","parameterTypes":[]}] },
+{ "name":"org.apache.tomcat.util.net.AbstractEndpoint", 
"allDeclaredConstructors" : true, "allPublicConstructors" : true, 
"allDeclaredMethods" : true, "allPublicMethods" : true},
+{ "name":"org.apache.tomcat.util.net.AbstractJsseEndpoint", 
"allDeclaredConstructors" : true, "allPublicConstructors" : true, 
"allDeclaredMethods" : true, "allPublicMethods" : true},
+{ "name":"org.apache.tomcat.util.net.AprEndpoint", "allDeclaredConstructors" : 
true, "allPublicConstructors" : true, "allDeclaredMethods" : true, 
"allPublicMethods" : true},
+{ "name":"org.apache.tomcat.util.net.NioEndpoint", "allDeclaredConstructors" : 
true, "allPublicConstructors" : true, "allDeclaredMethods" : true, 
"allPublicMethods" : true},
+{ "name":"org.apache.tomcat.util.buf.StringCache", "allPublicMethods":true },
+{ "name":"org.apache.tomcat.util.net.openssl.OpenSSLImplementation", 
"allDeclaredConstructors" : true, "allPublicConstructors" : true, 
"allDeclaredMethods" : true, "allPublicMethods" : true},
+{ "name":"org.apache.tomcat.util.net.SSLHostConfig", "allPublicMethods":true, 
"methods":[{"name":"<init>","parameterTypes":[] }] },
+{ "name":"org.apache.tomcat.util.net.SSLHostConfigCertificate", 
"allPublicMethods":true, "methods":[{"name":"<init>","parameterTypes":[] }] },
+{ "name":"org.apache.tomcat.util.net.SocketProperties", 
"allPublicMethods":true },
+{ "name":"org.apache.tomcat.util.net.openssl.OpenSSLConf", 
"methods":[{"name":"<init>","parameterTypes":[] }] }
+]
diff --git a/res/graal/tomcat-embed-core/native-image/tomcat-resource.json 
b/res/graal/tomcat-embed-core/native-image/tomcat-resource.json
new file mode 100644
index 0000000..577c660
--- /dev/null
+++ b/res/graal/tomcat-embed-core/native-image/tomcat-resource.json
@@ -0,0 +1,57 @@
+{
+  "bundles":[
+    {"name":"jakarta.servlet.LocalStrings"},
+    {"name":"jakarta.servlet.http.LocalStrings"},
+    {"name":"org.apache.catalina.authenticator.LocalStrings"},
+    {"name":"org.apache.catalina.authenticator.jaspic.LocalStrings"},
+    {"name":"org.apache.catalina.connector.LocalStrings"},
+    {"name":"org.apache.catalina.core.LocalStrings"},
+    {"name":"org.apache.catalina.deploy.LocalStrings"},
+    {"name":"org.apache.catalina.filters.LocalStrings"},
+    {"name":"org.apache.catalina.loader.LocalStrings"},
+    {"name":"org.apache.catalina.manager.LocalStrings"},
+    {"name":"org.apache.catalina.manager.host.LocalStrings"},
+    {"name":"org.apache.catalina.mapper.LocalStrings"},
+    {"name":"org.apache.catalina.mbeans.LocalStrings"},
+    {"name":"org.apache.catalina.realm.LocalStrings"},
+    {"name":"org.apache.catalina.security.LocalStrings"},
+    {"name":"org.apache.catalina.servlets.LocalStrings"},
+    {"name":"org.apache.catalina.session.LocalStrings"},
+    {"name":"org.apache.catalina.startup.LocalStrings"},
+    {"name":"org.apache.catalina.users.LocalStrings"},
+    {"name":"org.apache.catalina.util.LocalStrings"},
+    {"name":"org.apache.catalina.valves.LocalStrings"},
+    {"name":"org.apache.catalina.valves.rewrite.LocalStrings"},
+    {"name":"org.apache.catalina.webresources.LocalStrings"},
+    {"name":"org.apache.coyote.LocalStrings"},
+    {"name":"org.apache.coyote.http11.LocalStrings"},
+    {"name":"org.apache.coyote.http11.filters.LocalStrings"},
+    {"name":"org.apache.coyote.http11.upgrade.LocalStrings"},
+    {"name":"org.apache.coyote.http2.LocalStrings"},
+    {"name":"org.apache.naming.LocalStrings"},
+    {"name":"org.apache.naming.factory.LocalStrings"},
+    {"name":"org.apache.naming.factory.webservices.LocalStrings"},
+    {"name":"org.apache.tomcat.util.LocalStrings"},
+    {"name":"org.apache.tomcat.util.buf.LocalStrings"},
+    {"name":"org.apache.tomcat.util.codec.binary.LocalStrings"},
+    {"name":"org.apache.tomcat.util.compat.LocalStrings"},
+    {"name":"org.apache.tomcat.util.descriptor.LocalStrings"},
+    {"name":"org.apache.tomcat.util.descriptor.tld.LocalStrings"},
+    {"name":"org.apache.tomcat.util.descriptor.web.LocalStrings"},
+    {"name":"org.apache.tomcat.util.digester.LocalStrings"},
+    {"name":"org.apache.tomcat.util.http.LocalStrings"},
+    {"name":"org.apache.tomcat.util.http.parser.LocalStrings"},
+    {"name":"org.apache.tomcat.util.json.LocalStrings"},
+    {"name":"org.apache.tomcat.util.modeler.LocalStrings"},
+    {"name":"org.apache.tomcat.util.net.LocalStrings"},
+    {"name":"org.apache.tomcat.util.scan.LocalStrings"},
+    {"name":"org.apache.tomcat.util.security.LocalStrings"},
+    {"name":"org.apache.tomcat.util.threads.res.LocalStrings"}
+  ],
+  "resources":[
+    {"pattern":".*/mbeans-descriptors.xml$"},
+    {"pattern":".*/*.properties$"},
+    {"pattern":".*/*.dtd$"},
+    {"pattern":".*/*.xsd$"}
+  ]
+}
diff --git a/res/graal/tomcat-embed-el/native-image/native-image.properties 
b/res/graal/tomcat-embed-el/native-image/native-image.properties
new file mode 100644
index 0000000..29b501f
--- /dev/null
+++ b/res/graal/tomcat-embed-el/native-image/native-image.properties
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+Args = -H:ReflectionConfigurationResources=${.}/tomcat-reflection.json 
-H:ResourceConfigurationResources=${.}/tomcat-resource.json
\ No newline at end of file
diff --git a/res/graal/tomcat-embed-el/native-image/tomcat-reflection.json 
b/res/graal/tomcat-embed-el/native-image/tomcat-reflection.json
new file mode 100644
index 0000000..24f67f2
--- /dev/null
+++ b/res/graal/tomcat-embed-el/native-image/tomcat-reflection.json
@@ -0,0 +1,3 @@
+[
+{ "name":"org.apache.el.ExpressionFactoryImpl", "methods" : 
[{"name":"<init>","parameterTypes":[]}] }
+]
diff --git a/res/graal/tomcat-embed-el/native-image/tomcat-resource.json 
b/res/graal/tomcat-embed-el/native-image/tomcat-resource.json
new file mode 100644
index 0000000..55b2fb3
--- /dev/null
+++ b/res/graal/tomcat-embed-el/native-image/tomcat-resource.json
@@ -0,0 +1,12 @@
+{
+  "bundles":[
+    {"name":"jakarta.el.LocalStrings"},
+    {"name":"org.apache.el.Messages"}
+  ],
+  "resources":[
+    {"pattern":".*/mbeans-descriptors.xml$"},
+    {"pattern":".*/*.properties$"},
+    {"pattern":".*/*.dtd$"},
+    {"pattern":".*/*.xsd$"}
+  ]
+}
diff --git a/res/graal/tomcat-embed-jasper/native-image/native-image.properties 
b/res/graal/tomcat-embed-jasper/native-image/native-image.properties
new file mode 100644
index 0000000..29b501f
--- /dev/null
+++ b/res/graal/tomcat-embed-jasper/native-image/native-image.properties
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+Args = -H:ReflectionConfigurationResources=${.}/tomcat-reflection.json 
-H:ResourceConfigurationResources=${.}/tomcat-resource.json
\ No newline at end of file
diff --git a/res/graal/tomcat-embed-jasper/native-image/tomcat-reflection.json 
b/res/graal/tomcat-embed-jasper/native-image/tomcat-reflection.json
new file mode 100644
index 0000000..0d4f101
--- /dev/null
+++ b/res/graal/tomcat-embed-jasper/native-image/tomcat-reflection.json
@@ -0,0 +1,2 @@
+[
+]
diff --git a/res/graal/tomcat-embed-jasper/native-image/tomcat-resource.json 
b/res/graal/tomcat-embed-jasper/native-image/tomcat-resource.json
new file mode 100644
index 0000000..f8c661e
--- /dev/null
+++ b/res/graal/tomcat-embed-jasper/native-image/tomcat-resource.json
@@ -0,0 +1,11 @@
+{
+  "bundles":[
+    {"name":"org.apache.jasper.resources.LocalStrings"}
+  ],
+  "resources":[
+    {"pattern":".*/mbeans-descriptors.xml$"},
+    {"pattern":".*/*.properties$"},
+    {"pattern":".*/*.dtd$"},
+    {"pattern":".*/*.xsd$"}
+  ]
+}
diff --git 
a/res/graal/tomcat-embed-websocket/native-image/native-image.properties 
b/res/graal/tomcat-embed-websocket/native-image/native-image.properties
new file mode 100644
index 0000000..29b501f
--- /dev/null
+++ b/res/graal/tomcat-embed-websocket/native-image/native-image.properties
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+Args = -H:ReflectionConfigurationResources=${.}/tomcat-reflection.json 
-H:ResourceConfigurationResources=${.}/tomcat-resource.json
\ No newline at end of file
diff --git 
a/res/graal/tomcat-embed-websocket/native-image/tomcat-reflection.json 
b/res/graal/tomcat-embed-websocket/native-image/tomcat-reflection.json
new file mode 100644
index 0000000..5907375
--- /dev/null
+++ b/res/graal/tomcat-embed-websocket/native-image/tomcat-reflection.json
@@ -0,0 +1,8 @@
+[
+{ "name":"org.apache.tomcat.websocket.server.WsHttpUpgradeHandler", "methods" 
: [{"name": "<init>","parameterTypes":[] }] },
+{ "name":"org.apache.tomcat.websocket.pojo.PojoEndpointBase", 
"allDeclaredMethods":true },
+{ "name":"org.apache.tomcat.websocket.pojo.PojoEndpointServer", 
"allDeclaredMethods":true },
+{ "name":"org.apache.tomcat.websocket.server.WsContextListener", 
"allDeclaredMethods":true },
+{ "name":"org.apache.tomcat.websocket.server.WsFilter", 
"allDeclaredMethods":true },
+{ "name":"org.apache.tomcat.websocket.server.WsHttpUpgradeHandler", 
"methods":[{"name":"<init>","parameterTypes":[] }] }
+]
diff --git a/res/graal/tomcat-embed-websocket/native-image/tomcat-resource.json 
b/res/graal/tomcat-embed-websocket/native-image/tomcat-resource.json
new file mode 100644
index 0000000..6057069
--- /dev/null
+++ b/res/graal/tomcat-embed-websocket/native-image/tomcat-resource.json
@@ -0,0 +1,13 @@
+{
+  "bundles":[
+    {"name":"org.apache.tomcat.websocket.LocalStrings"},
+    {"name":"org.apache.tomcat.websocket.pojo.LocalStrings"},
+    {"name":"org.apache.tomcat.websocket.server.LocalStrings"}
+  ],
+  "resources":[
+    {"pattern":".*/mbeans-descriptors.xml$"},
+    {"pattern":".*/*.properties$"},
+    {"pattern":".*/*.dtd$"},
+    {"pattern":".*/*.xsd$"}
+  ]
+}
diff --git a/test/org/apache/catalina/startup/EmbeddedTomcat.java 
b/test/org/apache/catalina/startup/EmbeddedTomcat.java
new file mode 100644
index 0000000..4f2c46d
--- /dev/null
+++ b/test/org/apache/catalina/startup/EmbeddedTomcat.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.startup;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.logging.LogManager;
+
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServlet;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+
+import org.junit.Ignore;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.connector.Connector;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.scan.StandardJarScanFilter;
+import org.apache.tomcat.util.scan.StandardJarScanner;
+
+@Ignore
+public class EmbeddedTomcat {
+
+    private static void resetLogging() {
+        final String loggingConfig = "handlers = 
java.util.logging.ConsoleHandler\n" +
+            ".handlers = java.util.logging.ConsoleHandler\n" +
+            "java.util.logging.ConsoleHandler.level = FINE\n" +
+            "java.util.logging.ConsoleHandler.formatter = 
org.apache.juli.OneLineFormatter\n" +
+            "java.util.logging.ConsoleHandler.encoding = UTF-8\n";
+        try {
+            InputStream is = new 
ByteArrayInputStream(loggingConfig.getBytes(StandardCharsets.UTF_8));
+            LogManager.getLogManager().readConfiguration(is);
+            LogFactory.getLog(EmbeddedTomcat.class).info("Logger configured to 
System.out");
+        } catch (SecurityException | IOException e) {
+            // Ignore, the VM default will be used
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        Tomcat tomcat = new Tomcat();
+        resetLogging();
+        tomcat.setPort(8080);
+        Connector connector = tomcat.getConnector();
+        connector.setProperty("bindOnInit", "false");
+        // No file system docBase required
+        Context ctx = tomcat.addContext("", null);
+        skipTldsForResourceJars(ctx);
+        CounterServlet counterServlet = new CounterServlet();
+        Tomcat.addServlet(ctx, "counterServlet", counterServlet);
+        ctx.addServletMappingDecoded("/", "counterServlet");
+
+        tomcat.start();
+        Thread.sleep(60*1000);
+    }
+
+    public static void skipTldsForResourceJars(Context context) {
+        StandardJarScanner scanner = (StandardJarScanner) 
context.getJarScanner();
+        StandardJarScanFilter filter = (StandardJarScanFilter) 
scanner.getJarScanFilter();
+        filter.setTldSkip(filter.getTldSkip() + ",resources*.jar");
+    }
+
+    private static class CounterServlet extends HttpServlet {
+
+        private AtomicInteger callCount = new AtomicInteger(0);
+
+        @Override
+        protected void service(HttpServletRequest req, HttpServletResponse 
resp)
+            throws ServletException, IOException {
+            resp.setContentType("text/plain");
+            resp.getWriter().print("OK: " + req.getRequestURL() + "[" + 
callCount.incrementAndGet()+ "]");
+        }
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to