Now I can see two main suspects: "getSortedSectionArray" not being
called in your code after the update and sectionArray/toSection
relationship pair not being setup properly in the mapping. I guess
you need to do some debugging to see what really happens.
> Can you explain how i can write to a file using log4j?
Chances are Cayenne log is already being written to the standard
output of your web container (and container probably redirects it to
a file). If this is Tomcat, check $TOMCAT_HOME/logs/ directory. There
is probably a bunch of files there. Check both "catalina.out" and the
latest localhost* file. On other containers there are similar default
log locations.
To set custom logging in a web application, I usually copy
$CAYENNE_HOME/src/cayenne/.cayenne/cayenne-log.properties file to
some location under WEB-INF/ app directory, customize it per Log4J
documentation (this is not as bad as it sounds - usually you just
need to tweak levels of the existing loggers - see lines starting
with "log4j.logger.*" in a sample file, you may need to add a few
more if you create your own loggers). Here is a link to Log4J quick
start page: http://logging.apache.org/log4j/docs/manual.html
After that I bootstrap Log4J using one of the standard mechanisms
from servlet spec. E.g. an old and proven one - initialization
servlet. In this example it checks for "log4j-config" init parameter:
public class StartupServlet extends GenericServlet {
public static final String LOG4J_CONFIG = "log4j-config";
public void init(ServletConfig config) throws ServletException {
super.init(config);
// setup logging..
String logFile = getInitParameter(LOG4J_CONFIG);
if (logFile != null) {
try {
URL loggingURL = getServletContext().getResource
(logFile);
if (loggingURL != null) {
PropertyConfigurator.configure(loggingURL);
}
}
catch (MalformedURLException ex) {
log("Error setting up logging, ignoring: " +
ex.getMessage());
}
}
}
public void service(ServletRequest request, ServletResponse
response)
throws ServletException, IOException {
throw new ServletException("Unsupported...");
}
}
[this goes to web.xml]:
<servlet>
<servlet-name>startup</servlet-name>
<servlet-class>xyz.StartupServlet</servlet-class>
<init-param>
<param-name>log4j-config</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
Andrus
This archive was generated by hypermail 2.0.0 : Sun Jun 05 2005 - 12:54:05 EDT