2023年12月20日(水) 19:55 Rémy Maucherat <r...@apache.org>: > > On Wed, Dec 20, 2023 at 5:33 AM Jun Suzuki <junsuzuki1...@gmail.com> wrote: > > > > 2023年12月19日(火) 16:11 Jun Suzuki <junsuzuki1...@gmail.com>: > > > > > > 2023年12月19日(火) 1:18 Rémy Maucherat <r...@apache.org>: > > > > > > > > On Mon, Dec 18, 2023 at 1:28 PM Jun Suzuki <junsuzuki1...@gmail.com> > > > > wrote: > > > > > > > > > > Hello all, > > > > > > > > > > I'm now following the guide of > > > > > https://tomcat.apache.org/tomcat-11.0-doc/graal.html to build Tomcat > > > > > into native image. > > > > > The original thread I posted before has become too long to be easily > > > > > understood, so please let me raise a new thread to clarify. > > > > > I break down the contents from the guide into a step-by-step > > > > > procedure, and I would appreciate it if you can verify the steps and > > > > > check for the issues. > > > > > > > > > > [Environment]: Tomcat 10.0.27, Ant 1.10.14, Maven 3.6.3, GraalVM EE > > > > > 21.x+Java17 > > > > > [Steps]: > > > > > 1. Download the stuffed folder according to the guide. > > > > > 2. Edit the original pom to align with the Tomcat and JDK version: > > > > > <properties> > > > > > > > > > > <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> > > > > > <mainClass>org.apache.catalina.startup.Tomcat</mainClass> > > > > > <tomcat.version>10.0.27</tomcat.version> > > > > > </properties> > > > > > .................. > > > > > <plugin> > > > > > <groupId>org.apache.maven.plugins</groupId> > > > > > <artifactId>maven-compiler-plugin</artifactId> > > > > > <version>3.11.0</version> > > > > > <configuration> > > > > > <release>11</release> > > > > > </configuration> > > > > > </plugin> > > > > > 3. Copy conf and webapps folders from Tomcat to the stuffed folder. > > > > > 4. Edit the logging properties(Deleted all Juli-related statements to > > > > > avoid runtime error) > > > > > handlers = java.util.logging.ConsoleHandler > > > > > .handlers = java.util.logging.ConsoleHandler > > > > > ............................. > > > > > java.util.logging.ConsoleHandler.level = FINE > > > > > # java.util.logging.ConsoleHandler.formatter = > > > > > org.apache.juli.OneLineFormatter > > > > > java.util.logging.ConsoleHandler.encoding = UTF-8 > > > > > 5. Build and packaging. > > > > > mvn package > > > > > ant -Dwebapp.name=ROOT -f webapp-jspc.ant.xml > > > > > ant -Dwebapp.name=manager -f webapp-jspc.ant.xml > > > > > ant -Dwebapp.name=examples -f webapp-jspc.ant.xml > > > > > > > > > > Until here everything was running fine without error. And when I > > > > > executed the next command, error message displayed as below: > > > > > mvn package > > > > > .......................................................................................................... > > > > > [INFO] --- maven-compiler-plugin:3.11.0:compile (default-compile) @ > > > > > tomcat-stuffed --- > > > > > [INFO] Changes detected - recompiling the module! :source > > > > > [INFO] Compiling 130 source files with javac [debug release 17] to > > > > > target/classes > > > > > [INFO] > > > > > /home/opc/project/tomcat-native/stuffed/src/main/java/manager/org/apache/jsp/WEB_002dINF/jsp/sessionsList_jsp.java: > > > > > Some input files use unchecked or unsafe operations. > > > > > [INFO] > > > > > /home/opc/project/tomcat-native/stuffed/src/main/java/manager/org/apache/jsp/WEB_002dINF/jsp/sessionsList_jsp.java: > > > > > Recompile with -Xlint:unchecked for details. > > > > > [INFO] Some messages have been simplified; recompile with > > > > > -Xdiags:verbose to get full output > > > > > [INFO] ------------------------------------------------------------- > > > > > [ERROR] COMPILATION ERROR : > > > > > [INFO] ------------------------------------------------------------- > > > > > [ERROR] > > > > > /home/opc/project/tomcat-native/stuffed/src/main/java/examples/org/apache/jsp/jsp/tagplugin/choose_jsp.java:[162,210] > > > > > cannot access javax.servlet.jsp.tagext.TagSupport > > > > > class file for javax.servlet.jsp.tagext.TagSupport not found > > > > > [ERROR] > > > > > /home/opc/project/tomcat-native/stuffed/src/main/java/examples/org/apache/jsp/jsp/tagplugin/choose_jsp.java:[165,35] > > > > > cannot access javax.servlet.jsp.tagext.Tag > > > > > class file for javax.servlet.jsp.tagext.Tag not found > > > > > .......................................................................................................... > > > > > > > > > > Could you please help to indicate what I have missed from the above > > > > > steps? > > > > > And I would really appreciate it if you could offer some kind of > > > > > step-by-step hands-on examples about how to practice to run Tomcat as > > > > > native image. > > > > > > > > This seems unrelated, you are apparently trying to run an EE8 webapp > > > > (the examples from Tomcat 9) on a EE10 container. The package names > > > > for the APIs changed to jakarta.*. > > > > > > > > Rémy > > > > > > > > > > Thank you for the comments. > > > To avoid excessive trial and error, is it possible to provide a > > > combination of tested versions that ensure default Tomcat examples > > > running in native image without error? > > > Could you please indicate the version of Tomcat, GraalVM(EE or CE), > > > JDK, maven, ant? I want to use these specific versions you pointed to > > > make sure default Tomcat examples will run normally in term of native > > > image without additional customization. > > > Thank you in advance. > > > Jun > > > > Hi, I have accomplished each steps from the guide to packaging a > > simple war file(containing a single servlet which is entry point from > > web access) without error, except for last step of executing produced > > native image: > > SEVERE: Allocate exception for servlet [GreetingServlet] > > com.oracle.svm.core.jdk.UnsupportedFeatureError: No classes have been > > predefined during the image build to load from bytecodes at runtime. > > at > > org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:121) > > at > > org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.PredefinedClassesSupport.throwNoBytecodeClasses(PredefinedClassesSupport.java:76) > > at > > org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.PredefinedClassesSupport.loadClass(PredefinedClassesSupport.java:130) > > at > > java.base@21/java.lang.ClassLoader.defineClass(ClassLoader.java:280) > > at > > java.base@21/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) > > ....................................................................... > > > > I checked the source/main/java folder which is supposed to contain > > pre-generated code, but it looks like only index_jsp.java is existing. > > Whether servlet should also be pre-generated? And whether the error > > came from the missing of pre-generated servlet? > > I would appreciate your finding and insight about this issue. > > This error message seems rather new, but basically it most likely > means the bytecode is not there. > One important thing to always remember is that ultimately all the > classes bytecode MUST end up in the target/tomcat-stuffed-1.0.jar. If > some library or Servlet class or whatever is used by your webapp is > not there, then it won't work in the end. This could be true in > particular for webapp classes which could be provided as dependencies > in the main pom, or some script could copy them to target/classes > (webapp-jspc.ant.xml does that kind of work for precompiled JSPs for > example, copying the code to src/main/java so that then then get > compiled through Maven), and so on. > Do you feel like this could be improved by having webapp-jspc.ant.xml > attempt to do that work ? Ideally I thought using Maven to handle the > classes is better. > > I have retested Tomcat with GraalVM 21 and the ROOT webapp (with its > single JSP). Generating the native image worked and the JSP works as > well, so this covers the basic functionality of Tomcat. > > I did modernize the command line in the docs due to some warnings, but > without any functional change. That can be expected from time to time, > some options might get modified. > > Rémy
I appreciate your comments and support. I agree that using Maven to handle the classes is better. But I'm afraid I misunderstood some important steps from the guide. What I'm doing now is separately compiling my sample application (including a single servlet) into war file, and deployed the war file on Tomcat server, then I got my sample webapp folder. After that I copied the sample webapp folder into webapps directory within stuffed folder. There are no *.java source files there but only class file included. But when I checked webapp-jspc.ant.xml, there are statements as below: <!-- Copy all webapp classes to the mvn compile location --> <copy todir="${basedir}/src/main/java"> <fileset dir="${basedir}/webapps/${webapp.name}/WEB-INF/classes" includes="**/*.java" erroronmissingdir="false" /> </copy> Does "includes="**/*.java" mean I have to copy java source file but not class file into stuffed folder? And could you please confirm whether the steps I have done as above are correct or not? Thank you Jun --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org