Re: WEB-INF/web.xml
Jacob Kjome <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <[email protected]> |
Hi Damar,
Are you using the latest CVS source or an official release? I suggest
using the latest CVS.
Also, notice Barracuda's web.xml how log4j is initialized....
<context-param>
<param-name>log4j-selector</param-name>
<param-value>org.apache.log4j.selector.ContextJNDISelector</param-value>
</context-param>
<context-param>
<param-name>log4j-config</param-name>
<param-value>WEB-INF/log4j.xml</param-value>
</context-param>
<context-param>
<param-name>log4j-cron</param-name>
<param-value>5000</param-value>
</context-param>
<listener>
<listener-class>
org.apache.log4j.servlet.InitContextListener
</listener-class>
</listener>
...and further down web.xml....
<env-entry>
<description>JNDI logging context for this webapp</description>
<env-entry-name>log4j/logging-context</env-entry-name>
<env-entry-value>BarracudaMVC</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
Notice that the <env-entry> is only required for the ContextJNDISelector
set in the <context-param> tag above. You can also use
ContextClassLoaderSelector. Change
<env-entry-value>BarracudaMVC</env-entry-value> to a unique name for your
app. This entry must be unique in the JNDI namespace for the server.
You'll then need the log4j-sandbox-selector-0.1alpha.jar and
log4j-sandbox-servlet-0.1alpha.jar available to your app. At least the
log4j-sandbox-servlet-0.1alpha.jar *must* be in your WEB-INF/lib
directory. You can also put log4j.jar and the selector jar in WEB-INF/lib
or put both of them in shared classloaders. In this case, you should put
log4j.jar in CATALINA_HOME/common/lib (because commons-logging goes
complains if it is elsewhere...don't ask me why...I can't stand
commons-logging!) and the selector jar in shared/lib.
The other thing to remember is, if you are using a FileAppender, is to
modify your log4j.xml in a way that the "File" parameter points to a system
variable which is set up by the log4j InitContextListener. For instance,
here is the value in Barracuda's log4j.xml....
<param name="File" value="${Barracuda.log.home}/main.log" />
The initContextListener dynamically figures out the name of your app by
looking at the value of the ServletContext attribute
"javax.servlet.context.tempdir". In Tomcat, this name is very
predictable. If the app path is "/Barracuda", then the last directory in
the path to the value of "javax.servlet.context.tempdir" for this context
will be "Barracuda". If your app is named "myapp", then you would change
the "File" attribute such as...
<param name="File" value="${myapp.log.home}/main.log" />
Note that if you are deploying your app as the ROOT context in Tomcat, then
you would the "File" attribute should be....
<param name="File" value="${_.log.home}/main.log" />
I actually recommend against using the ROOT context for your app. Instead,
have an index.html file there to do a redirect to the app you want them to
be in. This avoids lots of problems that you run into when trying to use
the ROOT context for your own app.
Also note that the Barracuda build, the contrib project builds, and my
example build (based on Diez' cotrib project) called
barracuda-pages.sample generate the appropriate log4j.xml config
dynamically at build time via filter copying sample.log4j.xml. It makes it
so you really only have to worry about log4j configuration in
web.xml...unless you want to add new loggers to log4j.xml. I will have a
new barracuda-pages.sample build out sometime today based on the latest
CVS. The current build uses XMLC-2.1 and Barracuda's latest CVS just moved
to XMLC-2.2 so I highly recommend grabbing it if you want an example of how
to build your Barracuda webapp. See it here...
ftp://ftp.visi.com/users/hoju/pub
just make sure the date is 03/26/2003 before downloading.
For your <war> task issue, this is an Ant question and is better asked on
the Apache Ant list. You can take a look at Barracuda's build.xml to see
how it the <war> task is used there for an example.
Jake
At 04:20 PM 3/26/2003 +0800, you wrote:
>Further to my earlier question I have the followings:
>
>1. When I compile the page, I get the following Warning at the end:
>
>[war] Warning: selected war files include a WEB-INF/web.xml which will be
>ignored (please use webxml attribute to war task)
>
>What does it mean? Does it mean to say that .war file will ignore the
>web.xml file? How can I use webxml attribute?
>
>2. After running the application with run, all seems ok, and I can
>see my page at http://myhouse.com:8002/mypage. But I get the following
>error message at the application console shell:
>
>log4j:WARN No appenders could be found for logger
>(org.enhydra.barracuda.core.comp.helper.ComponentGateway).
>log4j:WARN Please initialize the log4j system properly.
>
>Does does it mean? How can I initialize log4j?
>
>Any pointers would be highly appreciated.
>
>Thanks.
>
>Damar
>
>_______________________________________________
>Barracuda mailing list
>[email protected]
>http://barracudamvc.org/lists/listinfo/barracuda