博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Maven Assembly plugin and Spring Namespace handlers
阅读量:4470 次
发布时间:2019-06-08

本文共 2636 字,大约阅读时间需要 8 分钟。

| 

Yesterday, I came accross a weird error when working with a Spring-enabled application. It was working fine within Eclipe but wouldn't run on the command line:

Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/p]

I knew that Spring classes were in the classpath, but I didn't know why they were not found, or rather why the association between the namespace and the handler was not established.

By looking at Spring's documentation, I found  that explained that you needed to implement the interface to map a namespace to a handler. I quickly found the handler that was not mapped: .

The class is instanciated by reflection which means I couldn't use Eclipse to find callers. Instead, I simply put a breakpoint on the init() method and ran the application. That way, I found that was instanciating the handler, and that the method was responsible for loading namespace-handler mappings.

The code is quite clear: it loads all the files named META-INF/spring.handlers. And here it is! There is more than one file named this way: there is one in spring-beans, one in spring-context, one in spring-aop, etc.

The issue is that, to make the application work outside Eclipse, we use the . It expands all the dependent JARs into the final JAR. This means it cannot put several files with the same name in the package and it has to choose one of the spring.handlers files.

As a workaround, I created my own spring.handlers with the content from all thespring.handlers files I could find in Spring packages. You could wonder how this works because this is only one more file to choose from, but it looks like that the local file is picked first and is not overriden by files from dependent packages!

Here is the file I created:

http\://www.springframework.org/schema/p=org.springframework.beans.factory.xml.SimplePropertyNamespaceHandlerhttp\://www.springframework.org/schema/util=org.springframework.beans.factory.xml.UtilNamespaceHandlerhttp\://www.springframework.org/schema/aop=org.springframework.aop.config.AopNamespaceHandlerhttp\://www.springframework.org/schema/context=org.springframework.context.config.ContextNamespaceHandlerhttp\://www.springframework.org/schema/jee=org.springframework.ejb.config.JeeNamespaceHandlerhttp\://www.springframework.org/schema/lang=org.springframework.scripting.config.LangNamespaceHandler

  

I found a few references to this issue:

[From] 

转载于:https://www.cnblogs.com/abnercai/p/3253644.html

你可能感兴趣的文章
解决IE6不支持position:fixed;的问题
查看>>
理解jquery的$.extend()、$.fn和$.fn.extend()的区别及用法
查看>>
make install fping
查看>>
面试笔试题
查看>>
#loj3051 [十二省联考2019] 皮配
查看>>
MySql可视化工具MySQL Workbench使用教程
查看>>
个人站立会议第二阶段07
查看>>
云时代架构阅读笔记五——Web应用安全
查看>>
IOS 单击手势和cell点击冲突
查看>>
学习_HTML5_day3
查看>>
计算机网络与应用第二次笔记
查看>>
Django之ORM查询
查看>>
学习python第七天
查看>>
Flask基础(07)-->正则自定义转换器
查看>>
网站架构模式(二)
查看>>
【数据结构】算法 LinkList (Add Two Numbers)
查看>>
Bugtags:移动时代首选 Bug 管理系统
查看>>
hibernate学习笔记之一 hibernate简介
查看>>
定时任务quartz
查看>>
Set集合和实现类
查看>>