在 struts2 Web 应用程序中添加新的 Web 服务

发布于 2024-12-21 21:18:19 字数 8157 浏览 2 评论 0原文

我正在使用 Netbeans IDE 7.0.1,这些是我正在使用的库:

  • antlr-2.7.6.jar
  • commons-beanutils-1.8.1.jar
  • commons-collections-3.2.jar
  • commons-digester-2.0.jar
  • commons-fileupload-1.2.1.jar
  • commons-logging-1.0.4.jar
  • dom4j-1.6.1.jar
  • ejb3-persistence.jar
  • freemarker-2.3.15.jar
  • hibernate-annotations-3.2.0.ga.jar
  • hibernate-commons-annotations.jar
  • hibernate-core.jar
  • hsqldb.jar
  • javassist-3.9.0.GA.jar
  • jta-1.1 .jar
  • log4j-1.2.15.jar
  • mysql-connector-java-5.1.10-bin.jar
  • ognl-2.7.3.jar
  • slf4j-api-1.4.2.jar
  • slf4j-log4j12-1.4.2.jar
  • struts2-config-browser-plugin-2.1.6.jar
  • struts2-core-2.1.8.1.jar
  • struts2-dojo -plugin-2.2.3.1.jar
  • xwork-core-2.1.6.jar

我创建了一个Struts2 Web 应用程序,我使用 Netbeans 向导在新包 webservice 中添加了一个 Web 服务;在我的 struts.xml 中,我使用了以下内容:

<constant name="struts.action.excludePattern" value="/YouSportWS*"/>

但是当我通过单击 Netbeans 上下文菜单中的测试 Web 服务 来测试我的 Web 服务时,我在浏览器中收到以下错误:

Struts Problem Report

Struts has detected an unhandled exception:

Messages:   
controller.MyWebService
Unable to instantiate Action, controller.YouSportWS, defined for 'YouSportWS' in namespace '/'controller.YouSportWS
File:   org/glassfish/web/loader/WebappClassLoader.java
Line number:    1.519

Stacktraces

Unable to instantiate Action, controller.YouSportWS, defined for 'YouSportWS' in namespace '/'controller.YouSportWS
    com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:307)
    com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:388)
    com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:187)
    org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
    org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
    com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:478)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
    com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
    org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
    com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
    com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
    com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
    com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    java.lang.Thread.run(Thread.java:722)

    java.lang.ClassNotFoundException: controller.YouSportWS
        org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1519)
        org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1369)
        com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:146)
        com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:96)
        com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:149)
        com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:139)
        com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:109)
        com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:288)
        com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:388)
        com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:187)
        org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
        org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
        com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
        org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:478)
        org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
        org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
        org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
        org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
        org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
        org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
        com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
        com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
        org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
        org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
        org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
        com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
        com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
        com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
        com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
        com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
        com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
        com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
        com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
        com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
        com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
        com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
        com.sun.grizzly.ContextTask.run(ContextTask.java:71)
        com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
        com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
        java.lang.Thread.run(Thread.java:722)

我的设置有什么问题?

I'm working on Netbeans IDE 7.0.1, and these are the libraries I am using:

  • antlr-2.7.6.jar
  • commons-beanutils-1.8.1.jar
  • commons-collections-3.2.jar
  • commons-digester-2.0.jar
  • commons-fileupload-1.2.1.jar
  • commons-logging-1.0.4.jar
  • dom4j-1.6.1.jar
  • ejb3-persistence.jar
  • freemarker-2.3.15.jar
  • hibernate-annotations-3.2.0.ga.jar
  • hibernate-commons-annotations.jar
  • hibernate-core.jar
  • hsqldb.jar
  • javassist-3.9.0.GA.jar
  • jta-1.1.jar
  • log4j-1.2.15.jar
  • mysql-connector-java-5.1.10-bin.jar
  • ognl-2.7.3.jar
  • slf4j-api-1.4.2.jar
  • slf4j-log4j12-1.4.2.jar
  • struts2-config-browser-plugin-2.1.6.jar
  • struts2-core-2.1.8.1.jar
  • struts2-dojo-plugin-2.2.3.1.jar
  • xwork-core-2.1.6.jar

I created a Struts2 web application, and I added a web service in a new package webservice by using Netbeans wizard; in my struts.xml I used the following:

<constant name="struts.action.excludePattern" value="/YouSportWS*"/>

but when I test my web service by clicking Test Web Service in Netbeans contextual menu, I get in my browser the following error:

Struts Problem Report

Struts has detected an unhandled exception:

Messages:   
controller.MyWebService
Unable to instantiate Action, controller.YouSportWS, defined for 'YouSportWS' in namespace '/'controller.YouSportWS
File:   org/glassfish/web/loader/WebappClassLoader.java
Line number:    1.519

Stacktraces

Unable to instantiate Action, controller.YouSportWS, defined for 'YouSportWS' in namespace '/'controller.YouSportWS
    com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:307)
    com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:388)
    com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:187)
    org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
    org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
    com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:478)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
    com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
    org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
    com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
    com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
    com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
    com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    java.lang.Thread.run(Thread.java:722)

    java.lang.ClassNotFoundException: controller.YouSportWS
        org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1519)
        org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1369)
        com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:146)
        com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:96)
        com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:149)
        com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:139)
        com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:109)
        com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:288)
        com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:388)
        com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:187)
        org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
        org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
        com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
        org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:478)
        org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
        org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
        org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
        org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
        org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
        org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
        com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
        com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
        org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
        org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
        org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
        com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
        com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
        com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
        com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
        com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
        com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
        com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
        com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
        com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
        com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
        com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
        com.sun.grizzly.ContextTask.run(ContextTask.java:71)
        com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
        com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
        java.lang.Thread.run(Thread.java:722)

What's wrong in my settings?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

柒七 2024-12-28 21:18:19

该模式应该是真正的正则表达式:

excludePattern="YouSportWS.*"

请参阅有关排除的文档

The pattern should be a real regex:

excludePattern="YouSportWS.*"

See the documentation regarding exclusions.

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