使用 Spring 和 OAS/OC4J 的 Java WebServices
我在将简单的 WebServices 应用程序(例如简单的“Hello World”)部署到 OC4J 时遇到问题。 相同的代码在 Jetty 下工作正常,但在 OC4J 中中断,我想知道是否有其他人遇到过同样的问题。 我正在使用企业管理器部署应用程序,但部署失败并显示以下消息:
[Jan 23, 2009 8:46:20 AM] Binding TestWs web-module for application TestWs to site default-web-site under context root /TestWs
[Jan 23, 2009 8:46:22 AM] Operation failed with error: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://cxf.apache.org/jaxws]
Offending resource: ServletContext resource [/WEB-INF/beans.xml]
查看 beans.xml,有问题的代码似乎是 XML 命名空间声明:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<jaxws:endpoint
id="helloService"
implementor="com.test.endpoint.HelloImpl"
address="/HelloWorld" />
</beans>
堆栈跟踪不是非常说明问题:
09/01/23 08:57:28 oracle.oc4j.admin.internal.DeployerException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://cxf.apache.org/jaxws]
Offending resource: ServletContext resource [/WEB-INF/beans.xml]
09/01/23 08:57:28 at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
09/01/23 08:57:28 at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
09/01/23 08:57:28 at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
09/01/23 08:57:28 at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:261)
09/01/23 08:57:28 at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1120)
...
是否有其他人遇到过类似的问题? 如果是这样,修复它的最佳方法是什么? 我的 XML 技能中等,而且我对 Web 服务完全是菜鸟。 但这可能是 OC4J 问题。
在此先感谢您的帮助!
编辑:据我所知,这不是一个类路径问题,除非 OC4J 对于它想要在哪里查看哪些 jar 感到奇怪(据我所知 Tomcat 可以)。 我的 WEB-INF/lib 文件夹包含 CXF jar、Spring jar(bean、context、core 和 web)、xml-resolver-1.2.jar 和 XmlSchema-1.4.2.jar。 如果我需要列出 WEB-INF/lib 文件夹中的所有内容,我会的。 但同样,该程序可以在 Jetty 中运行。
最后编辑:感谢大家的帮助。 我从未最终让 CXF 在 OC4J 中工作,因为我的客户端版本为 10.1.3.3.0。 它不符合 J2EE 5,而且我很确定他们不会解压 oc4j.jar 来更改 boot.xml。 但如果没有丹尼尔给我指的文件,我永远不会知道这一点。
所以我切换到 XFire 版本 1.2.6,并在出现一些问题后让我的测试应用程序正常工作。 一路上我学到了一些关于 OC4J 的有趣的事情:
- 在 Enterprise Manager 中部署时,请确保选择首先加载本地类路径。
- OC4J 使用非标准 XML 文件,因此请确保您的应用程序未使用任何 OC4J 的本机 XML 文件(在“部署设置”中,取消选中所有当前选定的导入 - 这样,您可以确保应用程序仅使用您定义的文件)在 WEB-INF/lib 中提供)
- 如果可以,请使用其他应用程序服务器。 :P
再次感谢大家!
I'm having problems deploying a simple WebServices app (like "Hello World" simple) to OC4J. The same code works fine under Jetty, but breaks in OC4J, and I'm wondering if anyone else has faced the same issue. I'm using Enterprise Manager to deploy the app, but the deployment fails with this message:
[Jan 23, 2009 8:46:20 AM] Binding TestWs web-module for application TestWs to site default-web-site under context root /TestWs
[Jan 23, 2009 8:46:22 AM] Operation failed with error: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://cxf.apache.org/jaxws]
Offending resource: ServletContext resource [/WEB-INF/beans.xml]
Looking at the beans.xml, the offending code seems to be the XML namespace declarations:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<jaxws:endpoint
id="helloService"
implementor="com.test.endpoint.HelloImpl"
address="/HelloWorld" />
</beans>
The stack trace is not terribly illuminating:
09/01/23 08:57:28 oracle.oc4j.admin.internal.DeployerException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://cxf.apache.org/jaxws]
Offending resource: ServletContext resource [/WEB-INF/beans.xml]
09/01/23 08:57:28 at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
09/01/23 08:57:28 at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
09/01/23 08:57:28 at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
09/01/23 08:57:28 at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:261)
09/01/23 08:57:28 at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1120)
...
Has anyone else run into similar problems? And if so, what's the best way to go about fixing it? My XML skills are middling, and I'm a complete noob with WebServices. But this may be an OC4J issue.
Thanks in advance for your help!
EDIT: This is not, as far as I can tell, a classpath issue, unless OC4J is odd about what jars it want to see where (as I know Tomcat can be). My WEB-INF/lib folder has the CXF jar, the Spring jars (beans, context, core, and web), xml-resolver-1.2.jar, and XmlSchema-1.4.2.jar. If I need to list everything in the WEB-INF/lib folder, I will. But again, the program works in Jetty.
Another Edit: Based on what I'm reading here, this appears to be an issue between Spring and the CXF jar -- there's a NamespaceHandler class in the CXF jar (in org.apache.cxf.frontend.spring
to be precise), but there seems to be a configuration issue preventing Spring from seeing it.
Last Edit: Thank you everyone for your help. I never ended up getting CXF working in OC4J, because my client is on version 10.1.3.3.0. It's not J2EE 5 compliant, and I'm pretty sure they're not going to go for unpacking their oc4j.jar in order to change the boot.xml. But without the document Daniel pointed me to, I never would have known that.
So I switched to XFire version 1.2.6, and got my test app working after a few hiccups. Along the way I learned some interesting things about OC4J:
- When deploying in Enterprise Manager, make sure you choose to load the local classpath first.
- OC4J uses non-standard XML files, so make sure your app is not using any of OC4J's native XML files (in the Deployment Settings, uncheck all the currently selected imports -- that way, you can ensure that the app is using only files you provide in WEB-INF/lib)
- If you can, use another app server. :P
Thank you all again!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不想问显而易见的问题,但是您是否从 CXF 网站上查看了用于配置 OS4J 和 CXF 的所有内容?
http://cwiki.apache.org/CXF20DOC/appserverguide.html#AppServerGuide- OC4J
I hate to ask the obvious, but have you looked at all the stuff for configuring OS4J and CXF together from the CXF web site?
http://cwiki.apache.org/CXF20DOC/appserverguide.html#AppServerGuide-OC4J
看起来像 Spring 的配置问题:
您的 web.xml 中是否有任何内容可以在应用程序启动时读取? 您是否在代码中的任何位置看到为该命名空间声明的 NamespaceHandler?
Looks like a configuration issue with Spring:
Do you have anything in your web.xml to read that when the app starts up? Do you see a NamespaceHandler declared for that namespace anywhere in your code?
我认为这是一个 CLASSPATH 问题。
我对 OC4J 不太熟悉,但是您如何打包/部署您的 Web 应用程序?
您需要确保 CXF jar 位于 WAR 的 WEB-INF/lib 目录中?
更新:您的评论有点困惑 - 如果您的 spring 配置位于 EAR 的 META-INF 目录中,那么这与您的 Web 应用程序使用的类路径不同。 因此,事实上,将 CXF jar 粘贴到 WEB-INF/lib 中是行不通的。 您需要将 JAR 粘贴到 EAR 的顶层,或者粘贴到 OC4J 的所有类加载器共享的某个库中。 我建议研究OC4J的企业应用程序/网络应用程序类加载器层次结构文档,看看这是否可以提供更多建议?
I would think its a CLASSPATH issue.
I'm not that familiar with OC4J, but how are you packaging/deploying your web-application?
You need to ensure that the CXF jar is in the
WEB-INF/lib
directory of your WAR?Update: A little confused by your comments - if your spring config is in the
META-INF
directory of your EAR, then this is not the same classpath as that used by your web-app. So, in fact, sticking the CXF jar inWEB-INF/lib
isn't going to work. You will either need to stick the JAR in the top-level of your EAR, or in some lib shared by all classloaders of OC4J. I suggest studying the enterprise-app/web-app classloader hierarchy documentation of OC4J to see if this can give more advice?