WebSphere 尝试从互联网加载 Spring 相关模式
我在 j2ee 应用程序中运行 spring 时遇到一些问题。
简短介绍:
我使用WebSphere 6.1(我不知道这是websphere特定的还是更普遍的问题)
工件:
- Web应用程序(war)在WEB-INF/lib文件夹中maven发布了所有需要的spring依赖关系。
- 然后将war打包到ear中并部署到应用服务器上。
我还没有应用程序中的任何 spring 配置文件或对 spring 的引用。只是 WEB-INF/lib
中的 jar 文件,没有更多关于 spring 的内容。
当应用程序部署并且应用程序开始加载应用程序服务器时,开始查找一些 spring xml 模式:
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tool/spring-tool-2.0.xsd http://www.springframework.org/schema/tool/spring-tool-2.5.xsd
http://www.springframework.org/schema/tool/spring-tool-3.0.xsd
它想通过上面指定的url从互联网上获取它们。
问题:
如何强制应用程序服务器使用位于本地(网络存档中)的架构? 或者也许根本禁用此检查?
另一方面,当应用程序启动时,一切工作都完美(后来我尝试使用 IoC)。
应用程序服务器没有 Internet 连接,并且解析此架构的所有尝试都会导致等待连接超时。
我尝试的方法:
将包含 url 映射到 Web 存档中架构的 spring.schemas
放入 META-INF
文件夹中。所有这些文件(spring.schemas
和 xml 模式)都可以通过 ClassLoader
访问(选中)。
任何帮助将不胜感激。
/me [愚蠢的 j2ee 开发人员]
更新 1:
以下是我从 websphere 日志文件中获取的确切消息:
[22.07.10 15:45:58:626 MSD] 00000043 XMLParser W java.net.SocketException occurs during processing http://www.springframework.org/schema/tool/spring-tool-2.0.xsd: Operation timed out: connect:could be due to invalid address
[22.07.10 15:46:20:112 MSD] 00000043 XMLParser W java.net.SocketException occurs during processing http://www.springframework.org/schema/beans/spring-beans-2.0.xsd: Operation timed out: connect:could be due to invalid address
[22.07.10 15:46:41:124 MSD] 00000043 XMLParser W java.net.SocketException occurs during processing http://www.springframework.org/schema/tool/spring-tool-2.5.xsd: Operation timed out: connect:could be due to invalid address
[22.07.10 15:47:02:118 MSD] 00000043 XMLParser W java.net.SocketException occurs during processing http://www.springframework.org/schema/beans/spring-beans-2.5.xsd: Operation timed out: connect:could be due to invalid address
[22.07.10 15:47:23:130 MSD] 00000043 XMLParser W java.net.SocketException occurs during processing http://www.springframework.org/schema/tool/spring-tool-3.0.xsd: Operation timed out: connect:could be due to invalid address
[22.07.10 15:47:44:129 MSD] 00000043 XMLParser W java.net.SocketException occurs during processing http://www.springframework.org/schema/beans/spring-beans-3.0.xsd: Operation timed out: connect:could be due to invalid address
I have some problem running spring in my j2ee application.
Short introduction:
I use WebSphere 6.1 (i don't know that it is websphere specific or more general problem)
Artifacts:
- web application (war) where in WEB-INF/lib folder maven publishes all needed spring dependencies.
- war is then packaged in ear and deploys on application server.
I don't have any spring configuration files or references to spring in the application yet. Just jar files inside WEB-INF/lib
and nothing more about spring.
When application is deployed and application starts loading application server start looking for some spring xml schemas:
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tool/spring-tool-2.0.xsd
http://www.springframework.org/schema/tool/spring-tool-2.5.xsd
http://www.springframework.org/schema/tool/spring-tool-3.0.xsd
It want to took them from internet by url's specified above.
Question:
How to force application server to use schemas located locally (in web archive)?
Or maybe disable this checks at all?
On the other hand when application starts all works perfectly (later i had try to use IoC).
Application server doesn't have internet connection and all attempts to resolve this schemas results in waiting for connection time-out.
What i try:
Put spring.schemas
containing url's mappings to schemas located in web archive into META-INF
folder. All this files (spring.schemas
and xml schemas) is accessible by ClassLoader
(checked).
Any help will be greatly appreciated.
/me [stupid j2ee developer]
Update 1:
Here is exact messages that i take from websphere log file:
[22.07.10 15:45:58:626 MSD] 00000043 XMLParser W java.net.SocketException occurs during processing http://www.springframework.org/schema/tool/spring-tool-2.0.xsd: Operation timed out: connect:could be due to invalid address
[22.07.10 15:46:20:112 MSD] 00000043 XMLParser W java.net.SocketException occurs during processing http://www.springframework.org/schema/beans/spring-beans-2.0.xsd: Operation timed out: connect:could be due to invalid address
[22.07.10 15:46:41:124 MSD] 00000043 XMLParser W java.net.SocketException occurs during processing http://www.springframework.org/schema/tool/spring-tool-2.5.xsd: Operation timed out: connect:could be due to invalid address
[22.07.10 15:47:02:118 MSD] 00000043 XMLParser W java.net.SocketException occurs during processing http://www.springframework.org/schema/beans/spring-beans-2.5.xsd: Operation timed out: connect:could be due to invalid address
[22.07.10 15:47:23:130 MSD] 00000043 XMLParser W java.net.SocketException occurs during processing http://www.springframework.org/schema/tool/spring-tool-3.0.xsd: Operation timed out: connect:could be due to invalid address
[22.07.10 15:47:44:129 MSD] 00000043 XMLParser W java.net.SocketException occurs during processing http://www.springframework.org/schema/beans/spring-beans-3.0.xsd: Operation timed out: connect:could be due to invalid address
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在使用公共验证器框架时遇到了这个问题。我所做的就是更改 xml 文件中的命名空间(通常指定它们的位置)以指向我在网络服务器上托管的本地版本。对于spring,我猜是ApplicationContext.xml。
http://www.springframework.org/schema/beans/spring-beans -2.0.xsd
http://yourservername/springns/schema/beans/spring-beans-2.0.xsd
这不是完美的解决方案,但它有效。
让我知道进展如何。
I had this problem with commons validator framework. What I did was to change the namespaces in the xml file [where they are normally specified] to point to a local version that I hosted on my webserver. For spring, I guess it is the ApplicationContext.xml.
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://yourservername/springns/schema/beans/spring-beans-2.0.xsd
This is not the perfect solution, but it works.
Let me know how it goes.
这可能是类加载器问题,来自另一个 WAR 的文件试图访问 spring 模式。或者应用程序服务器可能会尝试加载 web.xml 中指定的 spring 文件。
您可以尝试将 spring.schemas 和 XSD 文件放在 EAR 目录的根目录中。如果任何其他 WAR 文件尝试加载这些文件,则根据默认的 PARENT_FIRST 类加载器策略,它应该能够找到架构。为了完全排除类加载器问题,如果上一步没有帮助,请尝试将 XSD 文件放入 JRE/lib/ext 目录中的 jar 中,然后重新启动服务器。
This could be a classloader issue where a file from another WAR is trying to access the spring schema. Or maybe the appserver tries to load the spring files which are specified in the web.xml.
You can try placing the spring.schemas and XSD files in the root of the EAR directory. If any other WAR file is attempting to load the files, then based on the default PARENT_FIRST classloader policy, it should be able to find the schemas. Just to rule out the classloader issue completely, if the previous step did not help, try placing the XSD files in a jar in the JRE/lib/ext directory and restarting the server.