Archiva On GlassFish with MySQL
Glassfish web configuration
- Deploy the war file on your Glassfish server from the admin page (http://localhost:4848).
MySQL console
- Create the two needed databases:
CREATE DATABASE users;
CREATE DATABASE archiva; - Create account to access them:
GRANT ALL PRIVILEGES ON users.* TO 'users'@'*' IDENTIFIED BY 'users' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON archiva.* TO 'archiva'@'*' IDENTIFIED BY 'archiva' WITH GRANT OPTION;
Note: the tables should be latin1 character set. If you use UTF8 you ran out of max key length:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes
Glassfish file configuration
Edit the file <GLASSFISH_FOLDER>/domains/domain1/config/domain.xml to add the following tags:
- Go to Ressources -> JavaMail Sessions and create a new ressource with jndi-name='mail/Session', otherwise you will get "Error creating bean with name 'mailSession'" on startup. Or add it to the config file:
... <resources> <mail-resource debug="false" enabled="true" from="me@email.example.com" host="email.example.com" jndi-name="mail/Session" object-type="user" store-protocol="imap" store-protocol-class="com.sun.mail.imap.IMAPStore" transport-protocol="smtp" transport-protocol-class="com.sun.mail.smtp.SMTPTransport" user="me"/> ...
Set appserver.base and appserver.home properties
Ensure that the property appserver.base is set. Archiva uses this to locate log files.... <java-config ... <jvm-options>-Dappserver.base=${com.sun.aas.installRoot}/domains/domain1</jvm-options> <jvm-options>-Dappserver.home=${com.sun.aas.installRoot}/domains/domain1</jvm-options> ...
JDBC resources
... </applications> <resources> <jdbc-resource enabled="true" jndi-name="jdbc/users" object-type="user" pool-name="usersMysqlPool"/> <jdbc-resource enabled="true" jndi-name="jdbc/archiva" object-type="user" pool-name="archivaMysqlPool"/> ...
Connection pool
<jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="archivaMysqlPool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false"> <property name="databaseName" value="archiva"/> <property name="serverName" value="localhost"/> <property name="User" value="archiva"/> <property name="Password" value="archiva"/> <property name="URL" value="jdbc:mysql://localhost:3306/archiva"/> <property name="portNumber" value="3306"/> <property name="driverClass" value="com.mysql.jdbc.Driver"/> </jdbc-connection-pool> <jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="usersMysqlPool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false"> <property name="databaseName" value="users"/> <property name="serverName" value="localhost"/> <property name="User" value="users"/> <property name="Password" value="users"/> <property name="URL" value="jdbc:mysql://localhost:3306/users"/> <property name="portNumber" value="3306"/> <property name="driverClass" value="com.mysql.jdbc.Driver"/> </jdbc-connection-pool>
Resources ref
<servers> <server config-ref="server-config" lb-weight="100" name="server"> ... <resource-ref enabled="true" ref="jdbc/users"/> <resource-ref enabled="true" ref="jdbc/archiva"/> ... </server> </servers>
- Now restart you Glassfish server, and open the archiva location. The last thing you have to do is create the admin user