新手请教问题

初学DWR,现在有如下问题:

在dwr.xml下面配置自定义的类时会报错,类找不到。但是我的类明明在com.hl.dwr下了啊。而且已经编译好了classes也有。

在网上找了好久,都找不到是什么原因。请各位高手帮我一下。

警告: Error setting class=com.hl.dwr.Hello on org.directwebremoting.create.NewCreator

java.lang.IllegalArgumentException: Class not found: com.hl.dwr.Hello

at org.directwebremoting.create.NewCreator.setClass(NewCreator.java:46)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at org.directwebremoting.util.LocalUtil.setProperty(LocalUtil.java:388)

at org.directwebremoting.util.LocalUtil.setParams(LocalUtil.java:347)

at org.directwebremoting.impl.DefaultCreatorManager.addCreator(DefaultCreatorManager.java:96)

at org.directwebremoting.impl.DwrXmlConfigurator.loadCreate(DwrXmlConfigurator.java:274)

at org.directwebremoting.impl.DwrXmlConfigurator.loadAllows(DwrXmlConfigurator.java:224)

at org.directwebremoting.impl.DwrXmlConfigurator.configure(DwrXmlConfigurator.java:170)

at org.directwebremoting.impl.ContainerUtil.configureFromDefaultDwrXml(ContainerUtil.java:264)

at org.directwebremoting.impl.ContainerUtil.configureContainerFully(ContainerUtil.java:421)

at org.directwebremoting.servlet.DwrServlet.init(DwrServlet.java:79)

at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)

at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)

at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)

at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)

at java.lang.Thread.run(Thread.java:595)

2008-8-29 11:23:14 org.directwebremoting.util.CommonsLoggingOutput error

严重: Creator: 'NewCreator[Hello]' for Hello.js is returning null for type queries.

2008-8-29 11:23:14 org.directwebremoting.util.CommonsLoggingOutput warn

警告: Names of known classes are: JDate

2008-8-29 11:23:14 org.directwebremoting.util.CommonsLoggingOutput warn

警告: Unhandled Exception

java.lang.SecurityException: No class by name: Hello

at org.directwebremoting.impl.DefaultCreatorManager.getCreator(DefaultCreatorManager.java:189)

at org.directwebremoting.impl.DefaultRemoter.generateInterfaceScript(DefaultRemoter.java:158)

at org.directwebremoting.servlet.InterfaceHandler.handle(InterfaceHandler.java:50)

at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)

at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)

at org.directwebremoting.servlet.DwrServlet.doGet(DwrServlet.java:132)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)

at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)

at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)

at java.lang.Thread.run(Thread.java:595)

我的dwr.xml如下

<!----> 

<dwr>
<allow>
<create creator="new" javascript="JDate">

</create>
<create creator="new" javascript="Hello">

</create>
</allow>
</dwr>



我的web.xml如下

<!---->
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<display-name>WebModule1</display-name>
<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>
<init-param>
<param-name>classes</param-name>
<param-value>java.lang.Object</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<servlet>
<description>Added by JBuilder to compile JSPs with debug info</description>
<servlet-name>debugjsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>classdebuginfo</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>debugjsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
</web-app>


java代码

package com.hl.dwr;
public class Hello {
public String SayHello(String user){
return "hello"+user;
}
}


jsp

<html> 
<head>
<title>
<script type="text/javascript" src="dwr/interface/JDate.js"></script>
<script type="text/javascript" src="dwr/interface/Hello.js"></script>
<script type="text/javascript" src="dwr/engine.js"></script>
<script type="">
function hello(){
var user = document.getElementById("username").value;
Hello.SayHello(user,load);
}
function load(data){
alert(data)
}
function getdate(){
JDate.getDate(Dateload);
}
function Dateload(data){
alert(data)
}
</script>
</head>
<body onload="getdate()">
<input id="username" type="text">
<input type="button">
</body>
</html>




Jdate就好用,可以找到类。这是为什么?




问题补充:
我的classes路径:C:\Documents and Settings\Administrator\jbproject\Dwr\classes\com\hl\dwr

Jbuilder的output path

C:/Documents and Settings/Administrator/jbproject/Dwr/classes


问题补充:
我的类就在C:\Documents and Settings\Administrator\jbproject\Dwr\classes\com\hl\dwr

这里 可以找到。



我想问问DWR是如何匹配我这个路径的??????他默认的包位置放在哪?我要是想改变该如何去配置??



为什么jdk原有的包下(java.util.Date)就可以找到。但是我自定义的包(com.hl.dwr)就找不到
dwr

3个回答

87年的???????????????????????
太刺激了,太刺激了 :cry: :cry: :cry: :cry:

你的classes都生成在哪了?贴下路径吧

你的 web.xml和classes是在一个文件夹下么?

在web.xml的文件夹内,建立一个classes文件夹,把“Jbuilder的output path ”指向到这里面

java.lang.IllegalArgumentException: Class not found: com.hl.dwr.Hello
提示的很清楚了,你的类没找到,你仔细检查文件的位置!

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问