...
- Note that
c.d
meanscargo.datasource
- Note that if you specify a property marked do not set you will get a
CargoException
.
Property | Purpose | Valid Values | DataSource | Transactional DataSource | XA DataSource |
---|---|---|---|---|---|
| The path to this DataSource in JNDI | Any jndi path, like | mandatory | mandatory | mandatory |
| The implementation class | ex. | mandatory: must implement | mandatory: must implement | mandatory: must implement |
| Properties to pass to the driver | Semi-colon delimited string | optional | optional | mandatory |
| URL for the | ex. | mandatory | mandatory | optional |
| Determines the type of the driver | Defaults to | do not set | do not set |
|
| Determines transaction support type |
| do not set | mandatory | unset defaults to only valid option: |
| Identifier used in configuration files to reference this DataSource | Must contain no path-like characters | optional | optional | optional |
| Username to connect to the database | String | optional | optional | optional |
| Password to connect to the database | String | optional | optional | optional |
...
This is because Glassfish is already shipped with Derby, and the Glassfish class loaders do not know how to the manage the situation where the same class is duplicated. So, the solution is to simply remove the Derby JAR from dependencies; on the other hand this is not feasible if you are using the same CARGO profile with different containers. Here is how you can work around the issue:
Code Block | ||
---|---|---|
| ||
<dependencies> <dependency> <groupId>org.apache.derby</groupId> <artifactId>derby</artifactId> <version>${derby.version}</version> <scope>test</scope> </dependency> </dependencies> ... <build> <plugins> <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>${cargo.version}</version> <!-- This configuration will be used in general. --> <configuration> <container> <dependencies> <dependency> <groupId>org.apache.derby</groupId> <artifactId>derby</artifactId> </dependency> </dependencies> <systemProperties> <derby.system.home>\${project.build.directory}/derby</derby.system.home> </systemProperties> </container> <configuration> <properties> <cargo.datasource.datasource.derby> cargo.datasource.driver=org.apache.derby.jdbc.EmbeddedDriver| cargo.datasource.url=jdbc:derby:derbyDB;create=true| cargo.datasource.jndi=jdbc/CargoDS| cargo.datasource.username=APP| cargo.datasource.password=nonemptypassword </cargo.datasource.datasource.derby> </properties> </configuration> ... </configuration> </plugin> </plugins> </build> <profiles> ... <profile> <id>glassfish3x</id> <build> <pluginManagement> <plugins> <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <configuration> <container> <containerId>glassfish3x</containerId> <artifactInstaller> <groupId>org.glassfish.main.distributions</groupId> <artifactId>glassfish</artifactId> <version>3.1.2.2</version> </artifactInstaller> <dependencies> <!-- Remove the org.apache.derby dependency since GlassFish 3.x is already shipped with Derby, and adding the dependency twice results in a java.lang.SecurityException: sealing violation: package org.apache.derby. --> <dependency> <groupId>org.apache.derby</groupId> <artifactId>derby</artifactId> <classpath>none</classpath> </dependency> </dependencies> </container> </configuration> </plugin> </plugins> </pluginManagement> </build> </profile> </profiles> |
...
Users of the Maven2/Maven3 plugin can use the Maven2 Archetype showing DataSource support. Please read: DataSource Definition Archetype.