geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: DataSource, JNDI and EJB module ...
Date Tue, 17 Jul 2007 21:27:42 GMT

On Jul 16, 2007, at 11:10 AM, Viet Hung Nguyen wrote:

> DevIn wrote:
>> Hi there,
>>
>> I actually work on a EJB3 module which must access à Connection  
>> Pool on a
>> Geronimo 2 server.
>> I've successfully created the data source (BigDB) in the geronimo  
>> console
>> but my EJB
>> Deployment is unsucessfull with the folowing error :
>>
>> 19:53:39,207 ERROR [DirectoryHotDeployer] Unable to deploy: Unable to
>> resolve reference "NonJtaDataSourceWrapper" in gbean
>> default/testEJB/11846084165
>> 04/jar?EJBModule=default/testEJB/1184608416504/ 
>> jar,J2EEApplication=null,PersistenceUnitModule=ejb.jar,j2eeType=Persi 
>> stenceUnit,name=game
>> to a gbean ma
>> tching the pattern
>> [? 
>> name=BigDB#org.apache.geronimo.connector.outbound.ConnectionFactorySo 
>> urce]due
>> to: No matches for referencePatterns: [?name=BigDB# ....
>>
>> My persistence.xml is as below :
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <persistence xmlns="http://java.sun.com/xml/ns/persistence"
>>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>>     http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
>> version="1.0">
>> 	<persistence-unit name="game" transaction-type="RESOURCE_LOCAL">
>> 	
>> <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProv 
>> ider</provider> 	
>> 			<!--  jta-data-source>BigDB</jta-data-source-->
>> 			<non-jta-data-source>jdbc/BigDB</non-jta-data-source>
>> 	</persistence-unit>
>> </persistence>

I think you definitely need the jta-data-source.  Nothing will work  
without it, that's the main jdbc connection for the jpa provider.   
Toplink might work without the non-jta-data-source, my only  
experience is with openjpa and derby, where I couldn't get it to work  
right (I think  due to my lack of understanding of some derby  
configuration).


>>
>>
>> The problem seems to be in the JNDI name of the data source, so  
>> I've tried
>> in a separated project to establish a simple connection with the JNDI
>> provider of my geronimo server. My code is :
>>
>> Properties properties = new Properties();
>>             properties.put("java.naming.factory.initial",
>> "org.openejb.client.RemoteInitialContextFactory");
>>             properties.put("java.naming.provider.url",  
>> "127.0.0.1:4201");
>>            // properties.put("java.naming.security.principal",  
>> "myuser");
>>            // properties.put("java.naming.security.credentials",  
>> "mypass");
>>             Context ic = new InitialContext(properties);
>>             System.out.println(ic.getNameInNamespace());
>>             //Object obj = ic.lookup("jdbc/BigDB");

There's no possible way this will ever work.  Geronimo doesn't try to  
export connector deployments.  You can only look up datasources in  
the vm they are running in.

>>
>> and throws the exception :
>>
>> javax.naming.AuthenticationException: Cannot open object output  
>> stream to
>> server: ; nested exception is: 	java.net.SocketException: Software  
>> caused connection abort: socket write
>> error
>> 	at org.openejb.client.JNDIContext.authenticate(JNDIContext.java:196)
>> 	at org.openejb.client.JNDIContext.getInitialContext 
>> (JNDIContext.java:181)
>> 	at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
>> 	at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
>> 	at javax.naming.InitialContext.init(Unknown Source)
>> 	at javax.naming.InitialContext.<init>(Unknown Source)
>> 	at com.big.util.Test.main(Test.java:24)
>>
>> The JNDI provider doen't seem to be OK ....
>>
>> Any help or idea will be welcome.
>> Thanks.
>>
> Have you tried to use ic.lookup("java:comp/env/jdbc/BigDB");?
>

You can try this with
InitialContext ic = new InitialContext(), from a javaee component  
running in geronimo, where you've set up a resource-ref to jdbc/ 
BigDB.... otherwise it won't work.  I don't think you'll learn much  
from this.
> Also, for your persistence.xml, did you specify a dependency on  
> that db pool that you made in Geornimo in the openejb-jar.xml?

I'm 99% sure this is the problem.
>
> I also think that you need both jta-data-source and non-jta-data- 
> source.

As noted above, you definitely need jta-data-source, and you might or  
might not need non-jta-data-source.

hope this helps
david jencks

>
> Hope this helps,
> Viet


Mime
View raw message