Use BaseX in embedded mode on tomcat
Hi all,
I just want to ask shortly whether it is generally possible to run BaseX in embedded mode within a webapp on tomcat?
Using a very simple examle like this: https://github.com/BaseXdb/basex/blob/master/basex-examples/src/main/java/org/basex/examples/local/QueryCollection.java
Throws me an error on Context context = new Context();
java.nio.file.FileSystemNotFoundException at com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171) at com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:157) at java.nio.file.Paths.get(Paths.java:143) at org.basex.util.Prop.homePath(Prop.java:142) at org.basex.util.Prop.<clinit>(Prop.java:96) at org.basex.core.GlobalOptions.<clinit>(GlobalOptions.java:20) at org.basex.core.Context.<init>(Context.java:77) at org.basex.core.Context.<init>(Context.java:69) ........
The same code works great when executing locally (e.g. within JUnit tests). Do you have any ideas? Is it generally possible or do I need to deploy the war application?
Thanks in advance, Christian
Hi again,
I just noticed that this error only occurs in 8.0-Snapshot but not in the latest official release 7.9... Unfortunately I need the array module in my use case which was added in 8.0
Christian
Quoted text · Christian Müller · 35 lines
On Mon, Nov 10, 2014 at 9:14 PM, Christian Müller < christianmue1980a at gmail.com> wrote: > Hi all, > > I just want to ask shortly whether it is generally possible to run BaseX > in embedded mode within a webapp on tomcat? > > Using a very simple examle like this: > https://github.com/BaseXdb/basex/blob/master/basex-examples/src/main/java/org/basex/examples/local/QueryCollection.java > > Throws me an error on > Context context = new Context(); > > java.nio.file.FileSystemNotFoundException > at > com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171) > at > com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:157) > at java.nio.file.Paths.get(Paths.java:143) > at org.basex.util.Prop.homePath(Prop.java:142) > at org.basex.util.Prop.<clinit>(Prop.java:96) > at org.basex.core.GlobalOptions.<clinit>(GlobalOptions.java:20) > at org.basex.core.Context.<init>(Context.java:77) > at org.basex.core.Context.<init>(Context.java:69) > ........ > > The same code works great when executing locally (e.g. within JUnit > tests). Do you have any ideas? Is it generally possible or do I need to > deploy the war application? > > Thanks in advance, > Christian > > >
Hi Christian,
thanks for the observation. With 8.0, we switched to Java 7 and java.nio, so it could be that the check for finding the application directory fails.
I just looked at the stack trace, and I wondered if the error does really break your code, or if it simply output to stderr (due to the catch clause, see [1])?
Feedback from other Tomcat users is appreciated, Christian
[1] https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/util/Prop.java#L142
Quoted text · Christian Müller · 46 lines
On Mon, Nov 10, 2014 at 9:29 PM, Christian Müller <christianmue1980a at gmail.com> wrote: > Hi again, > > I just noticed that this error only occurs in 8.0-Snapshot but not in the > latest official release 7.9... Unfortunately I need the array module in my > use case which was added in 8.0 > > Christian > > On Mon, Nov 10, 2014 at 9:14 PM, Christian Müller > <christianmue1980a at gmail.com> wrote: >> >> Hi all, >> >> I just want to ask shortly whether it is generally possible to run BaseX >> in embedded mode within a webapp on tomcat? >> >> Using a very simple examle like this: >> https://github.com/BaseXdb/basex/blob/master/basex-examples/src/main/java/org/basex/examples/local/QueryCollection.java >> >> Throws me an error on >> Context context = new Context(); >> >> java.nio.file.FileSystemNotFoundException >> at >> com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171) >> at >> com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:157) >> at java.nio.file.Paths.get(Paths.java:143) >> at org.basex.util.Prop.homePath(Prop.java:142) >> at org.basex.util.Prop.<clinit>(Prop.java:96) >> at org.basex.core.GlobalOptions.<clinit>(GlobalOptions.java:20) >> at org.basex.core.Context.<init>(Context.java:77) >> at org.basex.core.Context.<init>(Context.java:69) >> ........ >> >> The same code works great when executing locally (e.g. within JUnit >> tests). Do you have any ideas? Is it generally possible or do I need to >> deploy the war application? >> >> Thanks in advance, >> Christian >> >> >
Hi Christian,
thanks for your answer. You are perfectly right, there was another (stupid) mistake by myself which crashes the execution but was closely related to the printed and caught exception. Now it works as expected. Thanks again!
Christian
Quoted text · Christian Grün · 71 lines
On Mon, Nov 10, 2014 at 9:50 PM, Christian Grün <christian.gruen at gmail.com> wrote: > Hi Christian, > > thanks for the observation. With 8.0, we switched to Java 7 and > java.nio, so it could be that the check for finding the application > directory fails. > > I just looked at the stack trace, and I wondered if the error does > really break your code, or if it simply output to stderr (due to the > catch clause, see [1])? > > Feedback from other Tomcat users is appreciated, > Christian > > [1] > https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/util/Prop.java#L142 > > > > On Mon, Nov 10, 2014 at 9:29 PM, Christian Müller > <christianmue1980a at gmail.com> wrote: > > Hi again, > > > > I just noticed that this error only occurs in 8.0-Snapshot but not in the > > latest official release 7.9... Unfortunately I need the array module in > my > > use case which was added in 8.0 > > > > Christian > > > > On Mon, Nov 10, 2014 at 9:14 PM, Christian Müller > > <christianmue1980a at gmail.com> wrote: > >> > >> Hi all, > >> > >> I just want to ask shortly whether it is generally possible to run BaseX > >> in embedded mode within a webapp on tomcat? > >> > >> Using a very simple examle like this: > >> > https://github.com/BaseXdb/basex/blob/master/basex-examples/src/main/java/org/basex/examples/local/QueryCollection.java > >> > >> Throws me an error on > >> Context context = new Context(); > >> > >> java.nio.file.FileSystemNotFoundException > >> at > >> > com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171) > >> at > >> > com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:157) > >> at java.nio.file.Paths.get(Paths.java:143) > >> at org.basex.util.Prop.homePath(Prop.java:142) > >> at org.basex.util.Prop.<clinit>(Prop.java:96) > >> at org.basex.core.GlobalOptions.<clinit>(GlobalOptions.java:20) > >> at org.basex.core.Context.<init>(Context.java:77) > >> at org.basex.core.Context.<init>(Context.java:69) > >> ........ > >> > >> The same code works great when executing locally (e.g. within JUnit > >> tests). Do you have any ideas? Is it generally possible or do I need to > >> deploy the war application? > >> > >> Thanks in advance, > >> Christian > >> > >> > > >
Quoted text · Christian Müller · 3 lines
> thanks for your answer. You are perfectly right, there was another (stupid) > mistake by myself which crashes the execution but was closely related to the > printed and caught exception. Now it works as expected. Thanks again!
Your feedback is welcome. I have finally added a GitHub issue for Tomcat [1], as we have frequent feedback on things that lead to unexpected behavior with this web server. For example, the stack trace should not be output at all if the application behaves as expected.
Christian
Quoted text · Christian Grün · 76 lines
> On Mon, Nov 10, 2014 at 9:50 PM, Christian Grün <christian.gruen at gmail.com> > wrote: >> >> Hi Christian, >> >> thanks for the observation. With 8.0, we switched to Java 7 and >> java.nio, so it could be that the check for finding the application >> directory fails. >> >> I just looked at the stack trace, and I wondered if the error does >> really break your code, or if it simply output to stderr (due to the >> catch clause, see [1])? >> >> Feedback from other Tomcat users is appreciated, >> Christian >> >> [1] >> https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/util/Prop.java#L142 >> >> >> >> On Mon, Nov 10, 2014 at 9:29 PM, Christian Müller >> <christianmue1980a at gmail.com> wrote: >> > Hi again, >> > >> > I just noticed that this error only occurs in 8.0-Snapshot but not in >> > the >> > latest official release 7.9... Unfortunately I need the array module in >> > my >> > use case which was added in 8.0 >> > >> > Christian >> > >> > On Mon, Nov 10, 2014 at 9:14 PM, Christian Müller >> > <christianmue1980a at gmail.com> wrote: >> >> >> >> Hi all, >> >> >> >> I just want to ask shortly whether it is generally possible to run >> >> BaseX >> >> in embedded mode within a webapp on tomcat? >> >> >> >> Using a very simple examle like this: >> >> >> >> https://github.com/BaseXdb/basex/blob/master/basex-examples/src/main/java/org/basex/examples/local/QueryCollection.java >> >> >> >> Throws me an error on >> >> Context context = new Context(); >> >> >> >> java.nio.file.FileSystemNotFoundException >> >> at >> >> >> >> com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171) >> >> at >> >> >> >> com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:157) >> >> at java.nio.file.Paths.get(Paths.java:143) >> >> at org.basex.util.Prop.homePath(Prop.java:142) >> >> at org.basex.util.Prop.<clinit>(Prop.java:96) >> >> at org.basex.core.GlobalOptions.<clinit>(GlobalOptions.java:20) >> >> at org.basex.core.Context.<init>(Context.java:77) >> >> at org.basex.core.Context.<init>(Context.java:69) >> >> ........ >> >> >> >> The same code works great when executing locally (e.g. within JUnit >> >> tests). Do you have any ideas? Is it generally possible or do I need to >> >> deploy the war application? >> >> >> >> Thanks in advance, >> >> Christian >> >> >> >> >> > > > >
Written for BaseX 7.9. BaseX may have changed since: please check the current documentation.