在迁移到Spring 3之后,从Eclipse IDE启动基于Maven的GWT App时,会发生Spring NamespaceHandler问题 [英] Spring NamespaceHandler issue when launching Maven-based GWT App from Eclipse IDE after migration to Spring 3

查看:99
本文介绍了在迁移到Spring 3之后,从Eclipse IDE启动基于Maven的GWT App时,会发生Spring NamespaceHandler问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个我已经呆了好几个小时的问题,现在我觉得很绝望。
我将应用程序从Spring 2.5 / Hiberante 3.3迁移到Spring 3.0.5 / Hibernate 3.6。以下是完成的:




  • 更新spring依赖/版本(现在有不止一些依赖)

  • 更新Hibernate依赖/版本

  • 根据'schemaLocation'的版本更新Spring上下文XML文件



在不同的次要修复和调整之后,从Eclipse IDE启动时,我仍然遇到的错误如下:

 配置问题:无法找到Spring NamespaceHandler的XML模式命名空间[http://www.springframework.org/schema/tx] 

我查看了其他线程,并意识到在类路径中找不到特定的lib(在这种情况下为spring-tx)时,会出现这样的问题,但我清楚地看到它在我的Maven依赖关系中。 >

下一件事我做了,我构建了WAR ,就像我以前的版本一样,部署在Tomcat上,应用程序运行正常



通过这个我可以得出结论,在Eclipse环境配置中缺少一些东西。有趣的是,所有抱怨都是关于spring-tx,当我使用tx命名空间删除单行
< tx:annotation-driven transaction-manager =transactionManager/>
..应用程序开始正常,没有抱怨其他命名空间(当然,它没有正常工作,但至少没有抱怨在init)。



有关我的IDE /项目设置的一些总结:




  • 应用程序启动由GWT .launch文件(GWT ver 2.0 .3)

  • 在这个启动文件中有引用其他项目,其中包括具有弹簧依赖性的服务器端

  • 其实这个gwt-client项目具有服务器端POM作为父级,因此我看到该项目的Maven依赖关系中的所有Spring依赖项。

  • GWT-client项目具有/war/WEB-INF/applicationContext.xml,导入其他上下文XML资源,其实际上是利用spring-tx



正式的问题是:在迁移到Spring 3x之后,项目从IDE中发生这种错误的可能原因是什么(并且作为构建的WAR)部署得很好?



我不期望直接的答案(除非有一个人有完全相同的环境和问题),但是指导方针,建议将会非常有帮助!



编辑
忘了提到在IDE的应用程序启动期间,我有一些警告如下:

  [WARN]服务器类'javax.persistence.EntityManagerFactory'找不到web应用程序,但是在系统classpath 
中找到[WARN]添加类路径条目'file:/ D:/maven/repository/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.0 .Final / hibernate-jpa-2.0-api-1.0.0.Final.jar'到此会话的web应用程序类路径
[WARN]服务器类'org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor'可以在网络应用程序中找不到,但在系统classpath
中找到[WARN]添加类路径条目'file:/ D:/maven/repository/org/springframework/spring-orm/3.0.5.RELEASE/ spring-orm-3.0.5.RELEASE.jar'到此会话的web应用程序类路径

。所以也许spring-tx也是我在网络应用程序中找不到(在系统类路径中找到),但是不像其他人那样添加它?这个行为的原因是什么?

解决方案

如果您的类路径上有多个弹簧依赖关系,那么您可能会遇到maven的这个问题:



使用多媒体Spring依赖关系,来自META-INF(来自Spring jar)的文件在可执行的jar中依次相互覆盖



要解决这个问题,请参阅来自克里斯·威尔克斯(Chris Wilkes)。您需要将spring.handlers和spring.schemas复制到META-INF目录中。


Here's an issue I'm stuck with for multiple hours already, and by now I feel quite desperate. I migrated our application from Spring 2.5/Hiberante 3.3 to Spring 3.0.5/Hibernate 3.6. The following was done:

  • updated spring dependencies/version (now there's more than just a few dependencies)
  • updated Hibernate dependencies/version
  • updated Spring context XML files in terms of versions for 'schemaLocation'

The error I still have when launching from Eclipse IDE after different minor fixes and tunes, is as following:

Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/tx]

I looked through the other threads, and realized that such a problem arises when the specific lib (in this case spring-tx) not found in classpath, but I clearly see it in my Maven dependencies.

The next thing I did, I built the WAR as I did it for previous versions, deployed it on Tomcat, and the app worked fine!

By this I can make a conclusion that something is missing in Eclipse environment configuration. What's interesting that all complains are about spring-tx,- when I removed the single line utilizing tx namespace <tx:annotation-driven transaction-manager="transactionManager" /> .. application started fine without complains about other namespaces (of course, it didn't work fine, but at least there were no complains during the init).

Some summary about my IDE/project setup:

  • application launch performed by GWT .launch file (GWT ver 2.0.3)
  • within this launch file there're references to other projects, including serverside that has spring dependencies
  • in fact, this gwt-client project has serverside POM as parent, and as a result I see all of spring dependencies in this project's Maven Dependencies
  • GWT-client project has /war/WEB-INF/applicationContext.xml that imports other context XML resources, which are actually utilizing spring-tx

The formal question would be: what are the possible reasons why the project launch from IDE results with such errors after migrating to Spring 3x (and works fine deployed as built WAR)?

I don't expect straight answers (unless someone had exactly the same environment & problem), but guidelines, advices would be of great help!

EDIT Forgot to mention that during app startup from IDE, I have bunch of warnings like these:

[WARN] Server class 'javax.persistence.EntityManagerFactory' could not be found in the web app, but was found on the system classpath
   [WARN] Adding classpath entry 'file:/D:/maven/repository/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.0.Final/hibernate-jpa-2.0-api-1.0.0.Final.jar' to the web app classpath for this session
[WARN] Server class 'org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor' could not be found in the web app, but was found on the system classpath
   [WARN] Adding classpath entry 'file:/D:/maven/repository/org/springframework/spring-orm/3.0.5.RELEASE/spring-orm-3.0.5.RELEASE.jar' to the web app classpath for this session

.. so maybe spring-tx also is not found in web-app (and found on the system classpath), but it's not added like that happened with the others? What would be the reason of this behavior?

解决方案

If you have multiple spring dependencies on your classpath, then you may be running into this issue with maven:

When using mulitple Spring dependencies, the files from META-INF (from the Spring jars) overwrite each other in an executable jar-with-dependencies

To fix this, see the comment from Chris Wilkes. You need to copy the spring.handlers and spring.schemas into your META-INF directory.

这篇关于在迁移到Spring 3之后,从Eclipse IDE启动基于Maven的GWT App时,会发生Spring NamespaceHandler问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆