问题
I am using the stand alone version of Archiva, it uses Jetty for its application container. It defaults to something like http://mycompany.com:8080/archiva
I want to get rid of the application context and just make it http://mycompany.com:8080/
so I can map it to a sub-domain using Virtual Hosts in Apache 2.2.x.
I can't figure out what to change in the configuration files. Here is the jetty.xml
file with all the comments cut out for brevity.
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure id="Server" class="org.mortbay.jetty.Server">
<!-- =========================================================== -->
<!-- Server Thread Pool -->
<!-- =========================================================== -->
<Set name="ThreadPool">
<!-- Default bounded blocking threadpool
-->
<New class="org.mortbay.thread.BoundedThreadPool">
<Set name="minThreads">10</Set>
<Set name="maxThreads">250</Set>
<Set name="lowThreads">25</Set>
</New>
</Set>
<Call name="addConnector">
<Arg>
<New class="org.mortbay.jetty.nio.SelectChannelConnector">
<Set name="host"><SystemProperty name="jetty.host"/></Set>
<Set name="port"><SystemProperty name="jetty.port" default="8081"/></Set>
<Set name="maxIdleTime">30000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
<Set name="confidentialPort">8443</Set>
<Set name="lowResourcesConnections">5000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
</New>
</Arg>
</Call>
<Set name="handler">
<New id="Handlers" class="org.mortbay.jetty.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.mortbay.jetty.Handler">
<Item>
<New id="Contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection"/>
</Item>
<Item>
<New id="DefaultHandler" class="org.mortbay.jetty.handler.DefaultHandler"/>
</Item>
<Item>
<New id="RequestLog" class="org.mortbay.jetty.handler.RequestLogHandler"/>
</Item>
</Array>
</Set>
</New>
</Set>
<Call name="addLifeCycle">
<Arg>
<New class="org.mortbay.jetty.deployer.ContextDeployer">
<Set name="contexts"><Ref id="Contexts"/></Set>
<Set name="configurationDir"><SystemProperty name="jetty.home" default="."/>/contexts</Set>
<Set name="scanInterval">1</Set>
</New>
</Arg>
</Call>
<Call name="addLifeCycle">
<Arg>
<New class="org.mortbay.jetty.deployer.WebAppDeployer">
<Set name="contexts"><Ref id="Contexts"/></Set>
<Set name="webAppDir"><SystemProperty name="jetty.home" default="."/>/apps</Set>
<Set name="parentLoaderPriority">false</Set>
<Set name="extract">true</Set>
<Set name="allowDuplicates">false</Set>
</New>
</Arg>
</Call>
<Ref id="RequestLog">
<Set name="requestLog">
<New id="RequestLogImpl" class="org.mortbay.jetty.NCSARequestLog">
<Set name="filename"><SystemProperty name="jetty.logs" default="./logs"/>/yyyy_mm_dd.request.log</Set>
<Set name="filenameDateFormat">yyyy_MM_dd</Set>
<Set name="retainDays">90</Set>
<Set name="append">true</Set>
<Set name="extended">true</Set>
<Set name="logCookies">false</Set>
<Set name="LogTimeZone">GMT</Set>
</New>
</Set>
</Ref>
<!-- =========================================================== -->
<!-- extra options -->
<!-- =========================================================== -->
<Set name="stopAtShutdown">true</Set>
<Set name="sendServerVersion">true</Set>
<Set name="sendDateHeader">true</Set>
<Set name="gracefulShutdown">1000</Set>
<Array id="plusConfig" type="java.lang.String">
<Item>org.mortbay.jetty.webapp.WebInfConfiguration</Item>
<Item>org.mortbay.jetty.plus.webapp.EnvConfiguration</Item>
<Item>org.mortbay.jetty.plus.webapp.Configuration</Item>
<Item>org.mortbay.jetty.webapp.JettyWebXmlConfiguration</Item>
<Item>org.mortbay.jetty.webapp.TagLibConfiguration</Item>
</Array>
<!-- =========================================================== -->
<!-- Deploy all webapps in webapps-plus -->
<!-- =========================================================== -->
<Call class="org.mortbay.jetty.webapp.WebAppContext" name="addWebApplications">
<Arg><Ref id="Contexts"/></Arg>
<Arg>./apps</Arg>
<Arg>org/mortbay/jetty/webapp/webdefault.xml</Arg>
<Arg><Ref id="plusConfig"/></Arg>
<Arg type="boolean">True</Arg>
<Arg type="boolean">False</Arg>
</Call>
<!-- ARCHIVA CONFIG -->
<New id="validation_mail" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>mail/Session</Arg>
<Arg>
<New class="org.mortbay.naming.factories.MailSessionReference">
<Set name="user"></Set>
<Set name="password"></Set>
<Set name="properties">
<New class="java.util.Properties">
<Put name="mail.smtp.host">localhost</Put>
</New>
</Set>
</New>
</Arg>
</New>
<!-- Archiva database -->
<New id="archiva" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>jdbc/archiva</Arg>
<Arg>
<New class="org.apache.commons.dbcp.BasicDataSource">
<Set name="driverClassName">org.apache.derby.jdbc.EmbeddedDataSource</Set>
<Set name="url">jdbc:derby:<SystemProperty name="appserver.base" default=".."/>/data/databases/archiva</Set>
<Set name="username">sa</Set>
<Call name="addConnectionProperty">
<Arg>create</Arg>
<Arg>true</Arg>
</Call>
</New>
</Arg>
</New>
<New id="archivaShutdown" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>jdbc/archivaShutdown</Arg>
<Arg>
<New class="org.apache.commons.dbcp.BasicDataSource">
<Set name="driverClassName">org.apache.derby.jdbc.EmbeddedDataSource</Set>
<Set name="url">jdbc:derby:<SystemProperty name="appserver.base" default=".."/>/data/databases/archiva</Set>
<Set name="username">sa</Set>
<Call name="addConnectionProperty">
<Arg>shutdown</Arg>
<Arg>true</Arg>
</Call>
</New>
</Arg>
</New>
<!-- Users / Security Database -->
<New id="users" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>jdbc/users</Arg>
<Arg>
<New class="org.apache.derby.jdbc.EmbeddedDataSource">
<Set name="DatabaseName"><SystemProperty name="appserver.base" default=".."/>/data/databases/users</Set>
<Set name="user">sa</Set>
<Set name="createDatabase">create</Set>
</New>
</Arg>
</New>
<New id="usersShutdown" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>jdbc/usersShutdown</Arg>
<Arg>
<New class="org.apache.derby.jdbc.EmbeddedDataSource">
<Set name="DatabaseName"><SystemProperty name="appserver.base" default=".."/>/data/databases/users</Set>
<Set name="user">sa</Set>
<Set name="shutdownDatabase">shutdown</Set>
</New>
</Arg>
</New>
</Configure>
Here is the contents of my /apps
directory:
[Thu Mar 03 22:03:37] [root]@[dev] /opt/archiva/apps
# dir
total 12K
drwxr-xr-x 3 root root 4.0K Mar 2 17:34 .
drwxr-xr-x 8 root root 4.0K Mar 2 17:39 ..
drwxr-xr-x 9 root root 4.0K Mar 2 17:34 archiva
Thanks for taking the time to look at this.
回答1:
OK, there's a few options for a solution.
If you rename
apps/archiva
toapps/root
then it should do exactly what you want.Otherwise, you can modify your
jetty.xml
so that it deploys each app (in your case you only have 1) explicitly (rather than the way it is now, which deploys everything inapps/
) That's a bit of a pain, so I don't recommend it.Save this in
apps/archiva/WEB-INF/jetty-web.xml
:<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<Set name="contextPath">/</Set>
</Configure>
You can use the context deployer http://docs.codehaus.org/display/JETTY/ContextDeployer instead of deploying the app directly - this will allow you to configure the contextPath
I think option 1 is the easiest, but option 3 is pretty easy too.
2. and 4. are both more complicated.
回答2:
Implemented for coming 1.4-M3. With an other solution :-) ${jetty.home}/contexts/archiva.xml with content
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/</Set>
<Set name="war"><SystemProperty name="jetty.home" default="."/>/apps/archiva</Set>
<Set name="extractWAR">false</Set>
<Set name="copyWebDir">false</Set>
</Configure>
来源:https://stackoverflow.com/questions/5176486/how-to-make-the-stand-alone-archiva-distribution-the-root-application-under-jett