Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [eclipselink-users] Running Eclipselink in JUnit4 test

Gili,
	Hi, good question.  
	I have not verified using the server datasource from an SE app for any other server yet - the method should be the same.
	For SE (non JEE) apps I usually use the internal connection pool provided by EclipseLink and not the one on the server.

see
http://wiki.eclipse.org/Introduction_to_Data_Access_%28ELUG%29#Internal_Connection_Pools

	The question of which JDBC connection mechanism to use (server datasource or jdbc properties) will depend on your application as both provide connection pooling and similar configuration options.  For example, you may want to use the same pool that your entity beans and/or servlets use on the server, or share a pool among SE applications - this may require use of the server datasource.  Otherwise I would just let EclipseLink handle the connections for standalone applications.

	thank you
	/michael

-----Original Message-----
From: cowwoc [mailto:cowwoc@xxxxxxxxxxxxxxxx]
Sent: Sunday, October 26, 2008 14:29
To: eclipselink-users@xxxxxxxxxxx
Subject: Re: [eclipselink-users] Running Eclipselink in JUnit4 test



Hi Michael,

Thanks for the pointer. Is there a similar document for Glassfish? Is there
a major advantage to using datasources over JDBC or are they mostly the same
nowadays?

Gili


mobrien wrote:
> 
> Gili, 
>    Hi, if your application originally ran on your server using JTA, you
> can leverage the datasource on the server in standalone SE/JUnit apps as
> well - without having to redefine db connection properties a 2nd time.
>    For reference, here is a verified quick start tutorial example on how
> to configure a SE EclipseLink JPA application to use the JNDI datasource
> from a running Tomcat 6 (web-only) container.  Your InitialContext will
> need to be preconfigured, container jars will need to be on your classpath
> and persistence.xml will need a non-jta-data-source
> 
> http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_Tutorial#Using_JNDI_outside_the_Tomcat_container_for_J2SE_Applications
> 
> Otherwise, just specify jdbc properties in your persistence.xml if you do
> not wish to reuse your container datasource.
> 
> Thank you
> /michael at eclipselink.org
> 
> ----------Original Message----------
> 
> From: "Tim Hollosy" <hollosyt@xxxxxxxxx>
> Sent: Sun, October 26, 2008 6:14 AM
> To: "EclipseLink User Discussions" <eclipselink-users@xxxxxxxxxxx>
> Subject: Re: [eclipselink-users] Running Eclipselink in JUnit4 test
> 
> 
> Maybe because it's trying to obtain the datasource from the container?
> 
> ./tch
> 
> 
> 
> On Sat, Oct 25, 2008 at 8:27 PM, cowwoc <cowwoc@xxxxxxxxxxxxxxxx> wrote:
>>
>> Hi,
>>
>> I have EclipseLink working perfectly in my application but when I try
>> using
>> it in a JUnit4 test (attached to the same project) I get:
>>
>> [EL Info]: 2008.10.25
>> 20:21:23.526--ServerSession(1546137693)--EclipseLink,
>> version: Eclipse Persistence Services - 1.0.1 (Build 20080905)
>> Exception Description: Cannot acquire data source [jdbc/adcaster].
>> Internal Exception: javax.naming.NoInitialContextException: Need to
>> specify
>> class name in environment or system property, or as an applet parameter,
>> or
>> in an application resource file:  java.naming.factory.initial)
>>
>> Any idea why Eclipselink can't find the datasource?
>>
>> Thanks,
>> Gili
>> --
>> View this message in context:
>> http://www.nabble.com/Running-Eclipselink-in-JUnit4-test-tp20169314p20169314.html
>> Sent from the EclipseLink - Users mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> eclipselink-users mailing list
>> eclipselink-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> 
> 

-- 
View this message in context: http://www.nabble.com/Running-Eclipselink-in-JUnit4-test-tp20169314p20176462.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top