[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] How to create J2SE applications with no persistence.xml files
|
You're going to need a persistence.xml somewhere I think. What do you
mean you have a requirement you can't put an xml file in the
src/META-INF dir? That's a pretty bizarre requirement...
./tch
On Thu, Jan 29, 2009 at 11:26 PM, krisusa123 <krisusa123@xxxxxxxxx> wrote:
>
> Hi Ben
> I am trying to use this which was developed by Tim for his comics example.
> But, even this one is looking for a persistence.xml file in my meta-inf
> directory. Otherwise there is an error like this shown after Tim's code. The
> error was produced by having a blank persistence.xml file. If I dont have a
> blank file, the project is throwing errors and does not run.
>
> Appreciate your help EclipseTeam!
>
> properties.put(PersistenceUnitProperties.TARGET_DATABASE, "Derby");
> properties.put(PersistenceUnitProperties.JDBC_DRIVER,
> "org.apache.derby.jdbc.ClientDriver");
> properties.put(PersistenceUnitProperties.JDBC_URL,
> "jdbc:derby://localhost:1527/sample;create=true");
> properties.put(PersistenceUnitProperties.JDBC_USER, "app");
> properties.put(PersistenceUnitProperties.JDBC_PASSWORD, "app");
> properties
> .put(PersistenceUnitProperties.JDBC_READ_CONNECTIONS_MIN, "1");
> properties.put(PersistenceUnitProperties.JDBC_WRITE_CONNECTIONS_MIN,
> "1");
> // properties.put(PersistenceUnitProperties.CACHE_SHARED_DEFAULT,
> // "true");
> properties.put(PersistenceUnitProperties.BATCH_WRITING, "JDBC");
> properties.put(PersistenceUnitProperties.CLASSLOADER,
> ComicsEntityManagerFactory.class.getClassLoader());
> properties.put("eclipselink.logging.level", "FINE");
> properties.put("eclipselink.logging.timestamp", "false");
> properties.put("eclipselink.logging.session", "false");
> properties.put("eclipselink.logging.thread", "false");
> emf = new PersistenceProvider().createEntityManagerFactory("comics",
> properties);
>
>
>
>
>
>
>
> Local Exception Stack:
>
> Exception [EclipseLink-30005] (Eclipse Persistence Services - 1.0.2 (Build
> 20081024)):
>
> org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
>
> Exception Description: An exception was thrown while searching for
> persistence archives with ClassLoader:
> sun.misc.Launcher$AppClassLoader@133056f
>
> Internal Exception: Exception [EclipseLink-30004] (Eclipse Persistence
> Services - 1.0.2 (Build 20081024)):
>
> org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
>
> Exception Description: An exception was thrown while processing
> persistence.xml from URL: file:/C:/workspace/Prototype/classes/
>
> Internal Exception:
>
> (1. Premature end of file.)
>
> at
> org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(
>
> PersistenceUnitLoadingException.java:121)
>
> at
> org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(
>
> PersistenceProvider.java:117)
>
> at
> org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(
>
> PersistenceProvider.java:64)
>
> at com.xx.entitymanager.EntityManagerProcessor.createEntityManagerFactory(
>
> EntityManagerProcessor.java:41)
>
> Caused by: Exception [EclipseLink-30004] (Eclipse Persistence Services -
> 1.0.2 (Build 20081024)):
> org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
>
> Exception Description: An exception was thrown while processing
> persistence.xml from URL: file:/C:/workspace/Prototype/classes/
>
> Internal Exception:
>
> (1. Premature end of file.)
>
> at
> org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionProcessingPersistenceXML(
>
> PersistenceUnitLoadingException.java:112)
>
> at
> org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processPersistenceXML(
>
> PersistenceUnitProcessor.java:365)
>
> at
> org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processPersistenceArchive(
>
> PersistenceUnitProcessor.java:314)
>
> at
> org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.getPersistenceUnits(
>
> PersistenceUnitProcessor.java:237)
>
> at
> org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.initPersistenceUnits(
>
> JPAInitializer.java:146)
>
> at
> org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.initialize(
>
> JPAInitializer.java:135)
>
> at
> org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(
>
> PersistenceProvider.java:104)
> ... 6 more
>
> --- On Thu, 1/29/09, Ben Horowitz <horowitz2@xxxxxxxx> wrote:
>
> From: Ben Horowitz <horowitz2@xxxxxxxx>
> Subject: Re: [eclipselink-users] How to create J2SE applications with no
> persistence.xml files
> To: krisusa123@xxxxxxxxx
> Date: Thursday, January 29, 2009, 7:43 PM
>
> You might want to try this (I haven't tried it, but I keep it in mind in
> case I need to use it):
>
> org.eclipse.persistence.jpa.PersistenceProvider has a method
> createContainerEntityManagerFactory that takes a PersistenceUnitInfo as an
> argument (as well as a map of properties).
>
> PersistenceUnitInfo is an interface that allows the specification of a
> list of managed class names.
>
> Good luck,
> Ben
>
>
> krisusa123 wrote:
>> Hi
>> I came into this rare problem of my app admins not ready to put files in
> META-INF directory to load persistence file.
>> I found this link from Doug explaining how to do this programatically.
> But he still used it finally to specify the following:
>> <persistence-unit name="unit-name">
>> <exclude-unlisted-classes>false</exclude-unlisted-classes>
>> </persistence-unit>
>> Is there any way we can specify these also programatically.
>> Reason: My persistence unit names change as per my environments and hence
> the requirement.
>> Appreciate your inputs.
>> Thanks in advance.
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> 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
>
>