2

I'm trying to get integration testing working for a GlassFish 2.x project, using Maven2 and Cargo. I finally have Cargo attempting to deploy my EAR but it fails to start because the data source is not configured. The app also depends on a few JMS queues and a connection factory - how do I add these?

The Cargo Glassfish 2.x plugin says existing configurations are not supported, so I can't do that.

Using the maven-glassfish-plugin is an option, but we also run OC4J so a Cargo solution would be preferred.

edit: The resources are: 1 JDBC connection pool, 1 JDBC resource, 4 JMS queues, 2 JMS connection factories and a custom security realm (pear tree optional). The realm needs an entry in the login.conf like:

myRealm {
    uk.co.mycom.MyGlassFishLoginModule required;
};
lxs
  • 8,847
  • 4
  • 20
  • 19

1 Answers1

1

I'm not sure (I never used this) but IIRC, you should be able to put your datasource configuration in a sun-resources.xml file and package it under META-INF/sun-resources.xml in your EAR and GlassFish is supposed to create the resources at deploy time.

Here is an example sun-resources.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//Sun Microsystems Inc.//DTD Application Server 9.0 Domain//EN" "sun-resources_1_3.dtd">
<resources>
 <jdbc-connection-pool name="SPECjPool" steady-pool-size="100" 
   max-pool-size="150" max-wait-time-in-millis="60000" 
   pool-resize-quantity="2" idle-timeout-in-seconds="300" 
   is-isolation-level-guaranteed="true" 
   is-connection-validation-required="false" 
   connection-validation-method="auto-commit" 
   fail-all-connections="false" 
   datasource-classname="oracle.jdbc.pool.OracleDataSource">
  <property name="URL" 
    value="jdbc:oracle:thin:@iasperfsol12:1521:specdb"/>
  <property name="User" value="spec"/>
  <property name="Password" value="spec"/>
  <property name="MaxStatements" value="200"/>
  <property name="ImplicitCachingEnabled" value="true"/>
 </jdbc-connection-pool>
 <jdbc-resource enabled="true" pool-name="SPECjPool" 
   jndi-name="jdbc/SPECjDB"/> 
</resources>

Give it a try.

Resources


Thanks, that worked. The datasource seems to have gone in okay and the app has deployed. However from the doc you linked, I can't see how to add the other things I need (edited more detail into my question about these). This solution also means that I will have to (use profiles to?) build my EAR differently for IT, which is imperfect.

I somehow missed that you wanted to create other resources than Datasources and I've seen several threads reporting that the suggested approach won't work with GlassFish v2 for any resources (like JMS resources). My bad.

So, given the current state, your options are (IMO):

  • contribute to Cargo to provide an "existing" configuration implementation for GlassFish v2
  • use the maven-glassfish-plugin as you suggested

I don't have any better suggestions.

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • @vkraemer I couldn't find an authoritative source but I understood it might work for datasources. Can you confirm this? – Pascal Thivent Nov 02 '10 at 22:59
  • Thanks, that worked. The datasource seems to have gone in okay and the app has deployed. However from the doc you linked, I can't see how to add the other things I need (edited more detail into my question about these). This solution also means that I will have to (use profiles to?) build my EAR differently for IT, which is imperfect. – lxs Nov 03 '10 at 09:40
  • @vkraemer How is the 3.1 support better? More robust? More comprehensive? – lxs Nov 03 '10 at 09:52
  • @lxs: I think it's more exhaustive (AFAIK, the above doesn't work for *any* resource, as it should). – Pascal Thivent Nov 03 '10 at 16:27
  • Thanks for editing into your post, upvoted. Going to work on something else for now, leaving the question open. – lxs Nov 05 '10 at 11:49
  • @lxs: the feature is documented in 3.1. It isn't really documented in 2.x. – vkraemer Nov 10 '10 at 04:41