OpenKM开发环境搭建
OpenKM,全称Open Source Document Management,是开源的在线文档管理系统,其具有文档上传下载、文档在线预览、用户管理等文档管理功能,但搭建其二次开发环境比较复杂,网上的资料也非常少,往往是只能编译成功,tomcat却启动失败,自己也是做了多次尝试,才搭建成功开发环境,在此记录搭建过程。
1. 开发环境
JDK: 1.6.0_10-rc
MyEclipse: 8.5
tomcat: 7.0.27
OpenKM: 6.2.5
Maven: 3.2.3
需要说明的是,tomcat是直接使用OpenKM 6.2.5绑定版中的tomcat,之所以如此,是因为之前使用自己的tomcat多次尝试没有成功,现在看来应该是配置的原因,以后再做研究。注意,tomcat的保存位置路径不要有空格,以免部署失败,将绑定tomcat中的OpenKM.war文件删除,其他文件保留。
其他软件按照正常方法安装和配置,网上有很多教程,这里不做介绍。
2. 搭建
2.1 OpenKM编译
将OpenKM 6.2.5的源码拷贝到任意位置,打开命令提示符面板,找到OpenKM6.2.5源码中pom.xml文件所在的位置,使用mvncompile命令开始编译源码,在编译之前,会在网上下载大量的依赖包,可能需要一定时间,若网上有人说出现失败的情况,我目前还没遇到,网上有解决出现下载失败的方法。在下载完成之后,即开始编译源码。
2.2 OpenKM打包
按理来说,这步实际上是不需要的,但是多次尝试之后发现,打包过程中将gwt的java源码编译成了javascript,是源码部署成功的重要一步。出现这种情况的原因是没有集成gwt开发环境,实际上,可以尝试先集成gwt开发环境,然后再部署,这种方法以后再研究。
打包的方法是在OpenKM源码文件夹中,使用mvn package命令,完成打包,这个过程大概需要几分钟的时间。
2.3 OpenKM生成myEclipse工程文件
再打包成功之后,使用mvn eclipse:eclipse命令,生成myEclipse工程文件。
2.4 OpenKM在myEclipse中配置
在myEclipse中使用import的ExistingProjects into Workspace方法将该工程导入工作空间。
导入完成之后,鼠标右键单击工程名,点击下拉菜单中的MyEclipse->Add Web Project Capabities添加web功能。
2.4 OpenKM在MyEclipse中启动
首先配置MyEclipse的tomcat,将第一步中的tomcat配置到MyEclipse中,然后在MyEclipse中部署和启动服务。其中,启动服务是出现如下错误:
java.lang.IllegalStateException: LifecycleProcessor notinitialized - call 'refresh' before invoking lifecycle methods via the context:Root WebApplicationContext: startup date [Thu Apr 21 14:45:26 CST 2016]; rootof context hierarchy
......
2016-04-21 14:45:33,784 [pool-2-thread-1] ERRORorg.springframework.web.context.ContextLoader - Context initialization failed
.......
Caused by: org.springframework.beans.factory.BeanCreationException:Error creating bean with name'org.springframework.security.web.DefaultSecurityFilterChain#0':
.......
Caused by:org.springframework.beans.factory.BeanCreationException: Error creating beanwith name '(inner bean)#20': Cannot resolve reference to bean'org.springframework.security.authentication.ProviderManager#0' while settingbean property 'authenticationManager';
.......
Caused by:org.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.authentication.ProviderManager#0':Cannot resolve reference to bean'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0'while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException:Error creating bean with name'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0':FactoryBean threw exception on object creation; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.authenticationManager': Cannot resolvereference to bean'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0'while setting constructor argument with key [0]; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0':Cannot resolve reference to bean 'org.springframework.security.provisioning.JdbcUserDetailsManager#0'while setting bean property 'userDetailsService'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0':Cannot resolve reference to bean 'dataSource' while setting bean property'dataSource'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'dataSource': Invocation of init method failed; nested exception isjavax.naming.NameNotFoundException: Name [jdbc/OpenKMDS] is not bound in thisContext. Unable to find [jdbc].
........
Caused by:org.springframework.beans.factory.BeanCreationException: Error creating beanwith name'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0':FactoryBean threw exception on object creation; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.authenticationManager': Cannot resolvereference to bean'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0'while setting constructor argument with key [0]; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0':Cannot resolve reference to bean'org.springframework.security.provisioning.JdbcUserDetailsManager#0' whilesetting bean property 'userDetailsService'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0':Cannot resolve reference to bean 'dataSource' while setting bean property'dataSource'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'dataSource': Invocation of init method failed; nested exception isjavax.naming.NameNotFoundException: Name [jdbc/OpenKMDS] is not bound in thisContext. Unable to find [jdbc].
.......
Caused by:org.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.authenticationManager': Cannot resolvereference to bean'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0'while setting constructor argument with key [0]; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0':Cannot resolve reference to bean'org.springframework.security.provisioning.JdbcUserDetailsManager#0' while settingbean property 'userDetailsService'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0':Cannot resolve reference to bean 'dataSource' while setting bean property'dataSource'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'dataSource': Invocation of init method failed; nested exception isjavax.naming.NameNotFoundException:Name [jdbc/OpenKMDS] is not bound in thisContext. Unable to find [jdbc].
........
Caused by: org.springframework.beans.factory.BeanCreationException:Error creating bean with name'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0':Cannot resolve reference to bean'org.springframework.security.provisioning.JdbcUserDetailsManager#0' whilesetting bean property 'userDetailsService'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0':Cannot resolve reference to bean 'dataSource' while setting bean property'dataSource'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'dataSource': Invocation of init method failed; nested exception isjavax.naming.NameNotFoundException:Name [jdbc/OpenKMDS] is not bound in thisContext. Unable to find [jdbc].
........
Caused by:org.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0':Cannot resolve reference to bean 'dataSource' while setting bean property'dataSource'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'dataSource': Invocation of init method failed; nested exception isjavax.naming.NameNotFoundException:Name [jdbc/OpenKMDS] is not bound in thisContext. Unable to find [jdbc].
......
Caused by: org.springframework.beans.factory.BeanCreationException:Error creating bean with name 'dataSource': Invocation of init method failed;nested exception is javax.naming.NameNotFoundException:Name [jdbc/OpenKMDS] isnot bound in this Context. Unable to find [jdbc].
......
Caused by: javax.naming.NameNotFoundException: Name[jdbc/OpenKMDS] is not bound in this Context. Unable to find [jdbc].
......
2016-04-21 14:45:33,806 [pool-2-thread-1] ERRORorg.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/openkm] -Exception sending context initialized event to listener instance of classorg.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException:Error creating bean with name 'org.springframework.security.filterChains':Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#0'while setting bean property 'sourceList' with key [0]; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.web.DefaultSecurityFilterChain#0':Cannot create inner bean '(inner bean)' of type[org.springframework.security.web.authentication.www.BasicAuthenticationFilter]while setting constructor argument with key [1]; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name '(inner bean)#20': Cannot resolve reference to bean'org.springframework.security.authentication.ProviderManager#0' while settingbean property 'authenticationManager'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.authentication.ProviderManager#0':Cannot resolve reference to bean'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0'while setting constructor argument; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0':FactoryBean threw exception on object creation; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.authenticationManager': Cannot resolvereference to bean 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0'while setting constructor argument with key [0]; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0': Cannotresolve reference to bean'org.springframework.security.provisioning.JdbcUserDetailsManager#0' whilesetting bean property 'userDetailsService'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0':Cannot resolve reference to bean 'dataSource' while setting bean property'dataSource'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'dataSource': Invocation of init method failed; nested exception isjavax.naming.NameNotFoundException:Name [jdbc/OpenKMDS] is not bound in thisContext. Unable to find [jdbc].
........
Caused by:org.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.web.DefaultSecurityFilterChain#0':Cannot create inner bean '(inner bean)' of type[org.springframework.security.web.authentication.www.BasicAuthenticationFilter]while setting constructor argument with key [1]; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name '(inner bean)#20': Cannot resolve reference to bean'org.springframework.security.authentication.ProviderManager#0' while settingbean property 'authenticationManager'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.authentication.ProviderManager#0':Cannot resolve reference to bean'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0'while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException:Error creating bean with name'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0':FactoryBean threw exception on object creation; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.authenticationManager': Cannot resolvereference to bean'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0'while setting constructor argument with key [0]; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0':Cannot resolve reference to bean 'org.springframework.security.provisioning.JdbcUserDetailsManager#0'while setting bean property 'userDetailsService'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0':Cannot resolve reference to bean 'dataSource' while setting bean property'dataSource'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'dataSource': Invocation of init method failed; nested exception isjavax.naming.NameNotFoundException:Name [jdbc/OpenKMDS] is not bound in thisContext. Unable to find [jdbc].
......
Caused by:org.springframework.beans.factory.BeanCreationException: Error creating beanwith name '(inner bean)#20': Cannot resolve reference to bean'org.springframework.security.authentication.ProviderManager#0' while settingbean property 'authenticationManager'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.authentication.ProviderManager#0':Cannot resolve reference to bean'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0'while setting constructor argument; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0':FactoryBean threw exception on object creation; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.authenticationManager': Cannot resolvereference to bean'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0'while setting constructor argument with key [0]; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0':Cannot resolve reference to bean 'org.springframework.security.provisioning.JdbcUserDetailsManager#0'while setting bean property 'userDetailsService'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0':Cannot resolve reference to bean 'dataSource' while setting bean property'dataSource'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'dataSource': Invocation of init method failed; nested exception isjavax.naming.NameNotFoundException:Name [jdbc/OpenKMDS] is not bound in thisContext. Unable to find [jdbc].
......
Caused by:org.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.authentication.ProviderManager#0':Cannot resolve reference to bean'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0'while setting constructor argument; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0':FactoryBean threw exception on object creation; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.authenticationManager': Cannot resolvereference to bean'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0'while setting constructor argument with key [0]; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0':Cannot resolve reference to bean'org.springframework.security.provisioning.JdbcUserDetailsManager#0' whilesetting bean property 'userDetailsService'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0':Cannot resolve reference to bean 'dataSource' while setting bean property'dataSource'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'dataSource': Invocation of init method failed; nested exception isjavax.naming.NameNotFoundException:Name [jdbc/OpenKMDS] is not bound in thisContext. Unable to find [jdbc].
........
Caused by: org.springframework.beans.factory.BeanCreationException:Error creating bean with name'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0':FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException:Error creating bean with name'org.springframework.security.authenticationManager': Cannot resolve referenceto bean'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0'while setting constructor argument with key [0]; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0':Cannot resolve reference to bean 'org.springframework.security.provisioning.JdbcUserDetailsManager#0'while setting bean property 'userDetailsService'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0':Cannot resolve reference to bean 'dataSource' while setting bean property'dataSource'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'dataSource': Invocation of init method failed; nested exception isjavax.naming.NameNotFoundException:Name [jdbc/OpenKMDS] is not bound in thisContext. Unable to find [jdbc].
........
Caused by:org.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.authenticationManager': Cannot resolvereference to bean'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0'while setting constructor argument with key [0]; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0':Cannot resolve reference to bean'org.springframework.security.provisioning.JdbcUserDetailsManager#0' whilesetting bean property 'userDetailsService'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0':Cannot resolve reference to bean 'dataSource' while setting bean property'dataSource'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'dataSource': Invocation of init method failed; nested exception isjavax.naming.NameNotFoundException:Name [jdbc/OpenKMDS] is not bound in thisContext. Unable to find [jdbc].
.......
Caused by:org.springframework.beans.factory.BeanCreationException: Error creating beanwith name'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0':Cannot resolve reference to bean 'org.springframework.security.provisioning.JdbcUserDetailsManager#0'while setting bean property 'userDetailsService'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0':Cannot resolve reference to bean 'dataSource' while setting bean property'dataSource'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'dataSource': Invocation of init method failed; nested exception isjavax.naming.NameNotFoundException:Name [jdbc/OpenKMDS] is not bound in thisContext. Unable to find [jdbc].
.......
Caused by:org.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0':Cannot resolve reference to bean 'dataSource' while setting bean property'dataSource'; nested exception isorg.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'dataSource': Invocation of init method failed; nested exception isjavax.naming.NameNotFoundException:Name [jdbc/OpenKMDS] is not bound in this Context.Unable to find [jdbc].
........
Caused by:org.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'dataSource': Invocation of init method failed; nested exception isjavax.naming.NameNotFoundException: Name [jdbc/OpenKMDS] is not bound in thisContext. Unable to find [jdbc].
.......
Caused by: javax.naming.NameNotFoundException: Name[jdbc/OpenKMDS] is not bound in this Context. Unable to find [jdbc].
.......
该错误的解决方法是打开Target中WEB-INF目录下的ApplicationContext.xml文件,找到下图中标记行,将其中jndi-name="jdbc/OpenKMDS"更改为jndi-name="jdbc/openkmDS",然后重新部署,即可启动成功。只所以这么改,是因为绑定的tomcat conf文件中的context.xml部署的数据源名称是openkmDS。
3. 说明
使用该方法搭建开发环境成功,但需要说明的是:
虽然开发环境可以搭建成功,但修改界面比较麻烦,主要原因就是OpenKM界面是基于gwt开发的,而我的MyEclipse又不具有该开发环境,因此,每次修改完界面后,需要使用mvn重新编译和打包该工程,最终实现界面的重新生成,所以,可以尝试将gwt开发环境集成到myEclipse中搭建该工程的开发环境。
可参考该博客:http://www.cnblogs.com/lixiaolong/archive/2013/03/24/2978448.html
4. 后续工作
(1) 集成gwt到MyEclipse中,通过直接添加该工程简化修改界面的过程;
(2) 尝试不使用绑定的tomcat部署服务。