Re: Tomcat GraalVm native image issue

2022-01-17 Thread Rémy Maucherat
On Sun, Jan 16, 2022 at 3:39 PM Satyajit Rout  wrote:
>
> Thanks Remy for the response.
>
> I kept the main conf files under the module/stuffed/conf folder and then
> tried to build the native image following the steps given in the doc.
>
> When I run the native image from the stuffed folder it works and I am able
> to access the webapp.
>
> *But when I run the same native image from a different folder or on a
> different server, it asks for the server.xml file and fails to run. I have
> pasted the error logs below.*
>
> *Tomcat version: 10.0.14*
>
> =
> Sun Jan 16 14:31:29 GMT 2022
>
> opc@devbox -15./tomcat-stuffed-1.0
>
> Jan 16, 2022 2:31:37 PM org.apache.catalina.startup.Catalina parseServerxml
> WARNING: Unable to load server configuration from /home/opc/conf/server.xml]

Tomcat is a Servlet container that runs standard EE compliant webapps.
The packaging that you're using is an example that allows compiling
the classes from Tomcat and your webapps into a native image. However,
you are still running the usual Tomcat standalone, as well as your
webapp. As a result, you still need a server.xml, all the other
configuration files and resources that go in conf, and your usual
unchanged webapp.

There are solutions to "replace" the files in conf:
- A custom ConfigurationSource implementation allows embedding files
from conf into Java classes (which can then be compiled into your
native image).
- There's a tool which allows generating Tomcat embedded code from
your server.xml. In addition to providing you with code examples if
you want to learn the embedded API, this can also allow you to replace
server.xml.

However, if you prefer a fully packaged and AOT specific solution, you
should look into the proprietary frameworks that target native images.

Rémy

>
> *java.io.FileNotFoundException: /home/opc/conf/server.xml (No such file or
> directory)*
>
> at
> com.oracle.svm.jnt.JNIJavaCallwrappers.jntInvoke_VA_LIST_FileNotFoundException_constructor
> 970c509c6abfd3f98898b9a7521945418b
>
> 90b270(JNIJavaCallwrappers.java:0)
>
> at java.io.FileInputStream.openo(FileInputstream.java) at
> java.to.FileInputStream.open(FileInputStream.java:219)
>
> at java.to.FileInputStream. java.io.FileInputStream.(FileInputStream.java:112)
>
> at
> sun.net.www.protocol.file.FileURL.Connection.connect(FileURL.Connection.java:86)
> at
> sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURL.Connection.java:184)
>
> at org.apache.catalina.startup.catalinaBaseConfigurationsource.getResourcei
> CatalinaBaseConfigurationSource.java:118)
>
> at
> org.apache.tomcat.util.file.configurationSource.getConfResource(ConfigurationSource.java:150)
> at org.apache.tomcat.util.file.configurationSource.getServerxml
> (Configurationsource.java:127)
>
> at org.apache.catalina.startup.CatalinaBaseConfigurationsource.getServerxel
> at org.apache.catalina.startup.Catalina.parseServerxml(Catalina.java:631)
>
> at org.apache.catalina.startup.Catalina.load(Catalina.java:732)
>
> at org.apache.catalina.startup.Tomcat. init(Tomcat.java:459)
> at org.apache.catalina.startup.Tomcat.main(Tomcat.java:1337)
>
> Jan 16, 2022 2:31:37 PM org.apache.catalina.core.Standardservice
> startInternal
> INFO: Starting service [Tomcat]
>
> =
>
> Your assistance would help in this situation.
>
> Thanks,
> Satyajit
>
> On Sun, 16 Jan 2022 at 00:50, Rémy Maucherat  wrote:
>
> > On Sat, Jan 15, 2022 at 6:05 PM Satyajit Rout 
> > wrote:
> > >
> > > I want to serve the static file of a reactjs application through this
> > > tomcat native image and I don't have any jar/war file to place under the
> > > webapps folder.
> > >
> > > But tomcat native image is not running without a server.xml file in the
> > > same path from where the native image is triggered.
> >
> > You have to place a server.xml and all the other usual configuration
> > files in the conf folder, this is really the same thing as the usual
> > Tomcat standalone. It seemed explicit enough when I wrote the sentence
> > in the doc. The idea is to not duplicate the default server.xml (and
> > all the others everywhere for no reason.
> > Would you have understood it better if "The main configuration files
> > are placed in the conf folder" -> "The usual configuration files for
> > Tomcat standalone (server.xml, web.xml, etc) should be placed in the
> > conf folder" ?
> >
> > Rémy
> >
> > >
> > > Thanks,
> > > Satyajit
> > >
> > > On Sat, 15 Jan 2022 at 22:29, Satyajit Rout 
> > > wrote:
> > >
> > > >
> > > >> Hi Team,
> > > >>
> > > >> I am trying to build a native image of tomcat on GraalVM by referring
> > to the doc at "
> > https://tomcat.apache.org/tomcat-9.0-doc/graal.html#Building_the_native_image
> > ".
> > > >>
> > > >> The documentation says, "Inside the tomcat-stuffed folder, the
> > directory structure is the same as for regular Tomcat. The main
> > 

Re: Tomcat GraalVm native image issue

2022-01-16 Thread Satyajit Rout
Thanks Remy for the response.

I kept the main conf files under the module/stuffed/conf folder and then
tried to build the native image following the steps given in the doc.

When I run the native image from the stuffed folder it works and I am able
to access the webapp.

*But when I run the same native image from a different folder or on a
different server, it asks for the server.xml file and fails to run. I have
pasted the error logs below.*

*Tomcat version: 10.0.14*

=
Sun Jan 16 14:31:29 GMT 2022

opc@devbox -15./tomcat-stuffed-1.0

Jan 16, 2022 2:31:37 PM org.apache.catalina.startup.Catalina parseServerxml
WARNING: Unable to load server configuration from /home/opc/conf/server.xml]

*java.io.FileNotFoundException: /home/opc/conf/server.xml (No such file or
directory)*

at
com.oracle.svm.jnt.JNIJavaCallwrappers.jntInvoke_VA_LIST_FileNotFoundException_constructor
970c509c6abfd3f98898b9a7521945418b

90b270(JNIJavaCallwrappers.java:0)

at java.io.FileInputStream.openo(FileInputstream.java) at
java.to.FileInputStream.open(FileInputStream.java:219)

at java.to.FileInputStream.(FileInputStream.java:112)

at
sun.net.www.protocol.file.FileURL.Connection.connect(FileURL.Connection.java:86)
at
sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURL.Connection.java:184)

at org.apache.catalina.startup.catalinaBaseConfigurationsource.getResourcei
CatalinaBaseConfigurationSource.java:118)

at
org.apache.tomcat.util.file.configurationSource.getConfResource(ConfigurationSource.java:150)
at org.apache.tomcat.util.file.configurationSource.getServerxml
(Configurationsource.java:127)

at org.apache.catalina.startup.CatalinaBaseConfigurationsource.getServerxel
at org.apache.catalina.startup.Catalina.parseServerxml(Catalina.java:631)

at org.apache.catalina.startup.Catalina.load(Catalina.java:732)

at org.apache.catalina.startup.Tomcat. init(Tomcat.java:459)
at org.apache.catalina.startup.Tomcat.main(Tomcat.java:1337)

Jan 16, 2022 2:31:37 PM org.apache.catalina.core.Standardservice
startInternal
INFO: Starting service [Tomcat]

=

Your assistance would help in this situation.

Thanks,
Satyajit

On Sun, 16 Jan 2022 at 00:50, Rémy Maucherat  wrote:

> On Sat, Jan 15, 2022 at 6:05 PM Satyajit Rout 
> wrote:
> >
> > I want to serve the static file of a reactjs application through this
> > tomcat native image and I don't have any jar/war file to place under the
> > webapps folder.
> >
> > But tomcat native image is not running without a server.xml file in the
> > same path from where the native image is triggered.
>
> You have to place a server.xml and all the other usual configuration
> files in the conf folder, this is really the same thing as the usual
> Tomcat standalone. It seemed explicit enough when I wrote the sentence
> in the doc. The idea is to not duplicate the default server.xml (and
> all the others everywhere for no reason.
> Would you have understood it better if "The main configuration files
> are placed in the conf folder" -> "The usual configuration files for
> Tomcat standalone (server.xml, web.xml, etc) should be placed in the
> conf folder" ?
>
> Rémy
>
> >
> > Thanks,
> > Satyajit
> >
> > On Sat, 15 Jan 2022 at 22:29, Satyajit Rout 
> > wrote:
> >
> > >
> > >> Hi Team,
> > >>
> > >> I am trying to build a native image of tomcat on GraalVM by referring
> to the doc at "
> https://tomcat.apache.org/tomcat-9.0-doc/graal.html#Building_the_native_image
> ".
> > >>
> > >> The documentation says, "Inside the tomcat-stuffed folder, the
> directory structure is the same as for regular Tomcat. The main
> configuration files are placed in the conf folder, and if using the default
> server.xml the webapps are placed in the webapps folder."
> > >>
> > >> But if you clone the repo "
> https://github.com/apache/tomcat/tree/main/modules/stuffed; there is no
> files inside tomcat/module/stuffed/conf folder except .gitignore file.
> > >>
> > >> After building the native image, while I am trying to run the native
> image on another server it fails as it is *unable to find conf/server.xml
> on that server*. Do we have any workaround to package the conf folder into
> the native image or any other resolution for this issue?
> > >>
> > >>
> > >> Thanks & Regards,
> > >>
> > >> Satyajit
> > >>
> > >>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: Tomcat GraalVm native image issue

2022-01-15 Thread Rémy Maucherat
On Sat, Jan 15, 2022 at 6:05 PM Satyajit Rout  wrote:
>
> I want to serve the static file of a reactjs application through this
> tomcat native image and I don't have any jar/war file to place under the
> webapps folder.
>
> But tomcat native image is not running without a server.xml file in the
> same path from where the native image is triggered.

You have to place a server.xml and all the other usual configuration
files in the conf folder, this is really the same thing as the usual
Tomcat standalone. It seemed explicit enough when I wrote the sentence
in the doc. The idea is to not duplicate the default server.xml (and
all the others everywhere for no reason.
Would you have understood it better if "The main configuration files
are placed in the conf folder" -> "The usual configuration files for
Tomcat standalone (server.xml, web.xml, etc) should be placed in the
conf folder" ?

Rémy

>
> Thanks,
> Satyajit
>
> On Sat, 15 Jan 2022 at 22:29, Satyajit Rout 
> wrote:
>
> >
> >> Hi Team,
> >>
> >> I am trying to build a native image of tomcat on GraalVM by referring to 
> >> the doc at 
> >> "https://tomcat.apache.org/tomcat-9.0-doc/graal.html#Building_the_native_image;.
> >>
> >> The documentation says, "Inside the tomcat-stuffed folder, the directory 
> >> structure is the same as for regular Tomcat. The main configuration files 
> >> are placed in the conf folder, and if using the default server.xml the 
> >> webapps are placed in the webapps folder."
> >>
> >> But if you clone the repo 
> >> "https://github.com/apache/tomcat/tree/main/modules/stuffed; there is no 
> >> files inside tomcat/module/stuffed/conf folder except .gitignore file.
> >>
> >> After building the native image, while I am trying to run the native image 
> >> on another server it fails as it is *unable to find conf/server.xml on 
> >> that server*. Do we have any workaround to package the conf folder into 
> >> the native image or any other resolution for this issue?
> >>
> >>
> >> Thanks & Regards,
> >>
> >> Satyajit
> >>
> >>

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



Re: Tomcat GraalVm native image issue

2022-01-15 Thread Satyajit Rout
I want to serve the static file of a reactjs application through this
tomcat native image and I don't have any jar/war file to place under the
webapps folder.

But tomcat native image is not running without a server.xml file in the
same path from where the native image is triggered.

Thanks,
Satyajit

On Sat, 15 Jan 2022 at 22:29, Satyajit Rout 
wrote:

>
>> Hi Team,
>>
>> I am trying to build a native image of tomcat on GraalVM by referring to the 
>> doc at 
>> "https://tomcat.apache.org/tomcat-9.0-doc/graal.html#Building_the_native_image;.
>>
>> The documentation says, "Inside the tomcat-stuffed folder, the directory 
>> structure is the same as for regular Tomcat. The main configuration files 
>> are placed in the conf folder, and if using the default server.xml the 
>> webapps are placed in the webapps folder."
>>
>> But if you clone the repo 
>> "https://github.com/apache/tomcat/tree/main/modules/stuffed; there is no 
>> files inside tomcat/module/stuffed/conf folder except .gitignore file.
>>
>> After building the native image, while I am trying to run the native image 
>> on another server it fails as it is *unable to find conf/server.xml on that 
>> server*. Do we have any workaround to package the conf folder into the 
>> native image or any other resolution for this issue?
>>
>>
>> Thanks & Regards,
>>
>> Satyajit
>>
>>


Re: Tomcat GraalVm native image issue

2022-01-15 Thread Satyajit Rout
>
>
> Hi Team,
>
> I am trying to build a native image of tomcat on GraalVM by referring to the 
> doc at 
> "https://tomcat.apache.org/tomcat-9.0-doc/graal.html#Building_the_native_image;.
>
> The documentation says, "Inside the tomcat-stuffed folder, the directory 
> structure is the same as for regular Tomcat. The main configuration files are 
> placed in the conf folder, and if using the default server.xml the webapps 
> are placed in the webapps folder."
>
> But if you clone the repo 
> "https://github.com/apache/tomcat/tree/main/modules/stuffed; there is no 
> files inside tomcat/module/stuffed/conf folder except .gitignore file.
>
> After building the native image, while I am trying to run the native image on 
> another server it fails as it is *unable to find conf/server.xml on that 
> server*. Do we have any workaround to package the conf folder into the native 
> image or any other resolution for this issue?
>
>
> Thanks & Regards,
>
> Satyajit
>
>