liferay文档库重新部署后无法下载问题

liferay的文档库的portlet用起来很方便,但是发现,当你把这个tomcat重新部署,或者把这个tomcat移植到其他机器上的时候,文档库里面以前上传上来的文档,虽然信息还在,但是无法下载了。

原因是,liferay文档库,默认的配置是把文档的数据存储到了你tomcat所在服务器的${user.home}/liferay下面的jackrabbit文件夹里面了,所以在重新部署tomcat 或者将tomcat移植到其他服务器上的时候,不能下载了。

解决办法:

    1。在portal.properties里面将resource.repositories.root=${user.home}/liferay的${user.home}修改成你的tomcat路径下。不要将这些信息存储到你的用户文件夹下。

   2。将文档的存储方式改变成以数据的形式存储到数据库中,我觉得这个方法更好一些。这个到${user.home}/liferay/jackrabbit下,修改repository.xml。

修改后的文件如下:

<?xml version="1.0"?>

<Repository>
 <!--<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
  <param name="path" value="${rep.home}/repository" />
 </FileSystem>-->

 <!--
 Database File System (Cluster Configuration)

 This is sample configuration for mysql persistence that can be used for
 clustering Jackrabbit. For other databases, change the connection,
 credentials, and schema settings.
 -->

     <FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
      <param name="driver" value="com.mysql.jdbc.Driver"/>
      <param name="url" value="jdbc:mysql://localhost/jcr" />
      <param name="user" value="root" />
      <param name="password" value="admin" />
      <param name="schema" value="mysql"/>
      <param name="schemaObjectPrefix" value="J_R_FS_"/>
     </FileSystem>

 <Security appName="Jackrabbit">
  <AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager" />
  <LoginModule class="org.apache.jackrabbit.core.security.SimpleLoginModule">
   <param name="anonymousId" value="anonymous" />
  </LoginModule>
 </Security>
 <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="liferay" />
 <Workspace name="${wsp.name}">
<!--  <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
   <param name="path" value="${wsp.home}" />
  </FileSystem>
  <PersistenceManager class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />
-->
  <!--
  Database File System and Persistence (Cluster Configuration)

  This is sample configuration for mysql persistence that can be used for
  clustering Jackrabbit. For other databases, change the  connection,
  credentials, and schema settings.
  -->

      <PersistenceManager class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager">
       <param name="driver" value="com.mysql.jdbc.Driver" />
       <param name="url" value="jdbc:mysql://localhost/jcr" />
       <param name="user" value="root" />
       <param name="password" value="admin" />
       <param name="schema" value="mysql" />
       <param name="schemaObjectPrefix" value="J_PM_${wsp.name}_" />
       <param name="externalBLOBs" value="false" />
      </PersistenceManager>
      <FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
       <param name="driver" value="com.mysql.jdbc.Driver"/>
       <param name="url" value="jdbc:mysql://localhost/jcr" />
       <param name="user" value="root" />
       <param name="password" value="admin" />
       <param name="schema" value="mysql"/>
       <param name="schemaObjectPrefix" value="J_FS_${wsp.name}_"/>
      </FileSystem>
 </Workspace>
 <Versioning rootPath="${rep.home}/version">
<!--  <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
   <param name="path" value="${rep.home}/version" />
  </FileSystem>

  <PersistenceManager class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />
-->
  <!--
  Database File System and Persistence (Cluster Configuration)

  This is sample configuration for mysql persistence that can be used for
  clustering Jackrabbit. For other databases, change the connection,
  credentials, and schema settings.
  -->

       <FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
        <param name="driver" value="com.mysql.jdbc.Driver"/>
        <param name="url" value="jdbc:mysql://localhost/jcr" />
        <param name="user" value="root" />
        <param name="password" value="admin" />
        <param name="schema" value="mysql"/>
        <param name="schemaObjectPrefix" value="J_V_FS_"/>
       </FileSystem>
       <PersistenceManager class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager">
        <param name="driver" value="com.mysql.jdbc.Driver" />
        <param name="url" value="jdbc:mysql://localhost/jcr" />
        <param name="user" value="root" />
        <param name="password" value="admin" />
        <param name="schema" value="mysql" />
        <param name="schemaObjectPrefix" value="J_V_PM_" />
        <param name="externalBLOBs" value="false" />
       </PersistenceManager>
 </Versioning>

 <!--
 Cluster Configuration

 This is sample configuration for mysql persistence that can be used for
 clustering Jackrabbit. For other databases, change the  connection,
 credentials, and schema settings.
 -->

    <!--<Cluster id="node_1" syncDelay="5">
  <Journal class="org.apache.jackrabbit.core.journal.DatabaseJournal">
   <param name="revision" value="${rep.home}/revision"/>
   <param name="driver" value="com.mysql.jdbc.Driver"/>
   <param name="url" value="jdbc:mysql://localhost/jcr"/>
   <param name="user" value=""/>
   <param name="password" value=""/>
   <param name="schema" value="mysql"/>
   <param name="schemaObjectPrefix" value="J_C_"/>
  </Journal>
    </Cluster>-->
</Repository>

注意:连接数据库时候的用户名和密码填写正确,还有数据库名,如果不想和tomcat用同一个数据库,那么就再另外建立一个jcr的数据库即可,里面的表会自动生成。

这样,不管tomcat怎么重新部署和移植,文档的数据是存储到数据库里面了,只要数据库文件还在,什么时候都能下载。

参考文档:http://wiki.liferay.com/index.php/Jackrabbit

 

 

补充:

     刚才一个网友告诉我可以在部署出来之前修改portal源码的相关配置,这样第一次部署tomcat生成的repository.xml就是存储到数据库的配置了。修改的源码是portal-impl.jar/com/liferay/portal/jcr/jackrabbit/dependencies/repository.xml  这个就是部署repository.xml之前的原文件。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值