Re: where to put jars used by several apps

2017-11-26 Thread Nasry Al-Haddad
One issue you might face in this configuration is if you have multiple versions 
of the same library existing on the same path, let's say com.example v1.0 and 
v2.0, and each is a dependency for one or more webapps. If a webapp depending 
on 2.0 requires class com.example.X which is available in both versions, and if 
the class loader looks in v1.0 jar file first, then you might see some CNF 
exceptions and such.

To workaround this ensure both statements below are true:
1. The class loader searches in WEB-INF jar files before common.loader (I think 
it should be the case)

2. Update your build process to include in WEB-INF only jar files that have an 
older version in common.loader path (just to not break any webapp especially 
the one being installed).

If you end up updating all webapps to use the latest version of the library 
com.example, you'll end up with all webapps having the latest version in 
WEB-INF and the unused older version in common.loader path. Then update the 
common.loader path by removing the old version and adding the new one, and 
remove it from WEB-INF directories.

This might incur more work on managing the webapps. But if you could have an 
automated build process that decides where to put dependency jar files and have 
it as a step for all webapps builds, then it could be a time/space saver later.

⁣Regards,
Nasry Al-Haddad

Sent from BlueMail ​

On Nov 25, 2017, 16:35, at 16:35, rich...@xentu.com wrote:
>I've written a few jersey webapps, and each has about 20 jar files
>included as Maven dependencies.
>
>The inclusion of those jars increases the size of the resulting wars by
>
>a factor of over 100. Uploading a war via 'Tomcat Web Application
>Manager' takes several minutes, presumably due in part to the war size.
>
>Given that these webapps require the same set of jars in their
>WEB-INF/lib/, I thought I could place them in say
>
>C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\jersey
>
>where all webapps could find them.
>
>In catalina.properties, I appended this new directory to the
>common.loader list of paths:
>
>common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar,
>
>${catalina.base}/lib/jersey/*.jar
>
>Then, in each jersey webapp, I'd modify pom.xml to exclude those files
>from the war.
>
>
>   maven-war-plugin
>   3.2.0
>   
> WEB-INF/lib/*.jar
>   
>
>
>This approach seems to work.
>
>So, the question I'm seeking advise on is this:
>
>If I have a collection of jars that I want to keep on Tomcat, for some
>but not all webapps, and those jars are not to be included in the wars,
>
>is this an acceptable technique? Or is it going to land me in trouble?
>Does the order of locations in common.loader matter?
>
>
>Thanks for any advice
>Richard
>
>-
>To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>For additional commands, e-mail: users-h...@tomcat.apache.org


Re: Suggestions for deploying context.xml for different environments?

2016-07-07 Thread Nasry Al-Haddad
One additional way to do it is to create a symbolic link in tomcat's
$CATALINA_HOME/conf/engine/host/ that points to a fixed location where you
deploy my-application.xml. But worth mentioning here is that you still have
to have the passwords in plain text configuration files. In this method,
whenever you deploy your application, with whatever configuration, tomcat
will always refer to your newly deployed my-application.xml rather than
having a copy of the old version or having to deploy another time to
$CATALINA_HOME. While symbolic links are Linux-only, Windows has shortcuts.
I never tried this method on Windows, but I guess Windows shortcuts are
also preserved even if the original copy of the file was removed.

If you use Ant to build your application, you can use the symlink task to
create the symbolic link, or use the exec task to run the "ln" command that
creates the symbolic link on Linux. The former task (symlink) is usable if
the user running the build script has write permissions on the directory
where the symlink will be created (we use it for tomcat). While the latter
(exec) is necessary if the user does not have write permissions (we use
this for httpd because httpd conf files are in /etc which requires root
permissions).







We run the above tasks only when the symbolic links are not there. But in
future builds, we just deploy ROOT.xml and ${APP_NAME}.conf to
${APP_HOME}/conf/tomcat and ${APP_HOME}/conf/httpd, respectively.
${user.ROOT_PASSWORD} refers to a property in a property file supplied to
Ant during a build. It can be the root password (not preferrable, I use
this task only on local testing environments), or it can be the password
for a user that has permissions on the target directory (that's if you
don't want to run the whole build script with that user and provided you
reconfigure the task to use that privileged user instead of sudo).

For Windows, I don't think there's a specific task for creating a shortcut.
If it turned out there isn't, you can also use the exec task to run
the SHORTCUT.exe
utility that creates shortcuts on Windows. I never tried this though.

I usually prefer this method for platform-independency because the
application files (whether web or standard application) are all deployed to
a HOME directory for that application (outside tomcat's webapps directory).
So whatever OS (Windows/Linux) and whatever Linux distro (there are
differences between Ubuntu and CentOS for example), everything changed is
just in the APP_HOME, and everything is automated by the Ant build script.
And we do set an environment property specifying APP_HOME property.

Hope this helps.

Regards
Nasry


On Mon, Jul 4, 2016 at 5:42 PM, Philip Hachey 
wrote:

> Hello.  I am seeking some advice for the best ways to deploy Java web
> applications to different Tomcat environments.
>
> In particular, my application requires that a JNDI resource be defined for
> a database, where the database server address and credentials will vary
> depending on the environment the application is deployed to.
>
> * Tomcat: 8.0.36
> * OS: varies depending on the environment deployed to
>
> If I include in the WAR file, a META-INF/context.xml that includes the
> Resource element, Tomcat will use that to create the file:
> $CATALINA_HOME/conf/engine/host/my-application.xml
>
> The context file my-application.xml can then be modified so that the
> Resource settings are appropriate for the environment.
>
> However, if, for any reason, the application is undeployed and then
> re-deployed, my-application.xml will be recreated with the settings as they
> originally appeared in the WAR file.
>
> The options that seem evident to me are:
>
> 1) Create a different WAR file for each environment.  This strikes me as a
> bit onerous.
>
> 2) Use environment variables in my-application.xml such as:
> url="${databaseurl}" and then define those environment variables using the
> Environment element in the GlobalNamingResources of Tomcat's server.xml.
>
> Regarding #2, would it be possible to instead use a properties file to
> define the variables?  I assume adding entries to catalina.properties would
> work, but is it possible to define a properties file separate from
> catalina.properties which deals more with system properties rather than
> application properties?
>
> I haven't been able to find a documented standard methodology for Tomcat
> deployments to different environments, but I'm certain there must be some
> common and elegant ways of doing this.  I'm interested in hearing what
> others have done.
>
> Thank you,
> Philip
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>
ᐧ


Tomcat 7.0: Unused primitive long or double variables prevent Tomcat from compiling JSP

2014-10-21 Thread Nasry Al-Haddad
)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at
org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2440)
at
org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2429)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

Best Regards,

Nasry Al-Haddad