i intended to pack my action classes in jar file and utilize the convention plugin to initialize them. i did it following
this instruction.
the plugin didn't recognize my jar file. >_<
with the source code of convention plugin, i traced to
org.apache.struts2.convention.PackageBasedActionConfigBuilder
private UrlSet buildUrlSet() throws IOException {
ClassLoaderInterface classLoaderInterface = getClassLoaderInterface();
UrlSet urlSet = new UrlSet(classLoaderInterface, this.fileProtocols);
//...
//removed the rest of codes
}
i found my jar in the
classLoaderInterface but the
urlSet didn't recognize it. let's dig deeper. it's a class in xwork. the xwork 2.1.6 release is not updated on the official site.
here is the address.
com.opensymphony.xwork2.util.finder.UrlSet
private static List<URL> getUrls(ClassLoaderInterface classLoader) throws IOException {
List<URL> list = new ArrayList<URL>();
//find jars
ArrayList<URL> urls = Collections.list(classLoader.getResources("META-INF"));
//...
//removed the rest of codes
}
classLoader.getResources("META-INF") - this is how xwork finds jar files. spring does it with the same approach and luckily someone(Ingo Düppe) from their side gave us a heads-up on the
META-INF.
http://jira.springframework.org/browse/SPR-1670
引用
Please be careful with this approach. Not all jar files do have a META-INF directory entry even when files exists like META-INF/manifest.mf. For instance jars build with eclipse do not contain a META-INF directory entry so this approach will not find these jars.
thanks Ingo! you save my day.
turns out that my jar was built with eclipse export tool and had no directory entry of the META-INF folder. i packed it again with ant task then the plugin found it.
分享到:
相关推荐
struts2-convention-plugin-2.3.15.1.jar
struts2-convention-plugin-2.1.6.jar
struts2-convention-plugin-2.3.32
struts2-convention-plugin-2.1.8.jar
从struts2.1版本开始,Convention Plugin作为替换替换Codebehind Plugin来实现Struts2的零配置。 • 包命名习惯来指定Action位置 • 命名习惯制定结果(支持JSP,FreeMarker等)路径 • 类名到URL的约定转换 • 包名...
不论高低版本,要使用struts2-core这个jar包,当又需struts2-convention-plugin.jar时勿必要使两者版本一致哦,否则会有DefError、Unable to read class诸等错误
struts2-convention-plugin-2.3.24.1
struts2-convention-plugin-2.3.32.jar
struts2-convention-plugin-2.3.1.2.jar
struts2-convention-plugin-2.3.24.jar
2.5.10.1.jar,struts2-config-browser-plugin-2.5.10.1.jar,struts2-convention-plugin-2.5.10.1.jar,struts2-dwr-plugin-2.5.10.1.jar,struts2-embeddedjsp-plugin-2.5.10.1.jar,struts2-gxp-plugin-2.5.10.1....
struts2-convention-plugin-2.1.8.1.jar
struts2-convention-plugin-2.3.1.jar,使用注解的方式代替xml配置action,必须要引用这个包。
struts2-convention-plugin-2.3.4.1.jar
struts2-convention-plugin-2.3.15.3.jar struts2配置Action注解要用到的包,真正实现零配置
一:升级高版本的struts2.5.22 无法访问Action解决办法 1.最主要原始struts版本与freemarker-2.3.22版本不一致...2.具体原因就研究struts2-core-2.3.32.jar 与 freemarker-2.3.22.jar 关系依赖 更新如下8个jar即可。
java web开发中所用到的struts2所有相关jar包,版本struts-2.5
struts2 convention plugin(插件)测试项目
Struts2_Convention_Plugin中文文档