geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Petersson <pe...@pmb.mine.nu>
Subject Re: geronimo using JPOX JDO
Date Sat, 11 Aug 2007 09:06:33 GMT
fred.ac wrote:
> It seems not working, my IDE (intellij) says "Duplicate annotation" ?
> Nevertheless I don't like to define at bean level a ref to the connection
> pool (my bean don't use it directly) , a ref to jdo persistence manage
> should be sufficient like done for JPA that needs a ref to the entity
> manager.
> It could be nice if the connection pool could be registered as a global jndi
> like java:/Transaction.
> With this I could define in JPOX rar connector cfg a ref to the connection
> pool with java:/tamsDS (like made for jboss). I found some geronimo samples
> with element <global-jndi-name> defined in the pool definition but it seems
> not recognized now (not allowed in geronimo-connector-1.1.xsd).
> Is there an other possibility to register a pool as a global jndi name ?
> Thanks
> Fred.
>   
You could also try this if you haven't already.
@Resources({
  @Resource(name="tamsDS")
  @Resource(name="tamsDS2") })
public class MyFoo {
...
regards
  Peter Petersson
>
>
>
>
> djencks wrote:
>   
>> I think that something like
>>
>> @Resource(name="tamsDS)
>> @Resource(name="tamsDS2)
>> public class MyFoo {
>> ...
>>
>> should work.   I think we need an integration test demonstrating how  
>> to set this up.
>>
>> thanks
>> david jencks
>>
>> On Aug 9, 2007, at 2:11 AM, fred.ac wrote:
>>
>>     
>>> Thanks for your quick reply!
>>> I have a session bean with jpox persitence manager factory injected  
>>> like
>>> this :
>>>
>>> @Stateless(name = "hello")
>>> @TransactionManagement(TransactionManagementType.CONTAINER)
>>> public class StatelessSessionBean implements StatelessSession {
>>>
>>>     @Resource(name = "jpox")
>>>     private PersistenceManagerFactory pmf;
>>>
>>>     @TransactionAttribute(TransactionAttributeType.REQUIRED)
>>>     public String sayHello(String name) {
>>>         String fctrName = "?";
>>>         try {
>>>             PersistenceManager pm = pmf.getPersistenceManager();
>>>             Query q = pm.newQuery(Functionality.class, "name ==  
>>> 'test2'");
>>>             q.setUnique(true);
>>>             Functionality fct = (Functionality) q.execute();
>>>             FunctionalityRelease fctr =
>>> fct.getFunctionalityRelease("00.00.01");
>>>             q.closeAll();
>>>             pm.close();
>>>             fctrName = fctr.getName();
>>>         } catch (Exception ex) {
>>>             ex.printStackTrace();
>>>         }
>>>         return fctrName;
>>>     }
>>> }
>>>
>>> You said  "try providing resource-refs in each component that uses  
>>> jdo (web
>>> app or ejb session bean) to each of the datasources"
>>> How can I define resource-refs you mentioned ? in ejb-jar.xml,
>>> open-ejb-jar.xml ? Could you give me an example ?
>>>
>>> Thanks
>>>
>>> Fred.
>>>
>>>
>>> djencks wrote:
>>>       
>>>> On Aug 8, 2007, at 11:56 PM, fred.ac wrote:
>>>>
>>>>         
>>>>> I'm trying to use JPOX framework (www.jpox.org) with geronimo 2-M6.
>>>>> I have a test case (all packaged in a ear) that is working with
>>>>> JBOSS 4.2
>>>>> and I want ot make it working with geronimo.
>>>>>
>>>>> First problem: in the rar file provided in jpox distrib the ra.xml
>>>>> doesn't
>>>>> contain available properties (config-property elements are empty).
>>>>> With
>>>>> Jboss I defined all properties in a jpox-ds.xml file :
>>>>>
>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>> <connection-factories>
>>>>>     <tx-connection-factory>
>>>>>         <jndi-name>eis/jdo/JpoxPersistenceManagerFactory</jndi-name>
>>>>>         <rar-name>MyApplication.ear#jpox-jca-1.2-SNAPSHOT.rar</rar-
>>>>> name>
>>>>>
>>>>> <connection-definition>javax.resource.cci.ConnectionFactory</
>>>>> connection-definition>
>>>>>
>>>>>         <config-property name="ConnectionFactoryName"
>>>>>             type="java.lang.String">java:/tamsDS</config-property>
>>>>>         <config-property name="ConnectionFactory2Name"
>>>>>             type="java.lang.String">java:/tamsDS2</config-property>
>>>>> ...
>>>>>   </tx-connection-factory>
>>>>> </connection-factories>
>>>>>
>>>>> With geronimo I defined the properties in a jpox.xml file like this:
>>>>> <connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/
>>>>> connector-1.1">
>>>>>     <dep:environment
>>>>> xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
>>>>>         <dep:moduleId>
>>>>>             <dep:groupId>console.dbpool</dep:groupId>
>>>>>             <dep:artifactId>jpox</dep:artifactId>
>>>>>             <dep:version>1.0</dep:version>
>>>>>             <dep:type>rar</dep:type>
>>>>>         </dep:moduleId>
>>>>>         <dep:dependencies>
>>>>>             <dep:dependency>
>>>>>                 <dep:groupId>oracle</dep:groupId>
>>>>>                 <dep:artifactId>ojdbc14</dep:artifactId>
>>>>>                 <dep:version>10.2.0.1.0</dep:version>
>>>>>                 <dep:type>jar</dep:type>
>>>>>             </dep:dependency>
>>>>>         </dep:dependencies>
>>>>>     </dep:environment>
>>>>>
>>>>>     <resourceadapter>
>>>>>         <outbound-resourceadapter>
>>>>>             <connection-definition>
>>>>>
>>>>> <connectionfactory-interface>javax.resource.cci.ConnectionFactory</
>>>>> connectionfactory-interface>
>>>>>                 <connectiondefinition-instance>
>>>>>                     <name>jpox</name>
>>>>>                     <!--<config-property-setting
>>>>> name="ConnectionFactoryName">tamsDS</config-property-setting>
>>>>>                     <config-property-setting
>>>>> name="ConnectionFactory2Name">tamsDS2</config-property-setting>-->
>>>>>                     <config-property-setting
>>>>> name="ConnectionDriverName">oracle.jdbc.OracleDriver</config-
>>>>> property-setting>
>>>>>                     <config-property-setting
>>>>> name="ConnectionURL">jdbc:oracle:thin:@localhost:1521/XE</config-
>>>>> property-setting>
>>>>>                     <config-property-setting
>>>>> name="ConnectionUserName">sa</config-property-setting>
>>>>>                     <config-property-setting
>>>>> name="ConnectionPassword">hagar</config-property-setting>
>>>>>                     <config-property-setting
>>>>> name="Schema">SA</config-property-setting>
>>>>>                     <config-property-setting
>>>>> name="FixedDatastore">true</config-property-setting>
>>>>>                     <config-property-setting
>>>>> name="ValidateTables">false</config-property-setting>
>>>>>                     <config-property-setting
>>>>> name="ValidateConstraints">false</config-property-setting>
>>>>>                     <config-property-setting
>>>>> name="Optimistic">true</config-property-setting>
>>>>>                     <config-property-setting
>>>>> name="Multithreaded">true</config-property-setting>
>>>>>                     <config-property-setting
>>>>> name="IgnoreCache">true</config-property-setting>
>>>>>                     <config-property-setting
>>>>> name="RestoreValues">true</config-property-setting>
>>>>>                     <config-property-setting
>>>>> name="DetachAllOnCommit">true</config-property-setting>
>>>>>                     <config-property-setting
>>>>> name="NontransactionalRead">false</config-property-setting>
>>>>>                     <connectionmanager>
>>>>>                         <no-transaction/>
>>>>>                         <no-pool/>
>>>>>                     </connectionmanager>
>>>>>                 </connectiondefinition-instance>
>>>>>             </connection-definition>
>>>>>         </outbound-resourceadapter>
>>>>>     </resourceadapter>
>>>>> </connector>
>>>>>
>>>>> the jpox.xml file is referred in geronimo-application like this :
>>>>>  <module>
>>>>> <connector>jpox-jca-1.2-SNAPSHOT.rar</connector>
>>>>> <alt-dd>META-INF/jpox.xml</alt-dd>
>>>>> </module>
>>>>>
>>>>> Whe I deploy my ear file in geronimo I receive :
>>>>> Unable to deploy: org.apache.geronimo.common.DeploymentException:
>>>>> The plan
>>>>> is trying to set attributes: [ConnectionDriverName, ConnectionURL,
>>>>> ConnectionUserName, ConnectionPassword, Schema, FixedDatastore,
>>>>> ValidateTables, ValidateConstraints, Optimistic, Multithreaded,
>>>>> IgnoreCache,
>>>>> RestoreValues, DetachAllOnCommit, NontransactionalRead]
>>>>>
>>>>> I think it is because these properties are not define in the ra.xml
>>>>> provided
>>>>> by jpox. If I manually add them it works.
>>>>>
>>>>> Is it possible to define properties somewhere else ? I don't want
>>>>> to "patch"
>>>>> standard jpox distrib (jpox-jca-1.2-SNAPSHOT.rar) to make it
>>>>> working with
>>>>> geronimo.
>>>>>           
>>>> I think you will need to patch the rar or build your own with all the
>>>> properties in the ra.xml.  My understanding of the j2ca spec is that
>>>> this is required of the ra.xml.  If the jpox people think otherwise
>>>> I'd like to know why.
>>>>         
>>>>> My second problem: I want that jpox use a geronimo connection pool.
>>>>> I have
>>>>> created 2 connection pools via the geronimo console. I need a
>>>>> transactional
>>>>> one and a non-transactional one, how can I specify this ?. Jpox
>>>>> needs 2
>>>>> properties to use app server connection pool : ConnectionFactoryName
>>>>> (transactional) and ConnectionFactory2Name (non transactional). As
>>>>> you see
>>>>> in the jpox-ds.xml the connections are refered with a global jndi  
>>>>> name
>>>>> (java:/tamsDS and java:/tamsDS2). How can I refer this in geronimo ?
>>>>>
>>>>> following config doesn't work :
>>>>>
>>>>> <config-property-setting
>>>>> name="ConnectionFactoryName">java:/tamsDS</config-property-setting>
>>>>> <config-property-setting
>>>>> name="ConnectionFactory2Name">java:/tamsDS2</config-property- 
>>>>> setting>
>>>>>
>>>>> Pools created in geronimo are defined like this :
>>>>> console.dbpool/tamsDS/1.0/rar
>>>>> console.dbpool/tamsDS2/1.0/rar
>>>>>
>>>>> How can I make the link between them ?
>>>>>           
>>>> This is trickier.  This seems to me like one thing the jpa spec did
>>>> better than the jdo spec.  Anyway, I would try providing resource-
>>>> refs in each component that uses jdo (web app or ejb session bean) to
>>>> each of the datasources and using something like
>>>>
>>>> <config-property-setting
>>>> name="ConnectionFactoryName">java:comp/env/tamsDS</config-property-
>>>> setting>
>>>> <config-property-setting
>>>> name="ConnectionFactory2Name">java:comp/env/tamsDS2</config-property-
>>>> setting>
>>>>
>>>> Another thing to be aware of is that your application needs to have
>>>> both datasource in parent configurations.  So the geronimo plan would
>>>> start something like
>>>>
>>>> <connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/ 
>>>> connector-1.1">
>>>>      <dep:environment
>>>> xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
>>>>          <dep:moduleId>
>>>>              <dep:groupId>console.dbpool</dep:groupId>
>>>>              <dep:artifactId>jpox</dep:artifactId>
>>>>              <dep:version>1.0</dep:version>
>>>>              <dep:type>rar</dep:type>
>>>>          </dep:moduleId>
>>>>          <dep:dependencies>
>>>>              <dep:dependency>
>>>>                  <dep:groupId>console.dbpool</dep:groupId>
>>>>                  <dep:artifactId>tamDS</dep:artifactId>
>>>>                  <dep:version>1.0</dep:version>
>>>>                  <dep:type>rar</dep:type>
>>>>              </dep:dependency>
>>>>              <dep:dependency>
>>>>                  <dep:groupId>console.dbpool</dep:groupId>
>>>>                  <dep:artifactId>tamDS2</dep:artifactId>
>>>>                  <dep:version>1.0</dep:version>
>>>>                  <dep:type>rar</dep:type>
>>>>              </dep:dependency>
>>>>          </dep:dependencies>
>>>>      </dep:environment>
>>>>
>>>> I'd also advise combining the 2 datasource plans into one plan.  Be
>>>> sure the non-transactional datasource really is configured with <no-
>>>> transaction/>
>>>>
>>>> As long as you name the datasources tamDS and tamDS2 in their plans I
>>>> think geronimo will be able to look up the datasource correctly.
>>>>
>>>> Does jpox recommend the <no-pool/> setting?
>>>>
>>>> Please let us know how this works out.  If you still have problems
>>>> and have a sample app to demonstrate the problems I can take a look
>>>> at it.  I wonder if we should look into supporting jdo similarly to
>>>> how jpa is supported.
>>>>
>>>> thanks
>>>> david jencks
>>>>
>>>>
>>>>         
>>>>> Thanks
>>>>>
>>>>> Frédéric.
>>>>> -- 
>>>>> View this message in context: http://www.nabble.com/geronimo-using-
>>>>> JPOX-JDO-tf4240920s134.html#a12067391
>>>>> Sent from the Apache Geronimo - Users mailing list archive at
>>>>> Nabble.com.
>>>>>
>>>>>           
>>>>
>>>>         
>>> -- 
>>> View this message in context: http://www.nabble.com/geronimo-using- 
>>> JPOX-JDO-tf4240920s134.html#a12069028
>>> Sent from the Apache Geronimo - Users mailing list archive at  
>>> Nabble.com.
>>>
>>>       
>>
>>     
>
>   


Mime
View raw message