RESOURCE_LOCAL because my applications runs, and with JTA transaction-type
it not run. About jdbc properties, I do not know.
Sorry, but I not understand about the next question. What is a EM? A
EntityManager?
The class that use the Persistence Unit looks like:
protected EntityManager em;
private EntityManagerFactory emf;
// Locale actual
private Locale locale;
protected ResourceBundle errorResources;
private String nombreBaseDatos = "seneca"; // BASE RESIDENTE
public ControladorBase() {
nombreBaseDatos = ParmsSingleton.global().getBaseEnCurso();
if (nombreBaseDatos==null) nombreBaseDatos="seneca";
String jdbcUrl = "jdbc:derby://localhost/"+nombreBaseDatos;
// System.out.println ("conecta base sin parametro: "+jdbcUrl);
Properties databaseProperties = new Properties();
databaseProperties.setProperty(oracle.toplink.essentials.config.TopLinkProperties.JDBC_URL,
jdbcUrl);
databaseProperties.setProperty(oracle.toplink.essentials.config.TopLinkProperties.JDBC_DRIVER,
"org.apache.derby.jdbc.ClientDriver");
databaseProperties.setProperty(oracle.toplink.essentials.config.TopLinkProperties.JDBC_USER,
"seneca");
databaseProperties.setProperty(oracle.toplink.essentials.config.TopLinkProperties.JDBC_PASSWORD,
"seneca");
emf = Persistence.createEntityManagerFactory("SenecaPU",
databaseProperties);
em = emf.createEntityManager();
locale = Locale.getDefault();
errorResources =
ResourceBundle.getBundle("seneca/resources/errors_es_ES", locale);
}
thanks!!
Daniel Benítez
--------------------------------------------------
From: "Marina Vatkina" <Marina.Vatkina_at_Sun.COM>
Sent: Wednesday, December 03, 2008 7:25 PM
To: <persistence_at_glassfish.dev.java.net>
Subject: Re: Where is my persistence unit?
> Daniel Benítez wrote:
>> Yes we can!
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <persistence version="1.0"
>> xmlns="http://java.sun.com/xml/ns/persistence">
>> <persistence-unit name="SenecaPU" transaction-type="RESOURCE_LOCAL">
>>
>> <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
>> <!--<non-jta-data-source>jdbc/SenecaJNDI</non-jta-data-source>-->
>> <exclude-unlisted-classes>false</exclude-unlisted-classes>
>> <properties>
>> <property name="toplink.jdbc.driver"
>> value="org.apache.derby.jdbc.ClientDriver"/>
>> <property name="toplink.logging.level" value="OFF"/>
>> <property name="toplink.ddl-generation" value="create-tables"/>
>> </properties>
>> </persistence-unit>
>> </persistence>
>
> Why do you use RESOURCE_LOCAL and jdbc properties in the EJB? How do you
> get a hold of an EM there?
>>
>>
>> I'm not sure about what do you want of the structure of the ear file,
>> directories and files?
>
> Yes.
>
> thanks,
> -marina
>
>>
>>
>> Thanks!
>>
>> Daniel Benítez.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> --------------------------------------------------
>> From: "Marina Vatkina" <Marina.Vatkina_at_Sun.COM>
>> Sent: Wednesday, December 03, 2008 1:12 AM
>> To: <persistence_at_glassfish.dev.java.net>
>> Subject: Re: Where is my persistence unit?
>>
>>> Can you publish your persistence.xml and the structure of your ear file?
>>>
>>> thanks,
>>> -marina
>>>
>>> Daniel Benítez wrote:
>>>
>>>> Hi people,
>>>>
>>>> I have a problem with a wicked persistence unit. My Entreprise
>>>> Application
>>>> in Netbeans 6.1 have an EJB and a App Client. I defined a persistence
>>>> unit
>>>> to connect with a derby database in the EJB module. My problem is that
>>>> I try
>>>> to execute from my Entreprise Application it not run, but if I execute
>>>> from
>>>> the Application client, I have not problems with the persistence unit.
>>>>
>>>> Netbeans tell me that "Exception in thread "AWT-EventQueue-0"
>>>> javax.persistence.PersistenceException: No Persistence provider for
>>>> EntityManager named SenecaPU". (Persistence provider named SenecaPU
>>>> exist!)
>>>>
>>>> I defined de persistence unit with transaction-type="RESOURCE_LOCAL"
>>>> parameter, but if I change this parameter with "JTA" I have not way to
>>>> run
>>>> my program.
>>>>
>>>>
>>>>
>>>> Thank You every one.
>>>>
>>>> Daniel Benítez.
>>>>
>>>>
>>>>
>>>
>>>
>
>