GateIn默认安装的数据库是HSQL,在其白皮书上也介绍了如何配置MYSQL数据库。公司所使用的数据库是MS SQL Server 2005,看GateIn的介绍是支持其他数据库的,所以着手进行迁移。修改$GateIn_home\gatein\conf下面的configuration.properties文件,同时修改JCR和IDM的数据库配置信息。
# JCR gatein.jcr.config.type=local gatein.jcr.datasource.name=jdbcjcr_portal gatein.jcr.datasource.dialect=org.hibernate.dialect.SQLServerDialect gatein.jcr.datasource.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver gatein.jcr.datasource.url=jdbc:sqlserver://192.168.0.30:1433;DatabaseName=jdbcjcr_portal gatein.jcr.datasource.username=sa gatein.jcr.datasource.password=123456
# IDM gatein.idm.datasource.name=jdbcidm_portal gatein.idm.datasource.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver gatein.idm.datasource.url=jdbc:sqlserver://192.168.0.30:1433;DatabaseName=jdbcidm_portal gatein.idm.datasource.username=sa gatein.idm.datasource.password=123456
同时将MS SQL Server的JDBC连接jar包放到lib文件夹下面。启动Tomcat,console抛出错误信息。
2011-2-15 9:58:26 org.exoplatform.container.RootContainer createPortalContainer
严重: Cannot create the portal container 'portal' . ServletContext: org.apache.catalina.core.ApplicationContextFacade@1991de1
org.picocontainer.PicoIntrospectionException: Failed when calling start on org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl@11ed166
at org.picocontainer.defaults.LifecycleVisitor.traverse(LifecycleVisitor.java:81)
at org.picocontainer.defaults.LifecycleVisitor.start(LifecycleVisitor.java:113)
at org.exoplatform.container.ConcurrentPicoContainer.start(ConcurrentPicoContainer.java:453)
at org.exoplatform.container.ExoContainer.start(ExoContainer.java:186)
at org.exoplatform.container.PortalContainer.start(PortalContainer.java:595)
at org.exoplatform.container.ExoContainer.start(ExoContainer.java:180)
at org.exoplatform.container.RootContainer.createPortalContainer(RootContainer.java:338)
at org.exoplatform.container.RootContainer.registerPortalContainer(RootContainer.java:212)
at org.exoplatform.portal.application.PortalController.afterInit(PortalController.java:114)
at org.exoplatform.container.web.AbstractHttpServlet.init(AbstractHttpServlet.java:72)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4149)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4458)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:630)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:556)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:491)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.RuntimeException: org.exoplatform.services.jcr.config.RepositoryConfigurationException: Fail to init from xml! Reason: javax.jcr.RepositoryException: Database exception. com.microsoft.sqlserver.jdbc.SQLServerException: 第 2 个列、参数或变量: 找不到数据类型 BLOB。. SQL: CREATE TABLE JCR_CONFIG (NAME VARCHAR(64) NOT NULL, CONFIG BLOB NOT NULL, CONSTRAINT JCR_CONFIG_PK PRIMARY KEY(NAME)): Database exception. com.microsoft.sqlserver.jdbc.SQLServerException: 第 2 个列、参数或变量: 找不到数据类型 BLOB。. SQL: CREATE TABLE JCR_CONFIG (NAME VARCHAR(64) NOT NULL, CONFIG BLOB NOT NULL, CONSTRAINT JCR_CONFIG_PK PRIMARY KEY(NAME))
at org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl.start(RepositoryServiceConfigurationImpl.java:303)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.picocontainer.defaults.LifecycleVisitor.traverse(LifecycleVisitor.java:75)
... 35 more
Caused by: org.exoplatform.services.jcr.config.RepositoryConfigurationException: Fail to init from xml! Reason: javax.jcr.RepositoryException: Database exception. com.microsoft.sqlserver.jdbc.SQLServerException: 第 2 个列、参数或变量: 找不到数据类型 BLOB。. SQL: CREATE TABLE JCR_CONFIG (NAME VARCHAR(64) NOT NULL, CONFIG BLOB NOT NULL, CONSTRAINT JCR_CONFIG_PK PRIMARY KEY(NAME)): Database exception. com.microsoft.sqlserver.jdbc.SQLServerException: 第 2 个列、参数或变量: 找不到数据类型 BLOB。. SQL: CREATE TABLE JCR_CONFIG (NAME VARCHAR(64) NOT NULL, CONFIG BLOB NOT NULL, CONSTRAINT JCR_CONFIG_PK PRIMARY KEY(NAME))
... 41 more
Caused by: javax.jcr.RepositoryException: Database exception. com.microsoft.sqlserver.jdbc.SQLServerException: 第 2 个列、参数或变量: 找不到数据类型 BLOB。. SQL: CREATE TABLE JCR_CONFIG (NAME VARCHAR(64) NOT NULL, CONFIG BLOB NOT NULL, CONSTRAINT JCR_CONFIG_PK PRIMARY KEY(NAME)): Database exception. com.microsoft.sqlserver.jdbc.SQLServerException: 第 2 个列、参数或变量: 找不到数据类型 BLOB。. SQL: CREATE TABLE JCR_CONFIG (NAME VARCHAR(64) NOT NULL, CONFIG BLOB NOT NULL, CONSTRAINT JCR_CONFIG_PK PRIMARY KEY(NAME))
at org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl.retain(RepositoryServiceConfigurationImpl.java:207)
at org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl.start(RepositoryServiceConfigurationImpl.java:293)
... 40 more
Caused by: org.exoplatform.services.jcr.config.RepositoryConfigurationException: Database exception. com.microsoft.sqlserver.jdbc.SQLServerException: 第 2 个列、参数或变量: 找不到数据类型 BLOB。. SQL: CREATE TABLE JCR_CONFIG (NAME VARCHAR(64) NOT NULL, CONFIG BLOB NOT NULL, CONSTRAINT JCR_CONFIG_PK PRIMARY KEY(NAME))
at org.exoplatform.services.jcr.impl.config.JDBCConfigurationPersister.write(JDBCConfigurationPersister.java:384)
at org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl.retain(RepositoryServiceConfigurationImpl.java:189)
... 41 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: 第 2 个列、参数或变量: 找不到数据类型 BLOB。
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.sendExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteUpdate(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeUpdate(Unknown Source)
at org.apache.commons.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:225)
at org.exoplatform.services.jcr.impl.config.JDBCConfigurationPersister.write(JDBCConfigurationPersister.java:327)
... 42 more
Caused by:
java.lang.RuntimeException: org.exoplatform.services.jcr.config.RepositoryConfigurationException: Fail to init from xml! Reason: javax.jcr.RepositoryException: Database exception. com.microsoft.sqlserver.jdbc.SQLServerException: 第 2 个列、参数或变量: 找不到数据类型 BLOB。. SQL: CREATE TABLE JCR_CONFIG (NAME VARCHAR(64) NOT NULL, CONFIG BLOB NOT NULL, CONSTRAINT JCR_CONFIG_PK PRIMARY KEY(NAME)): Database exception. com.microsoft.sqlserver.jdbc.SQLServerException: 第 2 个列、参数或变量: 找不到数据类型 BLOB。. SQL: CREATE TABLE JCR_CONFIG (NAME VARCHAR(64) NOT NULL, CONFIG BLOB NOT NULL, CONSTRAINT JCR_CONFIG_PK PRIMARY KEY(NAME))
at org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl.start(RepositoryServiceConfigurationImpl.java:303)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.picocontainer.defaults.LifecycleVisitor.traverse(LifecycleVisitor.java:75)
at org.picocontainer.defaults.LifecycleVisitor.start(LifecycleVisitor.java:113)
at org.exoplatform.container.ConcurrentPicoContainer.start(ConcurrentPicoContainer.java:453)
at org.exoplatform.container.ExoContainer.start(ExoContainer.java:186)
at org.exoplatform.container.PortalContainer.start(PortalContainer.java:595)
at org.exoplatform.container.ExoContainer.start(ExoContainer.java:180)
at org.exoplatform.container.RootContainer.createPortalContainer(RootContainer.java:338)
at org.exoplatform.container.RootContainer.registerPortalContainer(RootContainer.java:212)
at org.exoplatform.portal.application.PortalController.afterInit(PortalController.java:114)
at org.exoplatform.container.web.AbstractHttpServlet.init(AbstractHttpServlet.java:72)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4149)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4458)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:630)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:556)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:491)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: org.exoplatform.services.jcr.config.RepositoryConfigurationException: Fail to init from xml! Reason: javax.jcr.RepositoryException: Database exception. com.microsoft.sqlserver.jdbc.SQLServerException: 第 2 个列、参数或变量: 找不到数据类型 BLOB。. SQL: CREATE TABLE JCR_CONFIG (NAME VARCHAR(64) NOT NULL, CONFIG BLOB NOT NULL, CONSTRAINT JCR_CONFIG_PK PRIMARY KEY(NAME)): Database exception. com.microsoft.sqlserver.jdbc.SQLServerException: 第 2 个列、参数或变量: 找不到数据类型 BLOB。. SQL: CREATE TABLE JCR_CONFIG (NAME VARCHAR(64) NOT NULL, CONFIG BLOB NOT NULL, CONSTRAINT JCR_CONFIG_PK PRIMARY KEY(NAME))
... 41 more
Caused by: javax.jcr.RepositoryException: Database exception. com.microsoft.sqlserver.jdbc.SQLServerException: 第 2 个列、参数或变量: 找不到数据类型 BLOB。. SQL: CREATE TABLE JCR_CONFIG (NAME VARCHAR(64) NOT NULL, CONFIG BLOB NOT NULL, CONSTRAINT JCR_CONFIG_PK PRIMARY KEY(NAME)): Database exception. com.microsoft.sqlserver.jdbc.SQLServerException: 第 2 个列、参数或变量: 找不到数据类型 BLOB。. SQL: CREATE TABLE JCR_CONFIG (NAME VARCHAR(64) NOT NULL, CONFIG BLOB NOT NULL, CONSTRAINT JCR_CONFIG_PK PRIMARY KEY(NAME))
at org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl.retain(RepositoryServiceConfigurationImpl.java:207)
at org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl.start(RepositoryServiceConfigurationImpl.java:293)
... 40 more
Caused by: org.exoplatform.services.jcr.config.RepositoryConfigurationException: Database exception. com.microsoft.sqlserver.jdbc.SQLServerException: 第 2 个列、参数或变量: 找不到数据类型 BLOB。. SQL: CREATE TABLE JCR_CONFIG (NAME VARCHAR(64) NOT NULL, CONFIG BLOB NOT NULL, CONSTRAINT JCR_CONFIG_PK PRIMARY KEY(NAME))
at org.exoplatform.services.jcr.impl.config.JDBCConfigurationPersister.write(JDBCConfigurationPersister.java:384)
at org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl.retain(RepositoryServiceConfigurationImpl.java:189)
... 41 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: 第 2 个列、参数或变量: 找不到数据类型 BLOB。
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.sendExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteUpdate(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeUpdate(Unknown Source)
at org.apache.commons.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:225)
at org.exoplatform.services.jcr.impl.config.JDBCConfigurationPersister.write(JDBCConfigurationPersister.java:327)
... 42 more
可以看出是因为在初始化数据库时创建表JCR_CONFIG是由于数据类型不支持导致的错误。MS SQL Server中是没有BLOB数据类型的,而是通过text等类型支持的。
那问题出现在哪里?经过仔细查找、对比HSQL对BLOB的支持,发现问题出现在gatein.jcr.datasource.dialect=org.hibernate.dialect.SQLServerDialect 这句上面。
这句标明jcr的dialect是SQLServerDialect。
可能是不支持的原因吧,所以在创建表的时候BLOB数据类型没有转换为MS SQL Server支持的类型,
因此在初始化的初始化的时候抛出了上诉异常。将gatein.jcr.datasource.dialect=auto。问题完美解决。