浏览 454
已采纳

dwr和spring整合时出的问题

dwr和spring整合时出了的一点问题,请问有谁知道这是怎么回事呢?
具体代码如下:

dwr.xml
[code="java"]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.org/dwr/dwr20.dtd">











[/code]

ItemDAO.java
[code="java"]
public class ItemDAO extends HibernateDaoSupport{

public List findItems(String parent)
{

List list = this.getHibernateTemplate().find("from DBItem where parent="+parent);
return list;
}
}
[/code]

applicationContext.xml
[code="java"]
<?xml version="1.0" encoding="UTF-8"?>
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="dataSource"
    class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName"
        value="com.mysql.jdbc.Driver">
    </property>
    <property name="url"
        value="jdbc:mysql://127.0.0.1:3306/lin?useUnicode=true&amp;characterEncoding=UTF-8">
    </property>
    <property name="username" value="root"></property>      
    <property name="password" value="lin"></property>
</bean>
<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource">
        <ref bean="dataSource" />
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">
                org.hibernate.dialect.MySQLDialect
            </prop>
            <prop key="hibernate.show_sql">true</prop>
        </props>
    </property>
    <property name="mappingResources">
        <list>
            <value>com/Item/wise/DBItem.hbm.xml</value>
        </list>
    </property>
</bean>

<bean id="itemDAO" class="com.Item.wise.ItemDAO">
    <property name="sessionFactory">
        <ref local="sessionFactory" />
    </property>
</bean>


[/code]

[code]
2009-5-22 13:36:49 org.directwebremoting.impl.StartupUtil logStartup
信息: Starting: DwrServlet v3.0.0.116.rc1 on Apache Tomcat/6.0.16 / JDK 1.6.0_06 from Sun Microsystems Inc. at /AjaxStudy
2009-5-22 13:36:50 org.directwebremoting.impl.DTDEntityResolver resolveEntity
警告: Deprecated public id in dwr.xml. Use: <!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 3.0//EN" "http://getahead.org/dwr//dwr30.dtd">
2009-5-22 13:36:50 org.directwebremoting.util.LocalUtil setParams
警告: No property 'location' on org.directwebremoting.spring.SpringCreator
2009-5-22 13:36:50 org.directwebremoting.spring.SpringCreator getBeanFactory
信息: Spring BeanFactory via ClassPathXmlApplicationContext using 1configLocations.
2009-5-22 13:36:51 org.springframework.core.CollectionFactory
信息: JDK 1.4+ collections available
2009-5-22 13:36:51 org.springframework.core.CollectionFactory
信息: Commons Collections 3.x available
2009-5-22 13:36:51 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [applicationContext.xml]
2009-5-22 13:36:51 org.directwebremoting.impl.DefaultCreatorManager addCreator
严重: Error loading class for creator 'SpringCreator[ItemDAO]'.
java.lang.NullPointerException
at org.directwebremoting.spring.SpringCreator.getInstance(SpringCreator.java:153)
at org.directwebremoting.spring.SpringCreator.getType(SpringCreator.java:107)
at org.directwebremoting.impl.DefaultCreatorManager.addCreator(DefaultCreatorManager.java:97)
at org.directwebremoting.impl.DefaultCreatorManager.addCreator(DefaultCreatorManager.java:78)
at org.directwebremoting.impl.DwrXmlConfigurator.loadCreate(DwrXmlConfigurator.java:268)
at org.directwebremoting.impl.DwrXmlConfigurator.loadAllows(DwrXmlConfigurator.java:218)
at org.directwebremoting.impl.DwrXmlConfigurator.configure(DwrXmlConfigurator.java:164)
at org.directwebremoting.impl.StartupUtil.configureFromDefaultDwrXml(StartupUtil.java:587)
at org.directwebremoting.impl.StartupUtil.configureContainerFully(StartupUtil.java:696)
at org.directwebremoting.servlet.DwrServlet.configureContainer(DwrServlet.java:109)
at org.directwebremoting.servlet.DwrServlet.init(DwrServlet.java:68)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:806)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
2009-5-22 13:36:51 org.directwebremoting.impl.DefaultCreatorManager getCreator
严重: Class not found: 'ItemDAO'
2009-5-22 13:36:51 org.directwebremoting.impl.DefaultCreatorManager getCreator
警告: Names of known classes are: __Data Demo JavaDate __System
2009-5-22 13:36:51 org.directwebremoting.servlet.ExceptionHandler handle
警告: Error: java.lang.SecurityException: Class not found
[/code]
[b]问题补充:[/b]
web.xml
[code="java"]
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<servlet>
    <servlet-name>dwr-invoker</servlet-name>
    <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
    <init-param>   
        <param-name>debug</param-name>   
        <param-value>true</param-value>   
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>dwr-invoker</servlet-name>
    <url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

[/code]
[b]问题补充:[/b]
Item.jsp
[code="java"]
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


a";
}
];







Name url order operation



[/code]
谢谢studying_ 的耐心。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • iteye_8326 2009-05-22 17:13
    已采纳

    是否dwr的版本问题?
    我的dwr.jar 包 478KB
    我的web.xml
    [code="java"]<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    ......

    dwr-invoker
    /dwr/*

    [/code]

    点赞 评论
  • iteye_8326 2009-05-22 16:55

    严重: Error loading class for creator 'SpringCreator[ItemDAO]'
    ItemDAO 在相关的配置文件里,(creator是在dwr.xml),错误地加载了。
    请先帖出你的web.xml

    我的web.xml:
    [code="java"]
    dwr-invoker
    DWR Servlet -
    Direct Web Remoter Servlet
    </[/code]

    你的applicationContext.xml也定义了:
    [code="java"]









    [/code]

    dwr.xml 已经定义了:
    [code="java"] [/code]

    点赞 评论
  • iteye_8326 2009-05-22 17:07

    请把你调用这个配置文件的.jsp 代码帖出来,针对性强一些。
    如:
    [code="java"] src='<%=request.getContextPath() %>/dwr/interface/merchDao.js&#39;&gt;<br> [/code]

    你在测试时,merchDao.js是否自动生成了?

    点赞 评论

相关推荐 更多相似问题