You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

webapp.apt 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. ------
  2. Installing Apache Archiva as a Web Application
  3. ------
  4. Olivier Lamy
  5. ------
  6. 2011-09-29
  7. ------
  8. ~~ Licensed to the Apache Software Foundation (ASF) under one
  9. ~~ or more contributor license agreements. See the NOTICE file
  10. ~~ distributed with this work for additional information
  11. ~~ regarding copyright ownership. The ASF licenses this file
  12. ~~ to you under the Apache License, Version 2.0 (the
  13. ~~ "License"); you may not use this file except in compliance
  14. ~~ with the License. You may obtain a copy of the License at
  15. ~~
  16. ~~ http://www.apache.org/licenses/LICENSE-2.0
  17. ~~
  18. ~~ Unless required by applicable law or agreed to in writing,
  19. ~~ software distributed under the License is distributed on an
  20. ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  21. ~~ KIND, either express or implied. See the License for the
  22. ~~ specific language governing permissions and limitations
  23. ~~ under the License.
  24. Installing Apache Archiva as a Web Application
  25. ~~TODO: link to wiki location for other application servers
  26. Archiva can be deployed as a web application into any Java EE application server. This document will show an
  27. example of doing so with Tomcat 5.5 and Tomcat 6.0.x.
  28. <<Note>>: When you first start Archiva, you will see an Exception that schema SA does not exist - however it doesn't
  29. cause a problem. If you use a username other than 'sa', such as 'archiva', then you seem to get the same error but
  30. Tomcat fails to start the context and you have to shutdown and restart again.
  31. To deploy Archiva on Tomcat 5.5 and Tomcat 6.0
  32. * Create a directory in tomcat called archiva, at the same level as bin, conf, logs and the others.
  33. * Copy the war file into the new directory
  34. * Create a <<<\<tomcat home\>/conf/Catalina/localhost/archiva.xml>>> file with the following data (replace the database paths with a suitable location). When using
  35. Tomcat 6.0+, do not include the first line (XML encoding) in the <<<archiva.xml>>> configuration specified below to avoid parsing errors during startup:
  36. +-------------------------------------------------------------------------+
  37. <?xml version="1.0" encoding="UTF-8"?>
  38. <Context path="/archiva"
  39. docBase="${catalina.home}/archiva/apache-archiva-1.1.war">
  40. <Resource name="jdbc/users" auth="Container" type="javax.sql.DataSource"
  41. username="sa"
  42. password=""
  43. driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
  44. url="jdbc:derby:/path/to/database/users;create=true" />
  45. <Resource name="mail/Session" auth="Container"
  46. type="javax.mail.Session"
  47. mail.smtp.host="localhost"/>
  48. </Context>
  49. +-------------------------------------------------------------------------+
  50. * Install <<<derby-10.1.3.1.jar>>> (or later), <<<activation-1.1.jar>>> and <<<mail-1.4.jar>>> into the Tomcat 5.5 <<<common/lib>>> or Tomcat 6.0 <<<lib>>> directory.
  51. This is required since the data sources are instantiated before the web application.
  52. <<Note>>: Tomcat 5.5.20 and 5.5.23 are missing MailSessionFactory and a
  53. few other classes. JNDI mail sessions will <not> work. Use Tomcat 5.5.25
  54. instead, or see {{{http://issues.apache.org/bugzilla/show_bug.cgi?id=40668}
  55. Bug 40668}} for a workaround.
  56. * The $\{appserver.base\} java property is used by the Archiva internal logging configuration to determine where to output its logs to.
  57. It is important to define this property either in the $CATALINA_OPTS system environment variable if Tomcat is being launched via the
  58. command line) or the service properties (if being launched as a service or daemon). The format typically expected is
  59. -Dappserver.base=<SOMEWHERE>. In this example, we'll put the logs in Tomcat's <<<logs>>> directory so we need to set appserver.base
  60. property to where Tomcat is installed:
  61. +-----------+
  62. export CATALINA_OPTS="-Dappserver.home=$CATALINA_HOME -Dappserver.base=$CATALINA_HOME" (for UNIX)
  63. OR
  64. set CATALINA_OPTS="-Dappserver.home=%CATALINA_HOME% -Dappserver.base=%CATALINA_HOME%" (for Windows)
  65. +-----------+
  66. * If setting the $\{appserver.base\} and $\{appserver.home\} using the previous step does not work, you can set it in the unpacked Archiva web application's
  67. <<<WEB-INF/classes/application.properties>>> as follows:
  68. +-----------+
  69. # for Windows:
  70. appserver.base=%CATALINA_HOME%
  71. appserver.base=%CATALINA_BASE%
  72. # or, for UNIX:
  73. appserver.base=$CATALINA_HOME
  74. appserver.home=$CATALINA_BASE
  75. +-----------+
  76. * When running Tomcat as a <<Windows>> service, you need to edit <<<regedit>>> and then, in
  77. <<<HKEY_LOCAL_MACHINE \> SOFTWARE \> Apache Software Foundation \> Procrun 2.0 \> TomcatX \> Parameters \> Java>>>, modify
  78. the <<<Options>>> variable. Set the $\{appserver.base\} property by adding the following parameters at the end:
  79. +-----------+
  80. -Dappserver.base=%CATALINA_HOME% -Dappserver.home=%CATALINA_HOME%
  81. +-----------+
  82. For more information, see {{{http://cwiki.apache.org/confluence/display/ARCHIVA/Archiva+on+Tomcat} Archiva on Tomcat}} in the wiki.
  83. Archiva Configuration
  84. Archiva is configured using the <<<~/.m2/archiva.xml>>> configuration file by default when using a Java EE application server.
  85. ~~TODO: how to configure the other file
  86. Upgrading Archiva
  87. To upgrade the Archiva web application, simply replace the web application with an alternative. Since the database and configuration files are stored
  88. externally to the application, no further maintainance is needed.
  89. For general information about upgrading Archiva, see the relevant section in the {{{./standalone.html#Upgrading%20Archiva} Installing standalone}} guide.
  90. Configuring and Running Archiva
  91. Once Archiva is running, it is configured in the same way as the standalone instance. See the {{{../quick-start.html#Setting%20up%20your%20Archiva%20instance} quick start}} guide for more information.
  92. Troubleshooting
  93. * Error During Startup
  94. There are cases when the Tomcat logs only shows the following error during startup:
  95. +-----------+
  96. ...
  97. Aug 17, 2009 11:04:02 AM org.apache.catalina.core.StandardContext start
  98. SEVERE: Error listenerStart
  99. Aug 17, 2009 11:04:02 AM org.apache.catalina.core.StandardContext start
  100. SEVERE: Context [/archiva] startup failed due to previous errors
  101. Aug 17, 2009 11:04:04 AM org.apache.coyote.http11.Http11BaseProtocol start
  102. ...
  103. +-----------+
  104. One of the common causes for this <<<listenerStart Error>>> is a failure during Spring's initialization. One way to diagnose or confirm the
  105. exact cause of the error is by adding the following configuration to the unpacked Archiva webapp's <<<WEB-INF/classes/log4j.xml>>>:
  106. +-----------+
  107. <appender name="console" class="org.apache.log4j.ConsoleAppender">
  108. <layout class="org.apache.log4j.PatternLayout">
  109. <param name="ConversionPattern" value="%d [%t] %-5p %c %x - %m%n"/>
  110. </layout>
  111. </appender>
  112. <logger name="org.springframework.web">
  113. <level value="debug"/>
  114. <appender-ref ref="console"/>
  115. </logger>
  116. +-----------+
  117. The above configuration directs Spring's output logs to the Tomcat console and be recorded in Tomcat's log files.
  118. * Diagnosing Errors
  119. One of the least decipherable errors you can get from Tomcat is a <<<404>>> when the deployment fails. In <<<\<tomcat home\>/logs/catalina.out>>> you will only find that it fails, but not why. Also Archiva's logs will not tell you.
  120. The log messages and stack traces in case of a <<<404>>> can be found in <<<\<tomcat home\>/logs/localhost.\<date\>>>>.