【備忘録】eXist on Vagrant

# 実行環境

* OS : [CentOS64(centos64) http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130427.box](http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130427.box) on Vagrant 

# Vagrant　プライベートIP付与

1.Vagrantfileの下記のコメントを削除する。

```rb:Vagrantfile
config.vm.network :private_network, ip: "192.168.33.11"
```

2.vagrant をリロードする。

```bash:console(Mac)
$ vagrant reload
```

# eXist インストール

## JDK 1.7　インストール

* [jdk-7u67-linux-x64.rpm](http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html#jdk-7u67-oth-JPR)

```bash:console(Vagrant)
$ sudo rpm -ivh [jdk-7u67-linux-x64.rpm](http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html#jdk-7u67-oth-JPR)
$ java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
```
## eXist　本体　インストール

```bash:console(Vagrant)
$ sudo java -jar eXist-db-setup-2.1-rev18721.jar 
Select target path [/vagrant] 
/usr/local/lib/exist
press 1 to continue, 2 to quit, 3 to redisplay
1
Set Data Directory
Please select a directory where eXist-db will keep its data files. On Windows, this should be outside the 'Program Files' directory. Please make sure eXist can write to the directory it is installed in.
Data dir:  [webapp/WEB-INF/data] 
[Enter]
press 1 to continue, 2 to quit, 3 to redisplay
1
Set Admin Password and Configure Memory
Enter password:  [] 
secret
Enter password:  [secret（いつものパスワード）] 
secret

Maximum memory in mb: [1024] 
[Enter]
Cache memory in mb: [128] 
[Enter]
press 1 to continue, 2 to quit, 3 to redisplay
1
[ Starting to unpack ]
Starting process Setting admin password ... (1/1)
--- Starting embedded database instance ---
8 20, 2014 2:23:02 午前 org.expath.pkg.repo.util.Logger info
情報: Create a new repository with storage: File system storage in /usr/local/lib/webapp/WEB-INF/data/expathrepo
Setting admin user password...
--- Initialization complete. Shutdown embedded database instance ---
[ Console installation done ]
$ 
```

- データディレクトリへのパスは/usr/local/lib/exist/webapp/WEB-INF/data/fs/db（DBルート）となる。

# 起動・終了

## 手動起動

```bash:console(Vagrant)
$ sudo /usr/local/lib/exist/bin/startup.sh
26 2 2015 08:23:57,497 [main] INFO  (JettyStart.java [run]:117) - Configuring eXist from /usr/local/lib/exist/conf.xml 
26 2 2015 08:23:57,514 [main] INFO  (JettyStart.java [run]:119) - Running with Java 1.7.0_67 [Oracle Corporation (Java HotSpot(TM) 64-Bit Server VM) in /usr/java/jdk1.7.0_67/jre] 
26 2 2015 08:23:57,515 [main] INFO  (JettyStart.java [run]:125) - Running as user 'root' 
26 2 2015 08:23:57,583 [main] INFO  (JettyStart.java [run]:128) - [eXist Version : 2.1] 
26 2 2015 08:23:57,583 [main] INFO  (JettyStart.java [run]:130) - [eXist Build : 20130717] 
26 2 2015 08:23:57,584 [main] INFO  (JettyStart.java [run]:132) - [eXist Home : unknown] 
26 2 2015 08:23:57,584 [main] INFO  (JettyStart.java [run]:134) - [SVN Revision : 18721] 
26 2 2015 08:23:57,584 [main] INFO  (JettyStart.java [run]:137) - [Operating System : Linux 2.6.32-504.1.3.el6.x86_64 amd64] 
26 2 2015 08:23:57,584 [main] INFO  (JettyStart.java [run]:142) - [jetty.home : /usr/local/lib/exist/tools/jetty] 
26 2 2015 08:23:57,584 [main] INFO  (JettyStart.java [run]:144) - [log4j.configuration : file:/usr/local/lib/exist/log4j.xml] 
2 26, 2015 8:24:00 午前 org.expath.pkg.repo.util.Logger info
情報: Create a new repository with storage: File system storage in /usr/local/lib/exist/webapp/WEB-INF/data/expathrepo
26 2 2015 08:24:02,984 [main] INFO  (JettyStart.java [lifeCycleStarting]:404) - Jetty server starting... 
26 2 2015 08:24:02,995 [main] INFO  (Server.java [doStart]:270) - jetty-8.1.9.v20130131 
Logging already initialized. Skipping...
26 2 2015 08:24:06,217 [main] INFO  (NCSARequestLog.java [doStart]:649) - Opened /usr/local/lib/exist/tools/jetty/logs/2015_02_26.request.log 
26 2 2015 08:24:06,226 [main] INFO  (ScanningAppProvider.java [doStart]:113) - Deployment monitor /usr/local/lib/exist/tools/jetty/contexts at interval 10 
26 2 2015 08:24:06,230 [main] INFO  (ScanningAppProvider.java [doStart]:113) - Deployment monitor /usr/local/lib/exist/tools/jetty/webapps at interval 10 
26 2 2015 08:24:06,235 [main] INFO  (DeploymentManager.java [addApp]:132) - Deployable added: /usr/local/lib/exist/tools/jetty/webapps/portal 
26 2 2015 08:24:06,362 [main] WARN  (AbstractLifeCycle.java [setFailed]:204) - FAILED o.e.j.w.WebAppContext{/portal,file:/usr/local/lib/exist/tools/jetty/webapps/portal/},/usr/local/lib/exist/tools/jetty/webapps/portal: java.lang.IncompatibleClassChangeError: Implementing class 
java.lang.IncompatibleClassChangeError: Implementing class
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at org.eclipse.jetty.annotations.AnnotationConfiguration.createAnnotationParser(AnnotationConfiguration.java:154)
	at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:105)
	at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:466)
	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1245)
	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:710)
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:39)
	at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
	at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:494)
	at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:141)
	at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:145)
	at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:56)
	at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:609)
	at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:540)
	at org.eclipse.jetty.util.Scanner.scan(Scanner.java:403)
	at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:337)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:121)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:555)
	at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:230)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.eclipse.jetty.util.component.AggregateLifeCycle.doStart(AggregateLifeCycle.java:81)
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:58)
	at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:96)
	at org.eclipse.jetty.server.Server.doStart(Server.java:280)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.exist.jetty.JettyStart.run(JettyStart.java:187)
	at org.exist.jetty.JettyStart.main(JettyStart.java:71)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.exist.start.Main.invokeMain(Main.java:126)
	at org.exist.start.Main.run(Main.java:448)
	at org.exist.start.Main.main(Main.java:50)
26 2 2015 08:24:06,384 [main] WARN  (DeploymentManager.java [requestAppGoal]:501) - Unable to reach node goal: started 
java.lang.IncompatibleClassChangeError: Implementing class
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at org.eclipse.jetty.annotations.AnnotationConfiguration.createAnnotationParser(AnnotationConfiguration.java:154)
	at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:105)
	at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:466)
	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1245)
	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:710)
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:39)
	at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
	at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:494)
	at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:141)
	at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:145)
	at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:56)
	at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:609)
	at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:540)
	at org.eclipse.jetty.util.Scanner.scan(Scanner.java:403)
	at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:337)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:121)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:555)
	at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:230)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.eclipse.jetty.util.component.AggregateLifeCycle.doStart(AggregateLifeCycle.java:81)
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:58)
	at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:96)
	at org.eclipse.jetty.server.Server.doStart(Server.java:280)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.exist.jetty.JettyStart.run(JettyStart.java:187)
	at org.exist.jetty.JettyStart.main(JettyStart.java:71)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.exist.start.Main.invokeMain(Main.java:126)
	at org.exist.start.Main.run(Main.java:448)
	at org.exist.start.Main.main(Main.java:50)
26 2 2015 08:24:06,390 [main] INFO  (DeploymentManager.java [addApp]:132) - Deployable added: /usr/local/lib/exist/tools/jetty/webapps/homepage 
26 2 2015 08:24:06,449 [main] WARN  (AbstractLifeCycle.java [setFailed]:204) - FAILED o.e.j.w.WebAppContext{/homepage,file:/usr/local/lib/exist/tools/jetty/webapps/homepage/},/usr/local/lib/exist/tools/jetty/webapps/homepage: java.lang.IncompatibleClassChangeError: Implementing class 
java.lang.IncompatibleClassChangeError: Implementing class
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at org.eclipse.jetty.annotations.AnnotationConfiguration.createAnnotationParser(AnnotationConfiguration.java:154)
	at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:105)
	at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:466)
	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1245)
	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:710)
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:39)
	at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
	at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:494)
	at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:141)
	at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:145)
	at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:56)
	at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:609)
	at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:540)
	at org.eclipse.jetty.util.Scanner.scan(Scanner.java:403)
	at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:337)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:121)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:555)
	at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:230)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.eclipse.jetty.util.component.AggregateLifeCycle.doStart(AggregateLifeCycle.java:81)
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:58)
	at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:96)
	at org.eclipse.jetty.server.Server.doStart(Server.java:280)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.exist.jetty.JettyStart.run(JettyStart.java:187)
	at org.exist.jetty.JettyStart.main(JettyStart.java:71)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.exist.start.Main.invokeMain(Main.java:126)
	at org.exist.start.Main.run(Main.java:448)
	at org.exist.start.Main.main(Main.java:50)
26 2 2015 08:24:06,455 [main] WARN  (DeploymentManager.java [requestAppGoal]:501) - Unable to reach node goal: started 
java.lang.IncompatibleClassChangeError: Implementing class
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at org.eclipse.jetty.annotations.AnnotationConfiguration.createAnnotationParser(AnnotationConfiguration.java:154)
	at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:105)
	at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:466)
	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1245)
	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:710)
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:39)
	at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
	at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:494)
	at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:141)
	at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:145)
	at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:56)
	at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:609)
	at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:540)
	at org.eclipse.jetty.util.Scanner.scan(Scanner.java:403)
	at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:337)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:121)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:555)
	at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:230)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.eclipse.jetty.util.component.AggregateLifeCycle.doStart(AggregateLifeCycle.java:81)
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:58)
	at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:96)
	at org.eclipse.jetty.server.Server.doStart(Server.java:280)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
	at org.exist.jetty.JettyStart.run(JettyStart.java:187)
	at org.exist.jetty.JettyStart.main(JettyStart.java:71)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.exist.start.Main.invokeMain(Main.java:126)
	at org.exist.start.Main.run(Main.java:448)
	at org.exist.start.Main.main(Main.java:50)
26 2 2015 08:24:06,489 [main] INFO  (AbstractConnector.java [doStart]:338) - Started SelectChannelConnector@0.0.0.0:8080 
26 2 2015 08:24:06,893 [main] INFO  (SslContextFactory.java [doStart]:300) - Enabled Protocols [SSLv2Hello, SSLv3, TLSv1, TLSv1.1, TLSv1.2] of [SSLv2Hello, SSLv3, TLSv1, TLSv1.1, TLSv1.2] 
26 2 2015 08:24:06,898 [main] INFO  (AbstractConnector.java [doStart]:338) - Started SslSelectChannelConnector@0.0.0.0:8443 
26 2 2015 08:24:06,898 [main] INFO  (JettyStart.java [lifeCycleStarted]:410) - Jetty server started. 
26 2 2015 08:24:06,899 [main] INFO  (JettyStart.java [run]:224) - ----------------------------------------------------- 
26 2 2015 08:24:06,900 [main] INFO  (JettyStart.java [run]:225) - Server has started on ports 8080 8443. Configured contexts: 
26 2 2015 08:24:06,900 [main] INFO  (JettyStart.java [run]:234) - '/exist' 
26 2 2015 08:24:06,900 [main] INFO  (JettyStart.java [run]:272) - ----------------------------------------------------- 


```
* インストールを確認する。：[http://192.168.33.11:8080/exist/](http://192.168.33.11:8080/exist/)

## 自動起動（サービス登録）

* 手動起動すると、Ctrl+Cでストップしてしまうので、サービスとして実行する。
* [Advanced Installation Methods](http://exist-db.org/exist/apps/doc/advanced-installation.xml#linux)を参考に設定する。

### デーモンの登録

1.デーモンを登録する。

```bash:console(Vagrant)
$ sudo /usr/local/lib/exist/tools/wrapper/bin/exist.sh install
Detected RHEL or Fedora:
Installing the eXist-db Native XML Database daemon..
```

2.下記で再起動し、[eXist-db Dashboard](http://192.168.33.11:8080/exist/)に接続する。

```bash:console(Vagrant)
$ sudo reboot 
```
3.chkconfigの一覧も確認する。

```bash:console(Vagrant)
$ sudo chkconfig eXist-db on
$ sudo chkconfig --list
  :
eXist-db       	0:off	1:off	2:on	3:on	4:on	5:on	6:off
  :
```
###alternative設定

* 下記でサービスの起動・停止ができるようになる。

```bash:console(Vagrant)
$ sudo ln -s /usr/local/lib/exist/tools/wrapper/bin/exist.sh /etc/init.d/exist
$ sudo /etc/init.d/eXist-db start #サービス開始
$ sudo /etc/init.d/eXist-db stop #サービス終了
$ sudo service eXist-db start #サービス開始
$ sudo service eXist-db stop   #サービス終了
```
-----
# バックアップ・リストア

## コマンドベース

1.バックアップ

```lang:vagrant_terminal
[vagrant@localhost ~]$ cd /usr/local/lib/exist/bin
[vagrant@localhost bin]$ sudo bash backup.sh -d ./backup -u admin -p secret -b /db 
```

-d = ディレクトリ
-u = ユーザー
-p = パスワード
-b = DB内容

2.リストア

```lang:vagrant_terminal
[vagrant@localhost ~]$ cd /usr/local/lib/exist/bin
[vagrant@localhost bin]$ sudo bash backup.sh -r backup/db/__contents__.xml -u admin -p secret
```

## Java Admin Client

-----

# 【Perl-CGI】XML-RPCでeXistを操作する

## HTTPD(Apache)の設定

1.インストール

```bash:console(Vagrant)
$ sudo yum -y install httpd
```

2.サービス開始（手動）

```bash:console(Vagrant)
$ sudo service httpd start
```

3.自動起動設定

```bash:console(Vagrant)
$ sudo chkconfig httpd on
```
# eXist コレクションにXMLを新規保存する。

## XML-RPC (Perl) 

※Perlを利用する場合のみ、設定する。

* Perl(CGI)からXMLDBにアクセスできるようにするために、XML-RPCをインストールする。

1.[HTTPD : CGIを実行できるように変更する。](http://www.server-world.info/query?os=CentOS_6&p=httpd&f=26)

2.RPC::XMLをCPAN経由でインストールする。

```bash:console(Vagrant)
$ sudo yum install expat-devel
$ sudo yum -y install cpan
```

3.CPANを実行し、RPC::XMLをインストールする。

```bash:console(Vagrant)
$ sudo perl -MCPAN -e shell
cpan[1]> install XML::Parser
cpan[2]> install RPC::XML
cpan[3]> quit
```

4.サンプル：XML-RPCでXMLをアップロードする。

```pl:test.pl
#!/usr/bin/perl

use utf8;
use strict;
use warnings;

use RPC::XML;
use RPC::XML::Client;

my $url = "http://admin:passwd\@localhost:8080/exist/xmlrpc";
print "connecting to $url...\n";

my $client = RPC::XML::Client->new($url);

#登録するXMLを作成
my $xml = << "XML_DOC";
<?xml version="1.0" encoding="UTF-8"?>
<doc>
    <title>日本語タイトル</title>
    <details>日本語詳細</details>
</doc>
XML_DOC

#utf8エンコード実行
utf8::encode($xml);

#XMLドキュメントはRPC::XML::base64->new()でラップする
#/[コレクション名]/[ドキュメント名]で保存先を指定する
#最後の1は、上書きOK指定
my $req = RPC::XML::request->new("parse", RPC::XML::base64->new($xml), "/sample/test.xml", 1);
my $response = $client->send_request($req);
if($response->is_fault) {
    die "An error occurred: " . $response->string . "\n";
}

print $response->value, "\n";

```

```bash:console(Vagrant)
$ sudo chmod 705 test.pl
$ perl test.pl
connecting to http://admin:passwd@localhost:8080/exist/xmlrpc...
1 OK!
```

# 参考文献

## XPath 関連

## XQuery（DB問合せ言語） 関連
* [w3schools.com:XQuery Tutorial](http://www.w3schools.com/xquery/default.asp)
* [FunctX XQuery Functions（英語）](http://www.xqueryfunctions.com/xq/) ...ファンクションについては最もわかりやすい

### サンプル：ドキュメントの新規作成

```lang:db/sample/save-new.xq
xquery version "3.0" encoding "UTF-8";

(:追加先：コレクション:)
let $collection := 'xmldb:exist:///db/sample'
(:追加先：ファイル名:)
let $file-name := 'save-new.xml'

(:追加：XML:)
let $my-doc := 
<data>
   <id>123</id>
   <message>Hello World!!</message>
</data>

(:追加先：保存を実行する:)
let $store-return-status := 
    xmldb:store($collection, $file-name, $my-doc)
return
    <message>
        New Document Created {$store-return-status} at {$collection}/{$file-name}
    </message>

```

# 結果
```lang:/db/sample/save-new.xml
<data>
    <id>123</id>
    <message>Hello World!!</message>
</data>
```

## XForms関連

# 前提条件
* コレクションを作成する：/db/sample