[xwiki-devs] Export/Import batch mode

Thomas Mortagne thomas.mortagne at xwiki.com
Fri Jul 4 12:28:15 CEST 2008


Hi,

You should look at maven packager plugin
(trunks/xwiki-platform-tools/xwiki-packager-plugin) we use to build
initial XWiki hsqldb databse for distributed/installer packages. This
is based on XWiki on 1.3.1 but it should work axeactly the same way
with 1.4 branch and simpley use xwiki-core to import the XE xar for
example in a hsqldb database.

On Thu, Jul 3, 2008 at 6:49 PM, Amedeo <acannone at imolinfo.it> wrote:
>
> Hi,
> I'm able to make the export of a wiki via batch (I Invoke the class
> com.xpn.xwiki.tool.backup.ExporterMain), but I can't
> make the import in a new local wiki with the class
> com.xpn.xwiki.tool.backup.ImporterMain.
> I have the following kind of errors and my script doesn't terminate:
>
> 3-lug-2008 18.46.49 org.hibernate.event.def.DefaultLoadEventListener onLoad
> INFO: Error performing load command
> org.hibernate.ObjectNotFoundException: No row with the given identifier
> exists: [com.xpn.xwiki.doc.XWikiDocument#-1175017567]
>        at
> org.hibernate.impl.SessionFactoryImpl$1.handleEntityNotFound(SessionFactoryImpl.java:377)
>        at
> org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:145)
>        at
> org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
>        at
> org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
>        at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
>        at org.hibernate.impl.SessionImpl.load(SessionImpl.java:784)
>        at
> com.xpn.xwiki.store.XWikiHibernateStore.loadXWikiDoc(XWikiHibernateStore.java:616)
>        at
> com.xpn.xwiki.store.XWikiCacheStore.loadXWikiDoc(XWikiCacheStore.java:158)
>        at com.xpn.xwiki.XWiki.getDocument(XWiki.java:1182)
>        at com.xpn.xwiki.XWiki.getDocument(XWiki.java:1224)
>        at com.xpn.xwiki.XWiki.getWebPreference(XWiki.java:1882)
>        at com.xpn.xwiki.XWiki.getWebPreference(XWiki.java:1874)
>        at com.xpn.xwiki.XWiki.getWebPreference(XWiki.java:1868)
>        at com.xpn.xwiki.XWiki.getUserPreference(XWiki.java:1914)
>        at com.xpn.xwiki.XWiki.getEditorPreference(XWiki.java:5564)
>        at
> com.xpn.xwiki.render.XWikiRadeoxRenderEngine.appendCreateLink(XWikiRadeoxRenderEngine.java:309)
>        at
> com.xpn.xwiki.render.filter.XWikiLinkFilter.handleMatch(XWikiLinkFilter.java:215)
>        at
> org.radeox.filter.regex.RegexTokenFilter$1.handleMatch(RegexTokenFilter.java:91)
>        at org.radeox.regex.JdkMatcher.substitute(JdkMatcher.java:48)
>        at
> org.radeox.filter.regex.RegexTokenFilter.filter(RegexTokenFilter.java:89)
>        at org.radeox.filter.FilterPipe.filter(FilterPipe.java:169)
>        at
> com.xpn.xwiki.render.XWikiRadeoxRenderEngine.render(XWikiRadeoxRenderEngine.java:92)
>        at
> com.xpn.xwiki.render.XWikiRadeoxRenderer.render(XWikiRadeoxRenderer.java:118)
>        at
> com.xpn.xwiki.store.XWikiHibernateStore.saveLinks(XWikiHibernateStore.java:1856)
>        at
> com.xpn.xwiki.store.XWikiHibernateStore.saveXWikiDoc(XWikiHibernateStore.java:559)
>        at
> com.xpn.xwiki.store.XWikiCacheStore.saveXWikiDoc(XWikiCacheStore.java:97)
>        at
> com.xpn.xwiki.store.XWikiCacheStore.saveXWikiDoc(XWikiCacheStore.java:91)
>        at com.xpn.xwiki.XWiki.saveDocument(XWiki.java:1131)
>        at com.xpn.xwiki.XWiki.saveDocument(XWiki.java:1099)
>        at com.xpn.xwiki.XWiki.saveDocument(XWiki.java:1093)
>        at com.xpn.xwiki.plugin.packaging.Package.installDocument(Package.java:612)
>        at com.xpn.xwiki.plugin.packaging.Package.install(Package.java:545)
>        at com.xpn.xwiki.tool.backup.Importer.importDocuments(Importer.java:77)
>        at com.xpn.xwiki.tool.backup.ImporterMain.main(ImporterMain.java:56)
>
>
>
> I call a script that contains something like
> this:
>  java -classpath $XWIKICLASSPATH com.xpn.xwiki.tool.backup.ImporterMain
> /home/acannone/xwiki/prova/export xwiki
> /home/acannone/xwiki/prova/myxwiki/hibernate.cfg.xml
>
>
> Any ideas or suggestions?
>
>
>
> Thomas Mortagne wrote:
>>
>> On Wed, Jul 2, 2008 at 5:55 PM, Amedeo <acannone at imolinfo.it> wrote:
>>>
>>> Since the problem is caused by version 1.5M2 of XWiki cache service that
>>> is a
>>> plexus component, is possible to checkout a previous revision of XWiki
>>> sources?
>>> In other words, there is a tag for checking out a previous revision of
>>> all
>>> the modules configured in the svn:externals definition of
>>> http://svn.xwiki.org/svnroot/xwiki/trunks?
>>
>> You can find the 1.4 branch version of xwiki-core at
>> http://svn.xwiki.org/svnroot/xwiki/xwiki-platform/core/branches/xwiki-core-1.4/
>>
>>>
>>>
>>>
>>> Amedeo wrote:
>>>>
>>>> I follow your suggestion but now I have this error:
>>>>
>>>> Exception in thread "main" java.lang.NoClassDefFoundError:
>>>> org/codehaus/plexus/ContainerConfiguration
>>>> Caused by: java.lang.ClassNotFoundException:
>>>> org.codehaus.plexus.ContainerConfiguration
>>>>         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>>>>         at java.security.AccessController.doPrivileged(Native Method)
>>>>         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>>>         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>>>>         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
>>>>         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>>>>         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
>>>>
>>>> Do you know where is the class ContainerConfiguration?
>>>> I search in the maven repository and in the xwiki sources but I'm not
>>>> able
>>>> to find it.
>>>>
>>>>
>>>>
>>>> Thomas Mortagne wrote:
>>>>>
>>>>> On Mon, Jun 30, 2008 at 8:59 PM,  <acannone at imolinfo.it> wrote:
>>>>>> Invoking directly the class  com.xpn.xwiki.tool.backup.ExporterMain I
>>>>>> have the following Exception:
>>>>>>
>>>>>> Exception in thread "main" java.lang.RuntimeException: Component
>>>>>> manager
>>>>>> has not been initialized before lookup for
>>>>>> [org.xwiki.cache.CacheFactory] for hint [default]
>>>>>>        at com.xpn.xwiki.web.Utils.getComponent(Utils.java:553)
>>>>>>        at com.xpn.xwiki.XWiki.getCacheFactory(XWiki.java:5130)
>>>>>>        at
>>>>>> com.xpn.xwiki.store.XWikiCacheStore.initCache(XWikiCacheStore.java:86)
>>>>>>        at
>>>>>> com.xpn.xwiki.store.XWikiCacheStore.initCache(XWikiCacheStore.java:80)
>>>>>>        at
>>>>>> com.xpn.xwiki.store.XWikiCacheStore.<init>(XWikiCacheStore.java:62)
>>>>>>        at com.xpn.xwiki.XWiki.initXWiki(XWiki.java:675)
>>>>>>        at com.xpn.xwiki.XWiki.<init>(XWiki.java:618)
>>>>>>        at com.xpn.xwiki.XWiki.<init>(XWiki.java:612)
>>>>>>        at
>>>>>> com.xpn.xwiki.tool.backup.AbstractPackager.createXWikiContext(AbstractPackager.java:73)
>>>>>>        at
>>>>>> com.xpn.xwiki.tool.backup.Exporter.exportDocuments(Exporter.java:53)
>>>>>>        at
>>>>>> com.xpn.xwiki.tool.backup.ExporterMain.main(ExporterMain.java:57)
>>>>>
>>>>> This error is because you are trying to use XWiki Platform without
>>>>> initializing it. This particular error is about plexuw component
>>>>> manager needed because since versio 1.5M2 XWiki cache service is a
>>>>> plexus component. You should look at shared-test
>>>>> (trunks//xwiki-platform-tools/xwiki-shared-tests/src/main/java/com/xpn/xwiki/test/AbstractXWikiComponentTestCase.java)
>>>>> project for a way to create and initialize one you will need the
>>>>> plexus.xml also in shared-tests. You could directly extends
>>>>> AbstractXWikiComponentTestCase like unit tests do but it's... for unit
>>>>> tests and extends junit, jmock etc.
>>>>>
>>>>>>
>>>>>> Any ideas or suggestions?
>>>>>>
>>>>>> I have the previous error calling a script that contains something
>>>>>> like
>>>>>> this:
>>>>>> java -classpath $XWIKICLASSPATH com.xpn.xwiki.tool.backup.ExporterMain
>>>>>> /home/acannone/xwiki/prova/export xwiki
>>>>>> /home/acannone/xwiki/prova/hibernate.cfg.xml
>>>>>>
>>>>>> There is someone that can tell me how to invoke and configure the
>>>>>> maven
>>>>>> packager plugin in my example?
>>>>>>
>>>>>>
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>>
>>>>>> Thomas Mortagne wrote:
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I doubt there is any java level documentation on import/export but
>>>>>>> you
>>>>>>> can look at some good examples of how to use packager plugin :
>>>>>>>  - com.xpn.xwiki.web.ExportAction#exportXAR(XWikiContext)
>>>>>>>  - com.xpn.xwiki.web.ImportAction#render(XWikiContext)
>>>>>>>
>>>>>>> On Mon, May 5, 2008 at 3:19 PM, Lorenzo Manzoni
>>>>>>> <lmanzoni at imolinfo.it>
>>>>>>> wrote:
>>>>>>>> I would like to execute an export of all/some of the wiki pages in a
>>>>>>>>  batch mode (ex. with a script and a java program).
>>>>>>>>  In the same way I would like to execute an import.
>>>>>>>>  Is there an easy way to do this?
>>>>>>>>
>>>>>>>>  Looking forward in the xwiki sources I found two classes that seem
>>>>>>>> to
>>>>>>>> do
>>>>>>>>  what I want:
>>>>>>>>
>>>>>>>>     * com.xpn.xwiki.tool.backup.ExporterMain
>>>>>>>>     * com.xpn.xwiki.tool.backup.ImporterMain
>>>>>>>>
>>>>>>>>  Both classes are in the maven plugin called xwiki-packager-plugin.
>>>>>>>>  Is there any documentation that explain how use that plugin?
>>>>>>>>
>>>>>>>>
>>>>>>>>  thanks,
>>>>>>>>  Lorenzo
>>>>>>>>  _______________________________________________
>>>>>>>>  devs mailing list
>>>>>>>>  devs at xwiki.org
>>>>>>>>  http://lists.xwiki.org/mailman/listinfo/devs
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Thomas Mortagne
>>>>>>> _______________________________________________
>>>>>>> devs mailing list
>>>>>>> devs at xwiki.org
>>>>>>> http://lists.xwiki.org/mailman/listinfo/devs
>>>>>>>
>>>>>>>
>>>>>> Quoted from:
>>>>>> http://www.nabble.com/Export-Import-batch-mode-tp17061634p17062120.html
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Thomas Mortagne
>>>>> _______________________________________________
>>>>> devs mailing list
>>>>> devs at xwiki.org
>>>>> http://lists.xwiki.org/mailman/listinfo/devs
>>>>>
>>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Re%3A-Export-Import-batch-mode-tp18210860p18240863.html
>>> Sent from the XWiki- Dev mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> devs mailing list
>>> devs at xwiki.org
>>> http://lists.xwiki.org/mailman/listinfo/devs
>>>
>>
>>
>>
>> --
>> Thomas Mortagne
>> _______________________________________________
>> devs mailing list
>> devs at xwiki.org
>> http://lists.xwiki.org/mailman/listinfo/devs
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Re%3A-Export-Import-batch-mode-tp18210860p18263720.html
> Sent from the XWiki- Dev mailing list archive at Nabble.com.
>
> _______________________________________________
> devs mailing list
> devs at xwiki.org
> http://lists.xwiki.org/mailman/listinfo/devs
>



-- 
Thomas Mortagne


More information about the devs mailing list