Re: Locating WebAppConfig file in embedded tomcat

2015-04-28 Thread Benjamin Rogge

Am 2015-04-28 12:10, schrieb benrog:

Hi

we use an embedded Tomcat and are trying to update from version 7.0.40 
to
7.0.61. The the embedded tomcat instance starts up fine and our webapp 
is

also running. However we get the following warning:
Apr 28, 2015 8:58:58 AM org.apache.catalina.startup.Tomcat
getWebappConfigFileFromJar
WARNING: Unable to determine web application context.xml webapp-name
java.io.FileNotFoundException: webapp-name (System cannot find file)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.init(ZipFile.java:215)
at java.util.zip.ZipFile.init(ZipFile.java:145)
at java.util.jar.JarFile.init(JarFile.java:153)
at java.util.jar.JarFile.init(JarFile.java:117)
at 
org.apache.catalina.startup.Tomcat.getWebappConfigFileFromJa

r(Tomcat.java:1162)
at 
org.apache.catalina.startup.Tomcat.getWebappConfigFile(Tomca

t.java:1140)
at 
org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:543)
at 
org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:524)
at 
org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:206)
(Notice, that webapp-name is not the actual name and System cannot 
find

file is a translation of the original German message)

Our start-up process looks like this:
this.tomcat = new Tomcat();
this.tomcat.setBaseDir(.);
this.tomcat.getHost().setAutoDeploy(false);
this.tomcat.getHost().setDeployOnStartup(false);
this.tomcat.setPort(port);
final StandardContext webAppCtx = (StandardContext)
this.tomcat.addWebapp(/weppapp-name, webapp-name);



Here parameters should be context and the base path

The directory structure looks like this, while working directory is

Application-Home: /Application-Home/webapps/webapp-name
We noticed that in 
Tomcat.getWebappConfigFileFromJar(Tomcat.java:1162),

there is the following code:
 protected URL getWebappConfigFile(String path, String url) {
File docBase = new File(path);
if (docBase.isDirectory()) {
return getWebappConfigFileFromDirectory(docBase, url);
} else {
return getWebappConfigFileFromJar(docBase, url);
}
}
The parameter path is webapp-name and the parameter url is
/webapp-name.  With the working dir being Application-Home, new
File(path) will resolve to /Application-Home/webapp-name, which does
not exist. Hence, Tomcat is proceeding to load the config file from a 
jar

file, which leads to the warning mentioned above.
My questions are:
- What are the correct parameters for Tomcat.addWebapp(String 
contextPath,

String docBase)?



first parameter is the context of your web app and the 2nd parameter is 
the

base directory/absolute path


Using the absolute path did the trick. The following code does not 
produce a warning anymore and the context.xml is attempted to be loaded 
from a directory and not a jar file:


final StandardContext webAppCtx = (StandardContext) 
this.tomcat.addWebapp(/webapp-name,
Paths.get(this.tomcat.getHost().getAppBase(), 
webapp-name).toAbsolutePath().toString());


- Is there a special working directory expected, while using an 
embedded

Tomcat?

2015-04-28 15:06 GMT+05:30 Benjamin Rogge tom...@benjamin-rogge.de:


Hello,
we use an embedded Tomcat and are trying to update from version 7.0.40 
to
7.0.61. The the embedded tomcat instance starts up fine and our webapp 
is

also running. However we get the following warning:

Apr 28, 2015 8:58:58 AM org.apache.catalina.startup.Tomcat
getWebappConfigFileFromJar
WARNING: Unable to determine web application context.xml webapp-name
java.io.FileNotFoundException: webapp-name (System cannot find file)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.init(ZipFile.java:215)
at java.util.zip.ZipFile.init(ZipFile.java:145)
at java.util.jar.JarFile.init(JarFile.java:153)
at java.util.jar.JarFile.init(JarFile.java:117)
at
org.apache.catalina.startup.Tomcat.getWebappConfigFileFromJar(Tomcat.java:1162)
at
org.apache.catalina.startup.Tomcat.getWebappConfigFile(Tomcat.java:1140)
at 
org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:543)
at 
org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:524)
at 
org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:206)


(Notice, that webapp-name is not the actual name and System cannot 
find

file is a translation of the original German message)


Our start-up process looks like this:

this.tomcat = new Tomcat();
this.tomcat.setBaseDir(.);
this.tomcat.getHost().setAutoDeploy(false);
this.tomcat.getHost().setDeployOnStartup(false);
this.tomcat.setPort(port);
final StandardContext webAppCtx = (StandardContext)
this.tomcat.addWebapp(/weppapp-name, webapp-name);

The directory structure looks like this, while working directory is
Application-Home: /Application-Home/webapps/webapp-name

We noticed that in 

Locating WebAppConfig file in embedded tomcat

2015-04-28 Thread Benjamin Rogge

Hello,
we use an embedded Tomcat and are trying to update from version 7.0.40 
to 7.0.61. The the embedded tomcat instance starts up fine and our 
webapp is also running. However we get the following warning:


Apr 28, 2015 8:58:58 AM org.apache.catalina.startup.Tomcat 
getWebappConfigFileFromJar

WARNING: Unable to determine web application context.xml webapp-name
java.io.FileNotFoundException: webapp-name (System cannot find file)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.init(ZipFile.java:215)
at java.util.zip.ZipFile.init(ZipFile.java:145)
at java.util.jar.JarFile.init(JarFile.java:153)
at java.util.jar.JarFile.init(JarFile.java:117)
	at 
org.apache.catalina.startup.Tomcat.getWebappConfigFileFromJar(Tomcat.java:1162)
	at 
org.apache.catalina.startup.Tomcat.getWebappConfigFile(Tomcat.java:1140)

at org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:543)
at org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:524)
at org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:206)

(Notice, that webapp-name is not the actual name and System cannot 
find file is a translation of the original German message)



Our start-up process looks like this:

this.tomcat = new Tomcat();
this.tomcat.setBaseDir(.);
this.tomcat.getHost().setAutoDeploy(false);
this.tomcat.getHost().setDeployOnStartup(false);
this.tomcat.setPort(port);
final StandardContext webAppCtx = (StandardContext) 
this.tomcat.addWebapp(/weppapp-name, webapp-name);


The directory structure looks like this, while working directory is 
Application-Home: /Application-Home/webapps/webapp-name


We noticed that in Tomcat.getWebappConfigFileFromJar(Tomcat.java:1162), 
there is the following code:

 protected URL getWebappConfigFile(String path, String url) {
File docBase = new File(path);
if (docBase.isDirectory()) {
return getWebappConfigFileFromDirectory(docBase, url);
} else {
return getWebappConfigFileFromJar(docBase, url);
}
}

The parameter path is webapp-name and the parameter url is 
/webapp-name.  With the working dir being Application-Home, new 
File(path) will resolve to /Application-Home/webapp-name, which does 
not exist. Hence, Tomcat is proceeding to load the config file from a 
jar file, which leads to the warning mentioned above.


My questions are:
- What are the correct parameters for Tomcat.addWebapp(String 
contextPath, String docBase)?
- Is there a special working directory expected, while using an embedded 
Tomcat?


Thanks in advance for any support,
Benjamin Rogge







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



Re: Locating WebAppConfig file in embedded tomcat

2015-04-28 Thread Thusitha Thilina Dayaratne
Hi

we use an embedded Tomcat and are trying to update from version 7.0.40 to
 7.0.61. The the embedded tomcat instance starts up fine and our webapp is
 also running. However we get the following warning:
 Apr 28, 2015 8:58:58 AM org.apache.catalina.startup.Tomcat
 getWebappConfigFileFromJar
 WARNING: Unable to determine web application context.xml webapp-name
 java.io.FileNotFoundException: webapp-name (System cannot find file)
 at java.util.zip.ZipFile.open(Native Method)
 at java.util.zip.ZipFile.init(ZipFile.java:215)
 at java.util.zip.ZipFile.init(ZipFile.java:145)
 at java.util.jar.JarFile.init(JarFile.java:153)
 at java.util.jar.JarFile.init(JarFile.java:117)
 at org.apache.catalina.startup.Tomcat.getWebappConfigFileFromJa
 r(Tomcat.java:1162)
 at org.apache.catalina.startup.Tomcat.getWebappConfigFile(Tomca
 t.java:1140)
 at org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:543)
 at org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:524)
 at org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:206)
 (Notice, that webapp-name is not the actual name and System cannot find
 file is a translation of the original German message)

 Our start-up process looks like this:
 this.tomcat = new Tomcat();
 this.tomcat.setBaseDir(.);
 this.tomcat.getHost().setAutoDeploy(false);
 this.tomcat.getHost().setDeployOnStartup(false);
 this.tomcat.setPort(port);
 final StandardContext webAppCtx = (StandardContext)
 this.tomcat.addWebapp(/weppapp-name, webapp-name);


Here parameters should be context and the base path

The directory structure looks like this, while working directory is
 Application-Home: /Application-Home/webapps/webapp-name
 We noticed that in Tomcat.getWebappConfigFileFromJar(Tomcat.java:1162),
 there is the following code:
  protected URL getWebappConfigFile(String path, String url) {
 File docBase = new File(path);
 if (docBase.isDirectory()) {
 return getWebappConfigFileFromDirectory(docBase, url);
 } else {
 return getWebappConfigFileFromJar(docBase, url);
 }
 }
 The parameter path is webapp-name and the parameter url is
 /webapp-name.  With the working dir being Application-Home, new
 File(path) will resolve to /Application-Home/webapp-name, which does
 not exist. Hence, Tomcat is proceeding to load the config file from a jar
 file, which leads to the warning mentioned above.
 My questions are:
 - What are the correct parameters for Tomcat.addWebapp(String contextPath,
 String docBase)?


first parameter is the context of your web app and the 2nd parameter is the
base directory/absolute path

- Is there a special working directory expected, while using an embedded
Tomcat?

2015-04-28 15:06 GMT+05:30 Benjamin Rogge tom...@benjamin-rogge.de:

 Hello,
 we use an embedded Tomcat and are trying to update from version 7.0.40 to
 7.0.61. The the embedded tomcat instance starts up fine and our webapp is
 also running. However we get the following warning:

 Apr 28, 2015 8:58:58 AM org.apache.catalina.startup.Tomcat
 getWebappConfigFileFromJar
 WARNING: Unable to determine web application context.xml webapp-name
 java.io.FileNotFoundException: webapp-name (System cannot find file)
 at java.util.zip.ZipFile.open(Native Method)
 at java.util.zip.ZipFile.init(ZipFile.java:215)
 at java.util.zip.ZipFile.init(ZipFile.java:145)
 at java.util.jar.JarFile.init(JarFile.java:153)
 at java.util.jar.JarFile.init(JarFile.java:117)
 at
 org.apache.catalina.startup.Tomcat.getWebappConfigFileFromJar(Tomcat.java:1162)
 at
 org.apache.catalina.startup.Tomcat.getWebappConfigFile(Tomcat.java:1140)
 at org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:543)
 at org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:524)
 at org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:206)

 (Notice, that webapp-name is not the actual name and System cannot find
 file is a translation of the original German message)


 Our start-up process looks like this:

 this.tomcat = new Tomcat();
 this.tomcat.setBaseDir(.);
 this.tomcat.getHost().setAutoDeploy(false);
 this.tomcat.getHost().setDeployOnStartup(false);
 this.tomcat.setPort(port);
 final StandardContext webAppCtx = (StandardContext)
 this.tomcat.addWebapp(/weppapp-name, webapp-name);

 The directory structure looks like this, while working directory is
 Application-Home: /Application-Home/webapps/webapp-name

 We noticed that in Tomcat.getWebappConfigFileFromJar(Tomcat.java:1162),
 there is the following code:
  protected URL getWebappConfigFile(String path, String url) {
 File docBase = new File(path);
 if (docBase.isDirectory()) {
 return getWebappConfigFileFromDirectory(docBase, url);
 } else {
 return getWebappConfigFileFromJar(docBase, url);
 }
 }

 The parameter path is