在glassfish下登录spring 3.0?
我正在尝试调试为什么 Spring 的 AnnotationMethodHandlerAdapter 不调用我的控制器之一中的某些处理程序。我在 Netbeans 中没有收到任何错误,只是在浏览器中收到 404 错误。我尝试在我的一个工作控制器/处理程序中放置一个断点,然后沿着链向上在调度程序中放置一个断点。
Netbeans 向我展示了一些有趣的方法体:
protected ModelAndView invokeHandlerMethod(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
{
//compiled code
throw new RuntimeException("Compiled Code");
}
我怀疑这是由 AOP magiq 引起的。没有被吓倒,我尝试配置 log4j 来跟踪调用并显示从 org.springframework.web.servlet.mvc.annotation 包在调试级别记录的任何消息,但只需创建一个 log4j.properties 文件并放入我得到的类路径无非是默认的“INFO:”级别消息。在 web.xml 中添加 context-param 和侦听器失败,因为容器找不到 log4j 类,即使它们在那里,即使我可以将它们再次添加到项目中。
那么,问题是——在 Spring 3.0 下,我需要做什么来获取方法跟踪(这可以通过 AOP 完成)和增强调试(这肯定需要 log4j)?
I'm trying to debug why certain handlers in one of my controllers is not invoked by Spring's AnnotationMethodHandlerAdapter. I don't get any errors in Netbeans, just a 404 in the browser. I tried placing a breakpoint in one of my working controllers/handlers then walking up the chain to place a breakpoint in the dispatcher.
Netbeans shows me some funny method bodies:
protected ModelAndView invokeHandlerMethod(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
{
//compiled code
throw new RuntimeException("Compiled Code");
}
which I suspect is caused by the AOP magiq. Undeterred, I tried to configure log4j to trace the calls and display any messages logged at debug level from the org.springframework.web.servlet.mvc.annotation package, but just by creating a log4j.properties file and putting in the classpath I get nothing more than the default "INFO:" level messages. Adding the context-param and listener in web.xml fails because the container can't find the log4j classes, even though they are there and even though I can add them again to the project.
So, the question is -- what do I need to do to get method traces (this could be done through AOP) and enhanced debugging (this definitely needs log4j) under Spring 3.0?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我没记错的话 Spring 3.X 使用 SLF4J 进行日志记录。通常,您需要为您选择的日志框架添加 SLF4J 绑定 - 例如,对于 log4,slf4j-log4j12 jar 应该存在于类路径以及 log4j.jar 中,并且它们最好是正确的版本 - 我发现 SLF4J 很挑剔那。请在此处查看更多详细信息。另外不要忘记 log4j.xml 配置。
If I'm not mistaken Spring 3.X uses SLF4J for logging. Usually you would need to add SLF4J binding for your logging framework of choice - for example, for log4, slf4j-log4j12 jar should be present in classpath as well as log4j.jar and they better be proper versions - I found SLF4J to be picky about that. See more details here. Also don't forget log4j.xml config.