Extension libs in Tomcat .war
Hi all. After researching ANT for a bit, and the ins-and-outs of .war files, I'm feeling a bit more adventerous with deploying web apps via JWS.
I've been studying the very good Sun/Oracle tutorials on deploying apps via Web Start, but I'm stuck on the JNLP API. I don't understand when or why I need to use the classes in the api such as DownloadService.
I came across having to use the jnlp library when the code I would expect to work fails without error.
(The console opens, appends nothing, closes)
I have all my code in a try block, so it's a bit strange that catch (Exception e) catches nothing. - Or at least keeps the console open :/
(For ease of tracking, questions will be numbered!)
+1) Are there any java logs or anything where I can verify what is going on?+
So, after some reseach, it most likely is because I am using extension libs in my war.
+2) Is it?+
I will add the jnlp file I create is made by a servlet (after taking some params etc from my JSPs).
A copy of the generated file I have saved and hosted on the remote server, which JaNeLa verifies as follows (where jdom.jar and jaxen-1.1.3.jar are simple pointer jnlps to the jars in my /web directory along with all my other files):
JaNeLA Report - version 10.03.10
Report for http://hemmels.dyndns.org/WebTriad/web/jnlp.jnlp
XML encoding not known, but declared as UTF-8
Optimize this application for off-line use by adding the <offline-allowed /> flag.
Downloads can be optimized by specifying a resource size for 'web/PokeTriad.jar'.
The resource download at web/PokeTriad.jar can be optimized by removing the (default) value of download='eager'.
Lazy downloads might not work as expected for web/PokeTriad.jar unless the download 'part' is specified.
Downloads can be optimized by specifying a resource size for 'http:/reference.itags.org/reference/link/?url=img/OntoramaLogo-smaller.jpg'.
Icon loading & use can be optimized by specifying the width and height for http:/reference.itags.org/reference/link/?url=img/OntoramaLogo-smaller.jpg
Report for http://hemmels.dyndns.org/WebTriad/web/jaxen.jnlp
XML encoding not known, but declared as UTF-8
Downloads can be optimized by specifying a resource size for 'lib/jaxen-1.1.3.jar'.
The resource download at lib/jaxen-1.1.3.jar can be optimized by removing the (default) value of main='false'.
Lazy downloads might not work as expected for lib/jaxen-1.1.3.jar unless the download 'part' is specified.
Report for http://hemmels.dyndns.org/WebTriad/web/jdom.jnlp
XML encoding not known, but declared as UTF-8
Downloads can be optimized by specifying a resource size for 'lib/jdom.jar'.
The resource download at lib/jdom.jar can be optimized by removing the (default) value of main='false'.
Lazy downloads might not work as expected for lib/jdom.jar unless the download 'part' is specified. I have added code for using a DownloadService to access these jars from the client (can't remember which page this was from):
try{
DownloadService ds;
try {
ds = (DownloadService)ServiceManager.lookup("javax.jnlp.DownloadService");
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(
"DownloadService started!");
} catch (UnavailableServiceException e) {
ds = null;
if (ds != null) {
try {
// determine if a particular resource is cached
URL url = new URL("http://hemmels.dyndns.org/WebTriad/web/jdom.jar");
boolean cached = ds.isResourceCached(url, "1.0");
// remove the resource from the cache
if (cached) {
ds.removeResource(url, "1.0");
// reload the resource into the cache
DownloadServiceListener dsl = ds.getDefaultProgressWindow();
ds.loadResource(url, "1.0", dsl);
} catch (Exception e) {
e.printStackTrace();
}3) Is this right? I need to use the jnlp api to access extension libs from Tomcat?
This confirms my suspicions with the problem stemming from libraries in my war file because now when running the app I get the following error:
29-Oct-2010 00:35:25 runtime.PokeClient <init>
INFO: DownloadService started!
29-Oct-2010 00:35:25 runtime.PokeClient <init>
SEVERE: jdom lib could not be cached!
com.sun.deploy.net.FailedDownloadException: Unable to load resource: (http://hemmels.dyndns.org/WebTriad/web/jdom.jar, 1.0)
at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by:
java.io.IOException: missing version response from server
at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)which is thrown when the code hits:
DownloadService ds;
try {
ds = (DownloadService)ServiceManager.lookup("javax.jnlp.DownloadService");
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(
"DownloadService started!");
} catch (UnavailableServiceException e) {
ds = null;
if (ds != null) {
try {
// determine if a particular resource is cached
URL url = new URL("http://hemmels.dyndns.org/WebTriad/web/jdom.jar");
boolean cached = ds.isResourceCached(url, "1.0");
// remove the resource from the cache
if (cached) {
ds.removeResource(url, "1.0");
// reload the resource into the cache
DownloadServiceListener dsl = ds.getDefaultProgressWindow();
ds.loadResource(url, "1.0", dsl);
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(
"jdom lib is now cached!");
} catch (Exception e) {
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).severe(
"jdom lib could not be cached!");
e.printStackTrace();
}So before I go any further into guessing (have been googling/lurking in this forum for this problem for a week and found nothing), +4) am I along the right lines (i.e. am I trying to do something incorrectly or worse, something you can't do), or do I need to implement the "javax.jnlp.DownloadService" properly?+
Other information would be that the jar file ("http://hemmels.dyndns.org/WebTriad/web/jdom.jar") is accessable from a browser.
Appreciate any replies and the time spent reading.
Edited by: 798437 on Oct 28, 2010 11:44 PM
Spelling.
Edited by: 798437 on Oct 28, 2010 11:45 PM
code blocks
EDIT: I understand the issue java.io.IOException: missing version response from server, is from versioned extensions or something, having googled this I found I need the following version.xml in the /web folder:
<jnlp-versions>
<resource>
<pattern>
<name>jaxen-1.1.3.jar</name>
<version-id>1.0</version-id>
<locale>en_GB</locale>
<locale>en</locale>
</pattern>
<file>jaxen-1.1.3.jar</file>
</resource>
<resource>
<pattern>
<name>jdom.jar</name>
<version-id>1.0</version-id>
<locale>en_GB</locale>
<locale>en</locale>
</pattern>
<file>jdom.jar</file>
</resource>
</jnlp-versions>+5) Do I need a JNLPDownloadServlet or something or this this something different, and again, am I down the wrong path?+
Edited by: 798437 on Oct 28, 2010 11:47 PM
All the above seems to be irrelvant.
My console was closing because the client's stream was empty, and I was trying to read from it.
This was causing an Exception in my client code I wasn't catching (shame on me).
Consider it a hard lesson learnt :)
Similar Messages
-
Mtrace profiling on tomcat war
I wanted to see a very simple example of JVMTI. For that I included the sun provided sample mtrace.dll and mtrace.jar (with couple of sysouts and again I created a jar) in tomcat 6.0 bin directory and also from Tomcat configuration I provided -Xbootclasspath/a:"C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin\mtrace.jar" -agentlib:mtrace in java options.
I was expecting that when I run any of the war project on tomcat then mtrace would instrument bytecod at entry and exit of methods. But none of the sysout that I provided in the mtrace came out in log. If mtrace.jar gets called then sysout should get printed in logs.
Just wanted to ask if the steps I followed are correct and if so then why sysouts are not coming in logs?Put you default page in webapps/ROOT directory and call it index.jsp , or
put in conf/web.xml ,in the wellcome files list(at the bottom of the file), your default file name.
Of course you should have a way to to change the ROOT folder, from which your server will read it out .......... anyway i gave you an ideea , find it out by yourself ;) -
In my Tomcat 4.1.27 local development container (on Windows XP) I cant seem to get any of my War files to deploy. War files did work in the past and now anytime I put a War file in the webapps directory and stop and start Tomcat the War file doesnt create the new webapp directory. The autoDeploy is set to true in the conf/server.xml. Please advise how I can get War file to work?
So is context.xml actually overwriting the settings found in server.xml?I think so. The way I understand it is the the context.xml file saves you from having to edit server.xml. It is preferred for each web app to do its own config, rather than lumping them all together in server.xml.
And what would be the best way to create the war file? IAt its heart, a WAR is just a zip file with its contents laid out in according to the specification of a web application directory structure.
So the simplest way to make a war file is to zip up your directory structure with a tool like winzip, and rename it to be myApp.war.
Regarding ant, I would recommend you take a look through [url http://jakarta.apache.org/tomcat/tomcat-4.1-doc/appdev/index.html
]this tutorial. It explains the basics of website layout, configuration and deployment.
On [url http://jakarta.apache.org/tomcat/tomcat-4.1-doc/appdev/source.html] this page in particular, it includes a link to a basic ant file that you can use as a starting point.
Cheers,
evnafets -
i installed tomcat and i have J2SE 1.4.2
in documentation of tomcat it says that i need an extension to use tomcat with J2SE 1.4.2
but i couldn't find it
Can you help me?There is a ready-made Tomcat distribution for JDK1.4 - at least with Tomcat v4.
A hint: JDK1.4 contains some cryptography and xml-packages, which were not contained in JDK1.3. -
How to export war files without including the library files
Hi,
I have several portlets that share the same jar files. In my tomcat, I'd like to load those jar files from shared/lib when tomcat starts up. Currently, to accomplish this, I export the war file from jsc, deploy to tomcat, then manually delete the jar files from WEB-INF/lib.
Is there a way I can modify some property file so that my war file does not include the shared libraries?
Thanks,
MarcHi!
Rightclick project's root node in Projects window and select Properties. Then go to Build->Packaging and remove unnecessary libraries.
Thanks,
Roman. -
Error in deploying the java studio creator application to tomcat
Hi,
I'm trying to deploy my Sun Java Studio application to Apache Tomcat 5.0.28.
A simple JSF web application built using the creator works fine after deploying the war file under tomcat/weapps directory.
In case of a application with databse connection I'm getting the
" com.sun.rave.web.ui.appbase.ApplicationException: org.apache.jasper.JasperException: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' "
above error. My application connects to Oracle database using the Oracle Server type provided by the Studio Creator.
I have copied
jstl.jar
standard.jar
to webapps\%app%\WEB-INF\lib
The below url is currently not available ( Page not Found )stated as a solution in most of the querries regarding the deplyment to tomcat.
http://developers.sun.com/prodtech/javatools/jscreator/reference/tips/deploy_to_tomcat.html
Thanks for any help
abhiI had similar problems.
I used mysql with tomcat and have mysql in my Creator environment as well but still had the driver message you experienced.
I found that simply copying the WAR file into the webapp directory in tomcat caused a faulty deployment (it was creating /etc/tomcat5/localhost/YourProject.xml as a directory, not as a file)
I updated my Projects/MyProject/build.xml to include a deploy target and I manually execute the ant deploy step (having not figured out how to tweak the internal ant within Creator)
Note that this requires two jar files (see comments in the ant definition)
<project name="YourRoster" default="default" basedir=".">
<description>Builds, tests, and runs the project YourProject.</description>
<import file="nbproject/build-impl.xml"/>
<property file="build.properties"/>
<property name="appdir" value="."/>
<property name="distdir" value="${appdir}/dist"/>
<property name="warfile" value="${distdir}/${app}.war"/>
<property name="builddir" value="${appdir}/build"/>
<path id="classpath">
<pathelement location="${servlet.api.jar}"/>
<pathelement location="${jsp.api.jar}"/>
<fileset dir="${builddir}/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
</path>
<!-- requires tomcat/server/lib/catalina-ant.jar -->
<target name="lrp-init">
<tstamp/>
<fail unless="app" message="Run ant -Dapp=... or update 'build.properties'"/>
</target>
<target name="deploy-tomcat" depends="dist"
description="Deploy web application.">
<echo message="Deploying ${app} ..."/>
<taskdef name="deploy"
classname="org.apache.catalina.ant.DeployTask"/>
<deploy url="${manager.url}" username="${username}"
password="${password}" path="/${app}"
war="file:${warfile}"/>
</target>
<target name="undeploy-tomcat" depends="lrp-init"
description="Undeploy web application.">
<echo message="Undeploying ${app} ..."/>
<taskdef name="undeploy"
classname="org.apache.catalina.ant.UndeployTask"/>
<undeploy url="${manager.url}" username="${username}"
password="${password}" path="/${app}"/>
</target>
<!-- requires ant-contrib (http://ant-contrib.sourceforge.net) -->
<target name="try.undeploy-tomcat" depends="lrp-init"
description="Call the undeploy task (which may fail).">
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<trycatch>
<try>
<ant target="undeploy-tomcat"/>
</try>
<catch/>
</trycatch>
</target>
<target name="redeploy-tomcat" depends="try.undeploy-tomcat,deploy-tomcat"
description="Undeploy and deploy web application.">
</target>
</project>In addition, the build.properties...
jsf.dir=/opt/jsf-1_1_01
tomcat.dir=/opt/tomcat5
app=YourProject
username=tomcatAdminUser
password=tomcatPassword
manager.url=http://localhost:8080/manager
servlet.api.jar=${tomcat.dir}/common/lib/servlet-api.jar
jsp.api.jar=${tomcat.dir}/common/lib/jsp-api.jar
jsf.lib.dir=${jsf.dir}/lib
jstl.lib.dir=${tomcat.dir}/webapps/jsp-examples/WEB-INF/lib
commons.lib.dir=${tomcat.dir}/server/lib
jsf.libs=jsf-api.jar,jsf-impl.jar
jstl.libs=jstl.jar,standard.jar
commons.libs=commons-beanutils.jar,commons-digester.jarHope this helps.
...Lyall -
Deploying servlet on Tomcat using "ant install" not working. Please help.
Hello. Normally I can find answers by using search, but I can't today for some reason. So please bare with me if this has been mentioned before. I will try to provide as much info as possible so that helping me isn't too much a chore. Thank you.
I have downloaded and installed the JWSDP 1.3. and Tomcat is running. I am also using Ant 1.5.4 (previous installation - not one included with JWSDP) and modeled my build.xml file after the template provided here:
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/appdev/build.xml.txt.
When I run ant on my respository, everything builds fine. But when I run Ant with the install target, I get the following error:
BUILD FAILED
file:C:/owl/build.xml:366: java.io.IOException: Server returned HTTP response co
de: 401 for URL: http://localhost:8080/manager/deploy?path=%2Fowl&war=file%3A%2F
%2FC%3A%5Cowl%2Fbuild
Here is line 366 build.xml:
localWar="file://${build.home}"/>
...which is included in this block for the target "install":
<target name="install" depends="compile"
description="Install application to servlet container">
<deploy url="${manager.url}"
username="${manager.username}"
password="${manager.password}"
path="${app.path}"
localWar="file://${build.home}"/>
</target>
When I point my brower to the url located in the error verbose, I get the following:
FAIL - Encountered exception java.lang.NullPointerException
I am trying to get my environment set up correctly before I start spending time developing servlets, but I am getting tempted to just develop to servlets and "manually" installing/deploying them either by copying and pasting or by using the Tomcat manager. I would really like to do everything from Ant though if possible. Please help.I don't think this is at all correct:
localWar="file://${build.home}"/>You've got to create a real WAR file - a JAR file with WEB-INF and all its minions inside it:
http://access1.sun.com/techarticles/simple.WAR.html
That's the file you need to refer to there. You can manage that with Ant too, of course.
Here's what my Ant build.xml looks like for Web apps (there's a build-web.properties file that follows):
build-web.xml
<project name="Tomcat Build Tasks" default="clean" basedir=".">
<target name="init-props">
<tstamp>
<format property="touch.time" pattern="MM/dd/yyyy hh:mm aa" />
</tstamp>
<filterset id="ant.filters">
<filter token="DATE" value="${TODAY}" />
<filter token="TIME" value="${TSTAMP}" />
</filterset>
<!-- Load in all the settings in the properties file -->
<property file="build.properties" />
<!-- Load in all Tomcat settings in the properties file -->
<property file="build-web.properties" />
</target>
<target name="prepare" depends="init-props">
<mkdir dir="${war.classes}"/>
<mkdir dir="${war.lib}"/>
<mkdir dir="${manifest}" />
</target>
<target name="clean" depends="init-props" description="clean up temporary files">
<delete file="${project}.war" />
<delete dir="${war.root}"/>
<delete dir="${manifest}" />
</target>
<target name="set-tomcat-classpath" depends="prepare">
<path id="tomcat.class.path">
<fileset dir="${tomcat.home}/bin">
<patternset>
<include name="**/*.jar" />
</patternset>
</fileset>
<fileset dir="${tomcat.home}/shared/lib">
<patternset>
<include name="**/*.jar" />
</patternset>
</fileset>
<fileset dir="${tomcat.home}/common/lib">
<patternset>
<include name="**/*.jar" />
</patternset>
</fileset>
<fileset dir="${tomcat.home}/server/lib">
<patternset>
<include name="**/*.jar" />
</patternset>
</fileset>
<fileset dir="${ant.home}/lib">
<patternset>
<include name="**/*.jar" />
</patternset>
</fileset>
</path>
</target>
<target name="create" depends="set-tomcat-classpath" description="create the war file">
<!-- All files at root level -->
<!-- Temporarily put the JSPs at root until you figure this out -->
<copy todir="${war.root}">
<fileset dir="${src.jsp}"/>
</copy>
<!--
<copy todir="${war.root}">
<fileset dir="${src.html}" includes="*.html"/>
</copy>
-->
<copy todir="${war.root}/css">
<fileset dir="${src.css}"/>
</copy>
<copy todir="${war.root}/images">
<fileset dir="${src.images}"/>
</copy>
<copy todir="${war.root}/js">
<fileset dir="${src.js}"/>
</copy>
<!-- All files at the WEB-INF level and below -->
<copy todir="${war.web}">
<fileset dir="${src.etc}" includes="web.xml"/>
</copy>
<!-- All files in the CLASSPATH lib -->
<copy todir="${war.web}/lib">
<fileset dir="${src.lib}" includes="**/*.jar" excludes="**/*-tests.jar, **/junit.jar"/>
</copy>
<!-- Put the dispatcher XML in WEB-INF/config -->
<copy todir="${war.web}/config">
<fileset dir="${src.etc}" includes="${project}-config.xml"/>
</copy>
<!-- Put XSL stylesheets in WEB-INF/xsl -->
<copy todir="${war.web}/xsl">
<fileset dir="${src.xsl}" includes="**/*.xsl"/>
</copy>
<!-- Put the project JAR file in WEB-INF/lib -->
<copy todir="${war.web}/lib">
<fileset dir="${deploy}" includes="**/${project}.jar"/>
</copy>
<!-- Create the manifest -->
<buildnumber />
<manifest file="${manifest}/manifest.mf">
<attribute name="Implementation-Title" value="${project}" />
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Build-Date" value="${TODAY}" />
<attribute name="Major-Version" value="${major}" />
<attribute name="Minor-Version" value="${minor}" />
<attribute name="Build-Number" value="${build.number}" />
</manifest>
<!-- Create the WAR file -->
<jar jarfile="${project}.war"
manifest="${manifest}/manifest.mf">
<fileset dir="${war.root}"/>
<metainf dir="${src.etc}" includes="context.xml"/>
</jar>
</target>
<target name="create-tomcat-admin-tasks" depends="set-tomcat-classpath">
<!--
<pathconvert targetos="windows" refid="tomcat.class.path" property="converted.class.path" />
<echo message="CLASSPATH: ${converted.class.path}" />
-->
<taskdef name="install" classname="org.apache.catalina.ant.InstallTask" classpath="tomcat.class.path"/>
<taskdef name="remove" classname="org.apache.catalina.ant.RemoveTask" classpath="tomcat.class.path"/>
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask" classpath="tomcat.class.path"/>
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask" classpath="tomcat.class.path"/>
<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask" classpath="tomcat.class.path"/>
<taskdef name="start" classname="org.apache.catalina.ant.StartTask" classpath="tomcat.class.path"/>
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask" classpath="tomcat.class.path"/>
<taskdef name="list" classname="org.apache.catalina.ant.ListTask" classpath="tomcat.class.path"/>
<taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask" classpath="tomcat.class.path"/>
<taskdef name="roles" classname="org.apache.catalina.ant.RolesTask" classpath="tomcat.class.path"/>
</target>
<target name="install" depends="create-tomcat-admin-tasks" description="install the war file on Tomcat">
<install url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${project}"
config="file:/${basedir}/${src.etc}/context.xml"
war="file:/${basedir}/${project}.war" />
</target>
<target name="remove" depends="create-tomcat-admin-tasks" description="remove the war file on Tomcat">
<remove url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${project}" />
</target>
<target name="reload" depends="create-tomcat-admin-tasks" description="reload the war file on Tomcat">
<reload url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${project}" />
</target>
<target name="deploy" depends="create-tomcat-admin-tasks" description="deploy the war file on Tomcat">
<deploy url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${project}"
config="file:/${basedir}/${src.etc}/context.xml"
war="file:/${basedir}/${project}.war" />
</target>
<target name="undeploy" depends="create-tomcat-admin-tasks" description="undeploy the war file on Tomcat">
<undeploy url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${project}" />
</target>
<target name="start" depends="create-tomcat-admin-tasks" description="start an application on Tomcat">
<start url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${project}"/>
</target>
<target name="stop" depends="create-tomcat-admin-tasks" description="stop an application on Tomcat">
<stop url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${project}" />
</target>
<target name="list" depends="create-tomcat-admin-tasks" description="list all applications running on Tomcat">
<list url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"/>
</target>
<target name="resources" depends="create-tomcat-admin-tasks" description="list all resources on Tomcat">
<resources url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"/>
</target>
<target name="data-sources" depends="create-tomcat-admin-tasks" description="list all data sources on Tomcat">
<resources url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
type="javax.sql.DataSource"/>
</target>
<target name="roles" depends="create-tomcat-admin-tasks" description="list all user roles on Tomcat">
<roles url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"/>
</target>
</project>
build.properties
# Properties file for setting up an Ant build.xml
# Project specific items that change each time
project=api-prototype
major=1
minor=0
version=${major}.${minor}
jar.name=${project}
versiondate=${TODAY}
# Directory structure (these should never change)
bin=bin
deploy=deploy
doc=doc
manifest=META-INF
xml=xml
# Everything under src should come out of a repository
src=src
src.bin=${src}/bin
src.config=${src}/config
src.data=${src}/data
src.dtd=${src}/dtd
src.java=${src}/java
src.lib=${src}/lib
src.profile=${src}/profile
src.properties=${src}/properties
src.schema=${src}/schema
src.sql=${src}/sql
src.templates=${src}/templates
src.testdata=${src}/testdata
src.xml=${src}/xml
src.xsl=${src}/xsl
# These are created and deleted by Ant each time
javadocs=javadocs
reports=reports
output=output
output.classes=${output}/classes
output.lib=${output}/lib
# Required for proper use of XDoclet
xdoclet.home = C:/Tools/xdoclet-1.2b3
build-web.properties
war.root=war-root
war.pages=${war.root}/pages
war.web=${war.root}/WEB-INF
war.classes=${war.web}/classes
war.css=${war.web}/css
war.js=${war.web}/js
war.lib=${war.web}/lib
war.tld=${war.web}/tld
# Properties needed by Tomcat tasks
ant.home =
tomcat.home =
tomcat.manager.url = http://localhost:8080/manager
tomcat.username =
tomcat.password = MOD -
Help running a simple jsp file,Tomcat 5.0.16
Hi,
This question may be addressed many many times,but do reply.
I have a Win xp operating system
Installed Tomcat 5.0.16 in it.
Next the directory structure
PS : The sampleapp directory is outside the tomcat installation directory.
E:/sampleapp
| |
ROOT WEB-INF
|
classes
|
<package1><structure> .class files (for servlet works fine!!!!)
in the WEB-INF,there is the web.xml,then sourcefiles<dir> and the lib directory which is empty.
Now the servlet files work fine.........
I have placed my MyJsp.jsp file in the above mentioned ROOT directory.
I have not done any thing with the <TOMCAT_HOME>/conf/server.xml file
and the web.xml which I have written.
When I give the following URI
http://localhost:8080/sampleapp/MyJsp.jsp,
I get the HTTP status 404- /MyJsp.jsp
description: The requested resource (/MyJsp.jsp) is not available.
Hoping that I have defined the problem specifically.Kindly show some light on this.
Thanks
ASNevermind. I just found the answer. For the record, there are two ways in getting JSPs to work:
1. Precompiling the JSPs and modifying your webapp's web.xml file with the XML fragment generated in YourWebApp/web/WEB-INF/generated_web.xml;
2. Not precompiling the JSPs, but simply letting tomcat compile it on the fly on first access.
PRECOMPILATION METHOD
Go to http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jasper-howto.html. Copy-and-paste the ant script under the section "Web Application Compilation" into a file called compile.xml. For me, I save it in ~/development/compile.xml. Then compile the JSPs using the command (all in a single line):
$ANT_HOME/ant -file <PATH_TO_COMPILE.XML> -Dtomcat.home=<$TOMCAT_HOME> -Dwebapp.path=<$WEBAPP_PATH>
In my case, I cd into the directory where my app resides:
cd ~/development/HelloWorld
and then I type:
ant -file ~/development/compile.xml -Dtomcat.home=/var/tomcat5 -Dwebapp.path=.
(Note the trailing dot since my current directory is my webapp's directory itself. Also, in my case, my shell's PATH contains the path to the ant executable, so I just type 'ant' directly.)
Open the file ~/development/HelloWorld/web/WEB-INF/generated_web.xml and follow the instructions in that auto-generated file, which is: "Place this fragment in the web.xml before all icon, display-name, description, distributable, and context-param elements."
The web.xml referred to above is YOUR web.xml. In my case, it is the one in ~/development/HelloWorld/web/WEB-INF/web.xml
When ready to deploy, type:
ant dist
as usual. Deploy the .war file in the dist directory as you normally would. In my case, I do:
rm -rf $CATALINA_HOME/webapps/hello* (removes my HelloWorld webapp directory and its war file)
cp ~/development/HelloWorld/dist/hello.war $CATALINA_HOME/webapps
and wait for tomcat to unravel the war file. I can then access the JSP page based on whatever the generated_web.xml had specified. In my case, it would be http://localhost:8080/hello/sample.jsp
NON-PRECOMPILATION METHOD
Copy tools.jar from the Java JDK into tomcat's common/lib. (I found this only in the error message in tomcat's log file!! Didn't find it anywhere else!!). Do this one time only, then restart tomcat:
cp $JAVA_HOME/lib/tools.jar $CATALINA_HOME/common/lib
Restart tomcat.
Deploy your webapp as usual which will include your JSP files stored under your webapp's 'web' directory. No precompilation of JSPs is required. Then access your JSP pages such as http://localhost:8080/HelloWorld/my-jsp-page.jsp and tomcat will compile it on the fly on first access. The disadvantage is that there will be a slight delay on first access.
[Note: I am putting all this down for the record, because it took me MANY HOURS to figure all this out as the info on how to do this is not found clearly in one place!! Hope this helps others.]
My next step is to incorporate the contents of compile.xml as mentioned above, into my regular build.xml file. -
OES Client causes XML Parser Issue with Spring 3 Framework WAR
Dear All,
OES Client has been installed in the linux OS and configured JAVA SM in it. Have executed the sample webpage in the tomcat server which contains the 'PepResponse' of getting the authorization value (TRUE / FALSE) and it works fine.
Code snippet:-
PepResponse result = PepRequestFactoryImpl.getPepRequestFactory().newPepRequest(user, action, resourceString, null).decide();
out.println("Result: "+ result.allowed());
It returns the proper value if I mention the oes-client.jar classpath reference in the tomcat classpath settings, but at the same time the existing spring framework WAR file is not deployed in the tomcat. The same WAR file is deploying properly if I remove the classpath reference of oes-client.jar from the tomcat configuration.
The issue causes because of xmlparser2.jar(oracle.xdk11.1.1.1) in the oes client.
Have tried all the alternate approaches and failed to execute both the code together.
Note:- One of the approach, I have tried to copy xcersImpl.jar and xml-apis.jar in the WEB-INF/lib within the war file and also executed oes authorization sample web page simultaneously with referred oes-client.jar classpath reference. The WAR file is started deploy properly and OES Authorization sample webpage has thrown 'Null Pointer Exception'.
Anyone, please suggest how to resolve the JAR conflict issue between the OES Client and Spring Framework WAR.Hi, I got registered to this bea forms, can you help on where to go for posting new blog.
Weblogic Consultant -
Fetching email with attachments in Tomcat
I'm trying to process emails with attachments using following code and it works fine in standalone java application, but when I run this code on Tomcat it treates all messages as not multipart. Class of all contents got from messages is SharedByteArrayInputStream.
I'm using jdk1.6.0_27 and javamail1_4_5
I put mail.jar in WEB-INF/lib of my war.
Can anyone help my how to deal with this? What's wrong?
package test;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Store;
public class Main {
private static Store store;
private static Folder folder;
* @param args
* @throws Exception
public static void main(String[] args) throws Exception {
try {
List<Message> messages = getMessages("...", "...", "...");
for (Message mess : messages) {
System.out.println(mess.getSentDate());
Object content = mess.getContent();
if (content instanceof Multipart) {
System.out.println("miltipart");
} else {
System.out.println("plain");
} finally {
close();
public static List<Message> getMessages(String host, String userName, String password) throws Exception {
if (store != null || folder != null) {
throw new IllegalStateException("There are open and closed messages exist");
// create empty properties
Properties props = new Properties();
// get session
Session session = Session.getDefaultInstance(props, null);
try {
// get the store
store = session.getStore("pop3");
store.connect(host, userName, password);
// get folder
folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
// get directory
return Arrays.asList(folder.getMessages());
} catch (MessagingException e) {
throw new Exception("Exception while mail receiving ", e);
public static void close() throws MessagingException {
// close connection
if (folder != null) {
folder.close(false);
if (store != null) {
store.close();
folder = null;
store = null;
}But I found another interesting issue.
When I run my application everything works fine on first iteration. According to my code I get default instance of Session, get Store, get Folder and at last getMessages. After processing messages I close folder and store.
But if I don't restart my application and try to get messages again all of the SAME messages became plain (SharedByteArrayInputStream) again (as it was earlier).
If I restart my application first iteration works fine and others fails.
In both iterations used the same instance of class where I put Thread.currentThread().setContextClassLoader(BaseEmailService.class.getClassLoader());
What I must reinitialize to make it works on each iteration? -
JNLP and Tomcat JNDI DataSource
Software
JDK 1.5 Update 6
Tomcat 5.5.4
Requirements
I have a Client Side requirement and this project is going to be deployed to 5 users initially all in a lan but there are very chances of adding more users simultaneously.
I am thinking of deploying in JNLP Environment.
At present the Swing application though in development phase is running a little slow and therefore I required the way by which I could store the references of the Object in some server.Getting Connection Object is also a major time consumer and so I needed some way by which I can use the Tomcat DataSource and use the JNDI facility to store certain intermediate values in the server.
Can I use the JNDI in the JNLP Application.
Please provide me the way by which I can do this stuff
Thanks in advance
CSJakharia.> I am using tomcat 5.5.9 and oracle 9i. I am hosting a
portal which uses connection pooling.
I have decided to use the connection pooling through
tomcat's JNDI naming lookup.Excellent idea.
for this i have used the following steps --
1) made entry of <resource-ref> in webapp's web.xml
2) made relevant and corresponding entry in tomcat's
${TOMCAT_HOME}/conf/context.xml (for JNDI
JDBC-datasource)No, don't do it that way.
.> my problems are--
1) making the entry for context.xml in tomcats
conf folder makes the application war dependent
on web server which i dont want to make.Yes, it does.
2) i have to put classes12.jar in tomcats
${TOMCAT_HOME}/common/lib folder and only then the
application connection pooling works else the
exception coming on tomcat console is --
org.apache.tomcat.dbcp.dbcp.SQLNestedException.
Why aren't you using the latest JDBC driver from Oracle? That's in ojdbc14.jar.
.> I dont want to put classes12.jar in web server i want
the web server's JNDI lookup to pick the driver frm
my webapps' internal lib folder. please help me on
these very pressing and immediate issues. all the
help coming from anyone in this regard is very much
welcome.
thanks in advance!
VaivYour instinct is correct.
(1) Put ojdbc14.jar in WEB-INF/lib of your WAR file.
(2) Edit the <Context> XML into a file named context.xml and put it in META-INF of your WAR. Tomcat should pick up the context information for the JNDI data source from that.
Everything is in the WAR, and you don't have any dependence on the server that way.
% -
Can't get some LCDS ES Test Drive samples to work in Tomcat
I can't get many of the Sample Test Drive examples included
with Livecycle Data Services ES 2.5.1 to work properly with Tomcat
(both version 5.5.25 and 6.0.14). I've tried both on Windows XP SP2
and Mac OSX (10.4), but I get the same errors on both platforms. I
can however get the Sample Test Drive from LCDS to work fine with
the JRun server on Windows (included with the Windows version of
LCDS). I've setup the JRun server in a similar fashion as Tomcat
(see my steps below) and everything works fine. I haven't been as
successful with Tomcat. Can anyone point out where I'm going wrong
with my Tomcat setup?
I am using Java 1.5.0.
Here are the error messages I get when trying out the LCDS
Test Drive examples on Tomcat:
Sample 1 - Accessing data using an HTTP service (after
pressing the "Get Data" button):
[RPC Fault faultString="HTTP request error"
faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent
type="ioError" bubbles=false cancelable=false eventPhase=2
text="Error #2032: Stream Error. URL:
http://localhost:8080/samples/testdrive/sample1/catalog.jsp"
URL: catalog.jsp"]
at mx.rpc::AbstractInvoker/
http://www.adobe.com/2006/flex/mx/internal::faultHandler()
at mx.rpc::Responder/fault()
at mx.rpc::AsyncRequest/fault()
at DirectHTTPMessageResponder/errorHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/redirectEvent()
Samples 3, 4 and 5 all produce the following error:
[RPC Fault faultString="flex.samples.DAOException :
java.sql.SQLException: Connection is broken"
faultCode="Server.Processing" faultDetail="null"]
at mx.rpc::AbstractInvoker/
http://www.adobe.com/2006/flex/mx/internal::faultHandler()
at mx.rpc::Responder/fault()
at mx.rpc::AsyncRequest/fault()
at NetConnectionMessageResponder/statusHandler()
at mx.messaging::MessageResponder/status()
Sample 8 - Data Management Service:
[RPC Fault faultString="Unable to invoke a fill operation on
destination 'inventory' due to the following error: class
flex.samples.DAOException:java.sql.SQLException: Connection is
broken." faultCode="Server.Processing" faultDetail="null"]
at mx.data::ConcreteDataService/
http://www.adobe.com/2006/flex/mx/internal::dispatchFaultEvent()
at DataListRequestResponder/fault()
at mx.rpc::AsyncRequest/fault()
at NetConnectionMessageResponder/statusHandler()
at mx.messaging::MessageResponder/status()
Samples 2, 6 and 7 work fine.
Here are the steps I took to setup Tomcat. I've tried this on
both MacOSX and WinXP:
1. Download and extract Tomcat from tomcat.apache.org (I've
tried both version 5.5.25 and 6.0.14)
2. Install Livecycle Data Services ES 2.5.1 and copy
flex.war, flex-admin.war and samples.war to [tomcat-root]/webapps/
3. Prepare tomcat for Livecycle Data Services by following
the instructions here:
http://help.adobe.com/en_US/livecycle/es/lcds_installation.html
3a. Add Java Open Transaction Manager (JOTM) from
http://jotm.objectweb.org/.
Copy the JAR files from [jotm-root]/lib to
[tomcat-root]/common/lib/.
3b. Create a context file for your web application and
register JOTM using the Transaction element, e.g. for the samples
WAR create a [tomcat-root]/conf/Catalina/localhost/samples.xml file
and add the following lines:
<Context docBase="${catalina.home}/webapps/samples"
privileged="true"
antiResourceLocking="false" antiJARLocking="false">
<Transaction
factory="org.objectweb.jotm.UserTransactionFactory"
jotm.timeout="60"/>
</Context>
3c. Increase the maximum memory to at least 512MB. For
Tomcat, this is achieved by specifying the maximum heap size for
the JVM in the JAVA_OPTS variable in [tomcat-root]/bin/catalina.sh:
-Xmx512m
4. Run the tomcat server ([tomcat-root]/bin/startup.sh for
Mac OS or [tomcat-root]\bin\startup.bat for WinXP) which extracts
the 3 .war files into their respective directories in
[tomcat-root]/webapps/
5. Goto the Samples Test Drive in your web browser at
http://localhost:8080/samples/testdrive/Thanks Leif,
Yes, set it to the location jndi path.
A piece of info is that the 903 oc4j release notes states that global conn pooling doesn't
work. Infering that the j2ee/home/config/data-sources.xml data sources aren't pooled or ??
I just tested so called local connection pooling, where I edited the data-sources.xml that
gets packaged in the ear, to include the min/max params and re-ran my test.
Still, the AM creates a new conn, it's to a new socket, and closes the conn when done. Causing
each conn to not be pooled, rather opened then closed to the DB box. As verified with lsof and
netstat, checking the ephemeral port # on the DB box side, always changes, meaning it's a
new socket and not an old pooled conn socket.
???? What the heck??
Surely if the AM conn check out / return code works properly, OC4J's pooling JDBC driver would
pool and not close the socket??
Has anywone gotten JDBC Datasource connections in BC4J to actually be pooled under OC4J??
Since I couldn't get this to work in my early 902 oc4j testing, and now can't get it to work
still under 903 OC4J, either it's my config or BC4J AM's code or OC4J?
Any thoughts on how to figure out what's not configed correctly or has a bug?
Thanks, curt -
Hi,
I yust tried out,
- downloaded and installed the latest Tomcat
- downloaded and installed jstl.jar and standard.jar to ...\common\lib\
- copied my.war to ...\webapps\
the JDBC access is to a DB2/400 on an AS/400.
and run without any problem.
Just FYICopying WAR to <tomcat>/webapps, AFAIK, is not enougth.
You must "deploy" with Tomcat's manager.
Also,
Did you copy jt400.jar to <tomcat>/commons/lib ?
Did you register your data source in Tomcat's admin?
Did you create a resource link from application's context datasource to global datasource?
Regards. -
Connecting to multiple clusters using WAR file
I am trying to connect to multiple clusters by creating separate WAR(web archive) files through Apache tomcat.
My intention is to have each 'war' act as a node to a separate cluster. I started with the 'jmx-console' example available on the Tangosol website.
So, my understanding is that even though all the war files are loaded in the same JVM (tomcat), since each of these war's has its own classloader, we can have multiple tangosol ndoes from the same JVM.
So I have two basic questions:
*) If I use system.setProperty("tangosol.coherence.override", myOverrideFile-x) in the class loader of each WAR, can I have the nodes connect to different clusters. is'nt the System.setProperty() setting the property on the JVM? If so, how can multiple classloaders running in the same JVM connect to different clusters?
*) Where should I place config/override xml files under the tomcat directory structure for it to be accesible to the class loader.Hi sumax,
Thanks for your response Robert,
Maybe I did not understand your solution fully, I
thought your idea mostly talks about how to configure
the override files, and not how to configure the
individual nodes to use different override files.
That part is taken care of by the fact, that each war file loads the tangosol-coherence-override.xml from its own WEB-INF/classes directory.
Classloading from a web app in Tomcat resolves classpath classes/resources in the following order:
1. java.* and javax.* and com.sun.* packages are loaded from the system classloader. This, I believe, cannot be circumvented on a Sun JVM with a classloader extending a JDK classloader class.
2. Reloadable JSP classloader (loads servlet classes generated from JSP pages). This is webapp specific, each webapp sees its own generated servlet classes.
3. Reloadable Webapp classloader (loads from WEB-INF/classes and WEB-INF/lib of the war). This is webapp specific, each webapp sees its own WEB-INF/classes and WEB-INF/lib.
4. Common classloader (loads from ${TOMCAT_HOME}/common/classes and ${TOMCAT_HOME}/common/lib). This is used by all webapps and the Tomcat container itself. You should not put anything here, except for libraries for resource drivers, etc. JDBC drivers or anything which needs to be published in the JNDI server in a non-application-specific way.
5. Shared classloader (loads from ${TOMCAT_HOME}/shared/classes and ${TOMCAT_HOME}/shared/lib). This is shared between all webapps but not by the Tomcat container. You can put libraries here with which you want to communicate between webapps. Any singletons in classes in this classloader will be shared between webapps. A place for configuration files which are shared or if they have the application name in their filenames (so that they are not accidentally used by another application).
The question still lingering in my mind is:
How do I tell the classloader which override file to
load.
A tangosol-coherence-override.xml with different content should be put in the WEB-INF/classes directory of each war file. Each of those files will be loaded only by its containing webapp. This filename is defined in the deployment-mode-specific override files in coherence.jar or tangosol.jar (I don't remember which, off my head) which all chain to this same tangosol-coherence-override.xml file.
That override file can contain all your overrides, if you do not want to change those between restarts, or it can chain with its xml-override attribute (as shown in the example) to another file with the application name in its filename.
This chaining allows each webapp to refer to a differently named override file, so all those override files can be put into shared/classes folder. The uniquely named override file in shared/classes allows you to change the override configuration between restarts.
As for cluster address and port, you can specify those in any of the override files.
The full chaining path is the following (if you used the tangosol-coherence-override.xml example in my first reply):
tangosol-coherence.xml -> tangosol-coherence-prod.xml -> tangosol-coherence.xml (you provide this file in your webapp WEB-INF/classes) -> tangosol-coherence-override-warfilename.xml (you provide this file in the ${TOMCAT_HOME}/shared/classes)
I hope this makes it clear.
Best regards,
Robert -
Netbeans vwp+deploying to external Tomcat
Hi all,
I need to deploy my vwp-webapp to external Tomcat. It uses Mysql database.
What are the main steps in this? I could'nt find any instructions for it.
Thanks in advance.In JSC I have deployed webapp successfull copying common-beanutils.jar, common-digester.jar, standard.jar and jstl.jar from [creator]/modules/autoload/ext to [tomcat]/common/lib.
Exporting WAR-file from JSC to [tomcat]/webapps/ and defining a db-connection in tomcat-admin-webapp.
If I copy war-file from [netbeans-project-folder]/application-name/dist to [tomcat]/webapps and start server to deploy it. This is the same as above.
I can see only first page, if I try to use link to another page, it crashes.
This webapp works in Netbeans IDE.
Anybody have a idea or experiences from this?
Thanks.
Maybe you are looking for
-
Why Selection Screen is taking much time, very first time?
Hi Experts, I hv a Selection Screen-1000 with 15 select options, 2 push buttons, 6 radio buttons, 3 paras. with List Boxes with my_T.Code. So, When I executed this SS-1000 with my_t.code, its consuming time like, 1 - first time - 58 Sec. 2 - 2nd tim
-
Show different distribution channels in one line
Hello everybody, I have the following reporting problem: My customer wants to see an an attribute to 0Mat_sales summarized in one line despite the different distribution channels. With other words there is one material where two different distributio
-
1. After my last synching between iPad3 and iMac, most of my downloaded books have a cloud/arrow symbol and won't open. Most PDF files in iBook just disappeared. I am afraid to resync as a book I recently downloaded, which took up a big chunk of my 5
-
I have a laptop running Win 7 Pro, can I setup a dualboot with Win XP
My laptop is running Win 7 Pro (32-bit) but I have a Iomega Zip 100 drive which has not been supported since Win XP. I have numerous discs with content I would like to access and put onto CD. Can I set up a dualboot system with Win 7 and Win XP witho
-
Payment advice required on ACH file to bank
Hi Folks, My client have a requirement to add payment advice to ACH payment file to bank. I'm generating the DME file (ACH payments ) correctly and are able to print payment advices. I want the payment advice to be added to the DME file; When, I unch