在glassfish下登录spring 3.0?

发布于 2024-09-30 16:55:10 字数 752 浏览 0 评论 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回梦 2024-10-07 16:55:10

如果我没记错的话 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文