在JFinal中使用Spring ldap出错

reanw 发布于 2013/06/13 23:53
阅读 895
收藏 0

@JFinal 你好,想跟你请教个问题:我现在在做一个通过JFinal+Spring Ldap操作Ldap的项目,但现在一直调试不通过。当我在Controller的一个方法中定义 LdapContextSource cs = new LdapContextSource();的时候就不能通过了,浏览器显示:

500 Internal Server Error

JFinal/1.4

eclipse的Console窗口没有任何的错误显示,如果使用调试模式进行跟踪发现,运行到上边那个定义语句时就会跳到ActionInvocation的invoke方法中斜体的那一句去,如下:

public void invoke() {
if (index < inters.length)
inters[index++].intercept(this);
else if (index++ == inters.length) // index++ ensure invoke action only one time
// try {action.getMethod().invoke(controller, NULL_ARGS);} catch (Exception e) {throw new RuntimeException(e);}
try {
action.getMethod().invoke(controller, NULL_ARGS);
}
catch (InvocationTargetException e) {
Throwable cause = e.getTargetException();
if (cause instanceof RuntimeException)
throw (RuntimeException)cause;
throw new RuntimeException(e);
}
catch (RuntimeException e) {
throw e;
}
catch (Exception e) {
throw new RuntimeException(e);
}
}


这个问题已经找了两天了,谢谢了。
加载中
0
JFinal
JFinal
要看到错误提示才好解决问题,检查一下log4j配置文件先,或先看下jfinal demo
0
reanw
reanw

引用来自“JFinal”的答案

要看到错误提示才好解决问题,检查一下log4j配置文件先,或先看下jfinal demo

原来是我的log4j没有配置好,把log4j配置好后原先的问题竟然好了,但现在还有一个问题,就是我在configPlugin中注册SpringPlugin的时候出错,以下是错误信息:

2013-6-14 13:31:05 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter jfinal
java.lang.NoClassDefFoundError: org/springframework/asm/ClassVisitor
at org.springframework.context.support.AbstractRefreshableApplicationContext.customizeBeanFactory(AbstractRefreshableApplicationContext.java:218)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
at com.jfinal.plugin.spring.SpringPlugin.start(SpringPlugin.java:52)
at com.jfinal.core.Config.startPlugins(Config.java:78)
at com.jfinal.core.Config.configJFinal(Config.java:48)
at com.jfinal.core.JFinal.init(JFinal.java:68)
at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:277)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4650)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5306)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3920)
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:426)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1345)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1530)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1519)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.springframework.asm.ClassVisitor
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
... 26 more

以下是我的applicationContext.xml的内容:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="contextSource" class="org.springframework.ldap.support.LdapContextSource">
<property name="url" value="ldap://10.11.5.204:389" />
<property name="base" value="dc=buu,dc=edu,dc=cn" />
<property name="userName" value="cn=Manager" />
<property name="password" value="wabjtam369" />
</bean>
<bean id="ldapTemplate" class="org.springframework.ldap.LdapTemplate">
<constructor-arg ref="contextSource" />
</bean>
<bean id="personDao" class="net.leow.ldap.PersonDaoImpl">
<property name="ldapTemplate" ref="ldapTemplate"></property>
</bean>
</beans>

还请 @JFinal 指教,谢谢啦!

0
戴威
戴威

引用来自“reanw”的答案

引用来自“JFinal”的答案

要看到错误提示才好解决问题,检查一下log4j配置文件先,或先看下jfinal demo

原来是我的log4j没有配置好,把log4j配置好后原先的问题竟然好了,但现在还有一个问题,就是我在configPlugin中注册SpringPlugin的时候出错,以下是错误信息:

2013-6-14 13:31:05 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter jfinal
java.lang.NoClassDefFoundError: org/springframework/asm/ClassVisitor
at org.springframework.context.support.AbstractRefreshableApplicationContext.customizeBeanFactory(AbstractRefreshableApplicationContext.java:218)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
at com.jfinal.plugin.spring.SpringPlugin.start(SpringPlugin.java:52)
at com.jfinal.core.Config.startPlugins(Config.java:78)
at com.jfinal.core.Config.configJFinal(Config.java:48)
at com.jfinal.core.JFinal.init(JFinal.java:68)
at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:277)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4650)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5306)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3920)
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:426)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1345)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1530)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1519)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.springframework.asm.ClassVisitor
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
... 26 more

以下是我的applicationContext.xml的内容:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="contextSource" class="org.springframework.ldap.support.LdapContextSource">
<property name="url" value="ldap://10.11.5.204:389" />
<property name="base" value="dc=buu,dc=edu,dc=cn" />
<property name="userName" value="cn=Manager" />
<property name="password" value="wabjtam369" />
</bean>
<bean id="ldapTemplate" class="org.springframework.ldap.LdapTemplate">
<constructor-arg ref="contextSource" />
</bean>
<bean id="personDao" class="net.leow.ldap.PersonDaoImpl">
<property name="ldapTemplate" ref="ldapTemplate"></property>
</bean>
</beans>

还请 @JFinal 指教,谢谢啦!

你是否引用了spring-core这个jar?
reanw
reanw
已经引用了这个包了,下边是我的截图,谢谢
0
reanw
reanw

已经引用了这个包了,下边是我引用的包的截图,请指教。

0
戴威
戴威
那你试以下可否在Java文件中引用org.springframework.asm.ClassVisitor这个类。
reanw
reanw
我把spring换成了3.2,错误又变了,我想应该是包间依懒的问题,我再自己检查一下吧,谢谢
reanw
reanw
我发现问题了,我下载的包中,org.springframework.asm.ClassVisitor是个接口,不是一个类,可是下载了几个,这都不是一个类,不知道为什么,这个接口我需要自己实现吗?
返回顶部
顶部