Re: OpenEJB - Missing required persistence.xml

2008-02-18 Thread Karsten Ohme

David Blevins schrieb:

On Feb 16, 2008, at 1:38 PM, David Blevins wrote:



On Feb 16, 2008, at 1:22 PM, Karsten Ohme wrote:




On Feb 15, 2008, at 2:46 PM, Jacek Laskowski wrote:
> On Feb 15, 2008 2:37 PM, David Blevins <[EMAIL PROTECTED]> wrote:
>
>> The "Auto-commit" error usually means is that either a) only the 
jta-

>> data-source is configured in your persistence.xml so OpenJPA
>> incorrectly attempts to use it also as an non-jta-data-source, or b)
>> the non-jta-data-source specified is actually a jta-data-source 
(i.e.

>> a Resource where the 'JtaManaged' property isn't set to 'false')
>
> Hi Dave,
>
> He had non-jta-data-source only so I think his scenario's b).
... [show rest of quote]
As I described both a) and b) should be impossible in 3.0-beta-2, so
I'm still very baffled.  Has to be something else.


I will try again to send the source code as zipped attachment. The 
last times it was always impossible, because it was considered as 
spam. I will have access to the source on Monday again.


Great.  You can attach it here: 
http://issues.apache.org/jira/browse/OPENEJB-755


Sometimes the list refuses to accept attachments.



On Feb 18, 2008, at 1:57 AM, <[EMAIL PROTECTED]> 
<[EMAIL PROTECTED]> wrote:


I have attached the sample project on 
http://issues.apache.org/jira/browse/OPENEJB-755.


I got the OpenEJB test running smoothly in maven2 and attached a new 
zip.  I changed the subject of the jira issue as the zip provided did 
not replicate the "Auto-commit" error message.


Things I changed:
 - I did muck with your pom a bit, you don't need any of those changes 
and can revert back to your other pom -- though the javaee-api dep is a 
nice all in one dep.
 - Added a src/main/resources/META-INF/ejb-jar.xml file. Putting that 
file in src/test/resources doesn't work unless there are also beans you 
want picked up in your src/test/java dir.
 - Added managed and unmanaged datasources for your derby and mysql 
setups.  These will automatically get filled in as the values of 
jta-data-source and non-jta-data-source respectively, even if you didn't 
specify them in your persistence.xml.
 - Changed the persistence unit in the persistence.xml to 
transaction-type="TRANSACTION" (the default when unspecified).
 - Added a way for Hibernate to get the transaction manager from 
openejb.  There might be another way of doing this other than the 
persistence.xml.  I grabbed the hibernate source and am looking for a 
better way.  Might be as simple as making it a system property instead 
of a property in the persistence.xml, didn't try that.



At any rate, your named queries and persistence does work using hibernate.


Yes, great, it works at home. I'm quite confused. I have to try it again 
at work. Maybe your changes are after all important, maybe there are 
some problems with the imported JBoss libraries.


Thanks,
Karsten



-David





Re: OpenEJB - Missing required persistence.xml

2008-02-18 Thread David Blevins


On Feb 18, 2008, at 11:26 AM, David Blevins wrote:

- Added a way for Hibernate to get the transaction manager from  
openejb.  There might be another way of doing this other than the  
persistence.xml.  I grabbed the hibernate source and am looking for  
a better way.


Sumbitted a patch to hibernate:  
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3116

Feel encouraged to vote for it :)

-David



Re: OpenEJB - Missing required persistence.xml

2008-02-18 Thread David Blevins

On Feb 16, 2008, at 1:38 PM, David Blevins wrote:



On Feb 16, 2008, at 1:22 PM, Karsten Ohme wrote:




On Feb 15, 2008, at 2:46 PM, Jacek Laskowski wrote:
> On Feb 15, 2008 2:37 PM, David Blevins <[EMAIL PROTECTED]> wrote:
>
>> The "Auto-commit" error usually means is that either a) only  
the jta-

>> data-source is configured in your persistence.xml so OpenJPA
>> incorrectly attempts to use it also as an non-jta-data-source,  
or b)
>> the non-jta-data-source specified is actually a jta-data-source  
(i.e.

>> a Resource where the 'JtaManaged' property isn't set to 'false')
>
> Hi Dave,
>
> He had non-jta-data-source only so I think his scenario's b).
... [show rest of quote]
As I described both a) and b) should be impossible in 3.0-beta-2, so
I'm still very baffled.  Has to be something else.


I will try again to send the source code as zipped attachment. The  
last times it was always impossible, because it was considered as  
spam. I will have access to the source on Monday again.


Great.  You can attach it here: http://issues.apache.org/jira/browse/OPENEJB-755

Sometimes the list refuses to accept attachments.



On Feb 18, 2008, at 1:57 AM, <[EMAIL PROTECTED]> <[EMAIL PROTECTED] 
> wrote:


I have attached the sample project on http://issues.apache.org/jira/browse/OPENEJB-755 
.


I got the OpenEJB test running smoothly in maven2 and attached a new  
zip.  I changed the subject of the jira issue as the zip provided did  
not replicate the "Auto-commit" error message.


Things I changed:
 - I did muck with your pom a bit, you don't need any of those  
changes and can revert back to your other pom -- though the javaee-api  
dep is a nice all in one dep.
 - Added a src/main/resources/META-INF/ejb-jar.xml file. Putting that  
file in src/test/resources doesn't work unless there are also beans  
you want picked up in your src/test/java dir.
 - Added managed and unmanaged datasources for your derby and mysql  
setups.  These will automatically get filled in as the values of jta- 
data-source and non-jta-data-source respectively, even if you didn't  
specify them in your persistence.xml.
 - Changed the persistence unit in the persistence.xml to transaction- 
type="TRANSACTION" (the default when unspecified).
 - Added a way for Hibernate to get the transaction manager from  
openejb.  There might be another way of doing this other than the  
persistence.xml.  I grabbed the hibernate source and am looking for a  
better way.  Might be as simple as making it a system property instead  
of a property in the persistence.xml, didn't try that.



At any rate, your named queries and persistence does work using  
hibernate.



-David



Re: OpenEJB - Missing required persistence.xml

2008-02-18 Thread Karan Malhi
You should be able to . I have not tried it with eclipse, but typically
persistence frameworks use the non-jta one to alter your database schema for
you (Synchronize mappings). The problem here is that you have specified a
non-jta datasource, but not a jta datasource. I think it is OpenJpa with is
trying to treat it as "managed" (because it could not find a
 and then setting auto-commit to true on a connection
obtained from a "managed" resource (OpenJpa SchemaTool.run() method). See if
you can update your eclipse to the latest version through UpdateManager and
try adding  also.

On Feb 18, 2008 10:48 AM, <[EMAIL PROTECTED]> wrote:

> It is not possible to specify both  and
> . At least Eclipse complains.  only is
> not possible because of the exception thrown otherwise with Hibernate.
>
> Regards,
> Karsten
>
> -Ursprüngliche Nachricht-
> Von: Karan Malhi [mailto:[EMAIL PROTECTED]
> Gesendet: Montag, 18. Februar 2008 15:02
> An: users@openejb.apache.org
> Betreff: Re: OpenEJB - Missing required persistence.xml
>
> Did you try by adding a  also in persistence.xml ?
>
> On Feb 18, 2008 4:57 AM, <[EMAIL PROTECTED]> wrote:
>
> > I have attached the sample project on
> > http://issues.apache.org/jira/browse/OPENEJB-755.
> >
> > Thanks,
> > Karsten
> >
> > -Ursprüngliche Nachricht-
> > Von: David Blevins [mailto:[EMAIL PROTECTED]
> > Gesendet: Samstag, 16. Februar 2008 22:38
> > An: users@openejb.apache.org
> > Betreff: Re: OpenEJB - Missing required persistence.xml
> >
> >
> > On Feb 16, 2008, at 1:22 PM, Karsten Ohme wrote:
> >
> > >
> > >> On Feb 15, 2008, at 2:46 PM, Jacek Laskowski wrote:
> > >> > On Feb 15, 2008 2:37 PM, David Blevins <[EMAIL PROTECTED]> wrote:
> > >> >
> > >> >> The "Auto-commit" error usually means is that either a) only the
> > >> jta-
> > >> >> data-source is configured in your persistence.xml so OpenJPA
> > >> >> incorrectly attempts to use it also as an non-jta-data-source,
> > >> or b)
> > >> >> the non-jta-data-source specified is actually a jta-data-source
> > >> (i.e.
> > >> >> a Resource where the 'JtaManaged' property isn't set to 'false')
> > >> >
> > >> > Hi Dave,
> > >> >
> > >> > He had non-jta-data-source only so I think his scenario's b).
> > >> ... [show rest of quote]
> > >> As I described both a) and b) should be impossible in 3.0-beta-2, so
> > >> I'm still very baffled.  Has to be something else.
> > >
> > > I will try again to send the source code as zipped attachment. The
> > > last times it was always impossible, because it was considered as
> > > spam. I will have access to the source on Monday again.
> >
> > Great.  You can attach it here:
> > http://issues.apache.org/jira/browse/OPENEJB-755
> >
> > Sometimes the list refuses to accept attachments.
> >
> > -David
> >
> >
>
>
> --
> Karan Singh Malhi
>



-- 
Karan Singh Malhi


Re: OpenEJB - Missing required persistence.xml

2008-02-18 Thread Michael Dick
Hi Karsten,

You definitely should be able to specify both jta-data-source and
non-jta-data-source in persistence.xml. Are you using any plugins for
Eclipse which parse persistence.xml? I'm using Eclipse 3.3.1.1 with Dali and
it's not complaining for me.


On Feb 18, 2008 9:48 AM, <[EMAIL PROTECTED]> wrote:

> It is not possible to specify both  and
> . At least Eclipse complains.  only is
> not possible because of the exception thrown otherwise with Hibernate.
>
> Regards,
> Karsten
>
> -Ursprüngliche Nachricht-
> Von: Karan Malhi [mailto:[EMAIL PROTECTED]
> Gesendet: Montag, 18. Februar 2008 15:02
> An: users@openejb.apache.org
> Betreff: Re: OpenEJB - Missing required persistence.xml
>
> Did you try by adding a  also in persistence.xml ?
>
> On Feb 18, 2008 4:57 AM, <[EMAIL PROTECTED]> wrote:
>
> > I have attached the sample project on
> > http://issues.apache.org/jira/browse/OPENEJB-755.
> >
> > Thanks,
> > Karsten
> >
> > -Ursprüngliche Nachricht-
> > Von: David Blevins [mailto:[EMAIL PROTECTED]
> > Gesendet: Samstag, 16. Februar 2008 22:38
> > An: users@openejb.apache.org
> > Betreff: Re: OpenEJB - Missing required persistence.xml
> >
> >
> > On Feb 16, 2008, at 1:22 PM, Karsten Ohme wrote:
> >
> > >
> > >> On Feb 15, 2008, at 2:46 PM, Jacek Laskowski wrote:
> > >> > On Feb 15, 2008 2:37 PM, David Blevins <[EMAIL PROTECTED]> wrote:
> > >> >
> > >> >> The "Auto-commit" error usually means is that either a) only the
> > >> jta-
> > >> >> data-source is configured in your persistence.xml so OpenJPA
> > >> >> incorrectly attempts to use it also as an non-jta-data-source,
> > >> or b)
> > >> >> the non-jta-data-source specified is actually a jta-data-source
> > >> (i.e.
> > >> >> a Resource where the 'JtaManaged' property isn't set to 'false')
> > >> >
> > >> > Hi Dave,
> > >> >
> > >> > He had non-jta-data-source only so I think his scenario's b).
> > >> ... [show rest of quote]
> > >> As I described both a) and b) should be impossible in 3.0-beta-2, so
> > >> I'm still very baffled.  Has to be something else.
> > >
> > > I will try again to send the source code as zipped attachment. The
> > > last times it was always impossible, because it was considered as
> > > spam. I will have access to the source on Monday again.
> >
> > Great.  You can attach it here:
> > http://issues.apache.org/jira/browse/OPENEJB-755
> >
> > Sometimes the list refuses to accept attachments.
> >
> > -David
> >
> >
>
>
> --
> Karan Singh Malhi
>


Re: OpenEJB - Missing required persistence.xml

2008-02-18 Thread Karan Malhi
Did you try by adding a  also in persistence.xml ?

On Feb 18, 2008 4:57 AM, <[EMAIL PROTECTED]> wrote:

> I have attached the sample project on
> http://issues.apache.org/jira/browse/OPENEJB-755.
>
> Thanks,
> Karsten
>
> -Ursprüngliche Nachricht-
> Von: David Blevins [mailto:[EMAIL PROTECTED]
> Gesendet: Samstag, 16. Februar 2008 22:38
> An: users@openejb.apache.org
> Betreff: Re: OpenEJB - Missing required persistence.xml
>
>
> On Feb 16, 2008, at 1:22 PM, Karsten Ohme wrote:
>
> >
> >> On Feb 15, 2008, at 2:46 PM, Jacek Laskowski wrote:
> >> > On Feb 15, 2008 2:37 PM, David Blevins <[EMAIL PROTECTED]> wrote:
> >> >
> >> >> The "Auto-commit" error usually means is that either a) only the
> >> jta-
> >> >> data-source is configured in your persistence.xml so OpenJPA
> >> >> incorrectly attempts to use it also as an non-jta-data-source,
> >> or b)
> >> >> the non-jta-data-source specified is actually a jta-data-source
> >> (i.e.
> >> >> a Resource where the 'JtaManaged' property isn't set to 'false')
> >> >
> >> > Hi Dave,
> >> >
> >> > He had non-jta-data-source only so I think his scenario's b).
> >> ... [show rest of quote]
> >> As I described both a) and b) should be impossible in 3.0-beta-2, so
> >> I'm still very baffled.  Has to be something else.
> >
> > I will try again to send the source code as zipped attachment. The
> > last times it was always impossible, because it was considered as
> > spam. I will have access to the source on Monday again.
>
> Great.  You can attach it here:
> http://issues.apache.org/jira/browse/OPENEJB-755
>
> Sometimes the list refuses to accept attachments.
>
> -David
>
>


-- 
Karan Singh Malhi


Re: OpenEJB - Missing required persistence.xml

2008-02-16 Thread David Blevins


On Feb 16, 2008, at 1:22 PM, Karsten Ohme wrote:




On Feb 15, 2008, at 2:46 PM, Jacek Laskowski wrote:
> On Feb 15, 2008 2:37 PM, David Blevins <[EMAIL PROTECTED]> wrote:
>
>> The "Auto-commit" error usually means is that either a) only the  
jta-

>> data-source is configured in your persistence.xml so OpenJPA
>> incorrectly attempts to use it also as an non-jta-data-source,  
or b)
>> the non-jta-data-source specified is actually a jta-data-source  
(i.e.

>> a Resource where the 'JtaManaged' property isn't set to 'false')
>
> Hi Dave,
>
> He had non-jta-data-source only so I think his scenario's b).
... [show rest of quote]
As I described both a) and b) should be impossible in 3.0-beta-2, so
I'm still very baffled.  Has to be something else.


I will try again to send the source code as zipped attachment. The  
last times it was always impossible, because it was considered as  
spam. I will have access to the source on Monday again.


Great.  You can attach it here: http://issues.apache.org/jira/browse/OPENEJB-755

Sometimes the list refuses to accept attachments.

-David



Re: OpenEJB - Missing required persistence.xml

2008-02-16 Thread Karsten Ohme



On Feb 15, 2008, at 2:46 PM, Jacek Laskowski wrote:

 > On Feb 15, 2008 2:37 PM, David Blevins <[EMAIL PROTECTED]> wrote:
 >
 >> The "Auto-commit" error usually means is that either a) only the jta-
 >> data-source is configured in your persistence.xml so OpenJPA
 >> incorrectly attempts to use it also as an non-jta-data-source, or b)
 >> the non-jta-data-source specified is actually a jta-data-source (i.e.
 >> a Resource where the 'JtaManaged' property isn't set to 'false')
 >
 > Hi Dave,
 >
 > He had non-jta-data-source only so I think his scenario's b).
... [show rest of quote]

As I described both a) and b) should be impossible in 3.0-beta-2, so
I'm still very baffled.  Has to be something else.


I will try again to send the source code as zipped attachment. The last 
times it was always impossible, because it was considered as spam. I 
will have access to the source on Monday again.


Thanks,
Karsten



-David





Re: OpenEJB - Missing required persistence.xml

2008-02-16 Thread Karsten Ohme

>On Fri, Feb 15, 2008 at 9:36 AM,  <[EMAIL PROTECTED]> wrote:
>
>>  
>>  >
>> 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";>
>> >transaction-type="RESOURCE_LOCAL">
>> 
>org.hibernate.ejb.HibernatePersistence

>
>Remove provider so OpenJPA kicks in. It actually did, but provider
>might confuse it or openejb. Don't really know. Add 
>with the same value as . Remove transaction-type
>element.

OpenJPA was not working, so I had to use Hibernate. I would also like to 
use Hibernate, because the final persistence layer should be Hibernate. 
There also some older Springs dependencies, so if the database layout is 
not 100 % identical it does matter.


The transaction type element was necessary because of an error with 
Hibernate:


See JTA Transaction Manager topic at 
http://www.abcseo.com/tech/java/jboss-ebj-troubleshooting


>What's in 
>foo.bar.testfacade.TestFacadeImplOpenEJBTest.testPersistStrecke(TestFacadeImplOpenEJBTest.java:103)?


It is a call to a stateless bean. The Bean call persist() like this :

public void persistStrecke(Strecke s) {
 em.persist(s)
}

>Jacek
>
>--
>Jacek Laskowski
>http://www.JacekLaskowski.pl

Thanks,
Karsten




Re: OpenEJB - Missing required persistence.xml

2008-02-15 Thread David Blevins


On Feb 15, 2008, at 2:46 PM, Jacek Laskowski wrote:


On Feb 15, 2008 2:37 PM, David Blevins <[EMAIL PROTECTED]> wrote:


The "Auto-commit" error usually means is that either a) only the jta-
data-source is configured in your persistence.xml so OpenJPA
incorrectly attempts to use it also as an non-jta-data-source, or b)
the non-jta-data-source specified is actually a jta-data-source (i.e.
a Resource where the 'JtaManaged' property isn't set to 'false')


Hi Dave,

He had non-jta-data-source only so I think his scenario's b).


As I described both a) and b) should be impossible in 3.0-beta-2, so  
I'm still very baffled.  Has to be something else.


-David



Re: OpenEJB - Missing required persistence.xml

2008-02-15 Thread David Blevins


On Feb 15, 2008, at 9:36 AM, <[EMAIL PROTECTED]> <[EMAIL PROTECTED] 
> wrote:



Hi,

well it works now. Because I have changed the persistence provider  
to Hibernate. The problem now is that entities are not persisted.  
persist() simply does nothing. But no error is shown.


The persistence.xml is as follows. I have also a full log of the  
whole Hibernate. I cannot find an error.



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 
">
	type="RESOURCE_LOCAL">

org.hibernate.ejb.HibernatePersistence

java:jdbc/DerbyDatabase









I'd definitely use transaction-type="TRANSACTION" instead of  
transaction-type="RESOURCE_LOCAL" with either OpenJPA or Hibernate.   
RESOURCE_LOCAL is very difficult to use and transaction- 
type="TRANSACTION" is not slow like people normally think.  At the  
very least, start with the default of transaction-type="TRANSACTION",  
get that to work and switch it later if it's still important.


Regardless of if you use transaction-type="RESOURCE_LOCAL" or  
transaction-type="TRANSACTION" you definitely should supply both data-source> and .


The DataSource for the jta-data-source should always have it's  
'JtaManaged' property set to 'true' (this is the default)
The DataSource for the non-jta-data-source should always have it's  
'JtaManaged' property set to 'false'.


In your test code, you could do it like this:


  if (DB_MODE == MYSQL) {
  properties.setProperty("MySqlDatabase", "new://Resource? 
type=DataSource");
  properties.setProperty("MySqlDatabase.JdbcUrl",  
"jdbc:mysql://localhost:3306/tpg-server");
  properties.setProperty("MySqlDatabase.JdbcDriver",  
"com.mysql.jdbc.Driver");

  properties.setProperty("MySqlDatabase.UserName", "tpg");
  properties.setProperty("MySqlDatabase.Password", "tpg");

  properties.setProperty("MySqlDatabaseUnmanaged", "new:// 
Resource?type=DataSource");
  properties.setProperty("MySqlDatabaseUnmanaged.JdbcUrl",  
"jdbc:mysql://localhost:3306/tpg-server");
  properties.setProperty("MySqlDatabaseUnmanaged.JdbcDriver",  
"com.mysql.jdbc.Driver");
  properties.setProperty("MySqlDatabaseUnmanaged.UserName",  
"tpg");
  properties.setProperty("MySqlDatabaseUnmanaged.Password",  
"tpg");
  properties.setProperty("MySqlDatabaseUnmanaged.JtaManaged",  
"false");

  } else if (DB_MODE == DERBY) {
  properties.setProperty("DerbyDatabase", "new://Resource? 
type=DataSource");
  properties.setProperty("DerbyDatabase.JdbcUrl",  
"jdbc:derby:derbyDB;create=true");
  properties.setProperty("DerbyDatabase.JdbcDriver",  
"org.apache.derby.jdbc.EmbeddedDriver");


  properties.setProperty("DerbyDatabaseUnmanaged", "new:// 
Resource?type=DataSource");
  properties.setProperty("DerbyDatabaseUnmanaged.JdbcUrl",  
"jdbc:derby:derbyDB;create=true");
  properties.setProperty("DerbyDatabaseUnmanaged.JdbcDriver",  
"org.apache.derby.jdbc.EmbeddedDriver");
  properties.setProperty("DerbyDatabaseUnmanaged.JtaManaged",  
"false");

  }


-David




Re: OpenEJB - Missing required persistence.xml

2008-02-15 Thread Jacek Laskowski
On Feb 15, 2008 2:37 PM, David Blevins <[EMAIL PROTECTED]> wrote:

> The "Auto-commit" error usually means is that either a) only the jta-
> data-source is configured in your persistence.xml so OpenJPA
> incorrectly attempts to use it also as an non-jta-data-source, or b)
> the non-jta-data-source specified is actually a jta-data-source (i.e.
> a Resource where the 'JtaManaged' property isn't set to 'false')

Hi Dave,

He had non-jta-data-source only so I think his scenario's b).

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl


Re: OpenEJB - Missing required persistence.xml

2008-02-15 Thread David Blevins


On Feb 15, 2008, at 4:03 AM, <[EMAIL PROTECTED]> <[EMAIL PROTECTED] 
> wrote:



Not working, the tables are not created. Now I get this:

Auto-commit can not be set while enrolled in a transaction



I'm very interested in how you got this error so I can fix any related  
checks we have.  In 3.0-beta-2 I attempted to make it impossible to  
get this error -- apparently unsuccessfully :)


Info that will help:
 - the persistence.xml
 - let me know if you're using PersistenceContextType.TRANSACTION  
(default) or PersistenceContextType.EXTENDED in your  
@PersistenceContext annotation
 - the openejb log output so I can see what kind of configuration  
ended up getting used.

 - your test setup code


The "Auto-commit" error usually means is that either a) only the jta- 
data-source is configured in your persistence.xml so OpenJPA  
incorrectly attempts to use it also as an non-jta-data-source, or b)  
the non-jta-data-source specified is actually a jta-data-source (i.e.  
a Resource where the 'JtaManaged' property isn't set to 'false')


In 3.0-beta-2 it's impossible to set jta-data-source to a  
JtaManaged=false Resource or to set the non-jta-data-source to a  
JtaManaged=true Resource.  Also, if you don't supply either jta-data- 
source or non-jta-data-source, we will create Resources for you with  
their JtaManaged property set accordingly, and set them as the value  
of jta-data-source or non-jta-data-source, so it's also impossible to  
not have them filled in as we will fill them in when you haven't.  The  
thing I've noticed in the code now is that our "make a managed/ 
unmanaged datasource for you" code could be smarter and needs to be  
improved -- it should take the one you defined (if there is one), copy  
it, set the JtaManaged flag accordingly, then use that.


As an FYI, I've been taking all these exchanges and using them to help  
fill out the docs:


  http://cwiki.apache.org/OPENEJBx30/jpa-usage.html
  http://cwiki.apache.org/OPENEJBx30/openjpa.html

I have an empty Hibernate doc waiting in the wing:

  http://cwiki.apache.org/OPENEJBx30/hibernate.html

-David



Re: OpenEJB - Missing required persistence.xml

2008-02-15 Thread Jacek Laskowski
On Fri, Feb 15, 2008 at 9:36 AM,  <[EMAIL PROTECTED]> wrote:

>  
>  
> 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";>
>  transaction-type="RESOURCE_LOCAL">
> org.hibernate.ejb.HibernatePersistence

Remove provider so OpenJPA kicks in. It actually did, but provider
might confuse it or openejb. Don't really know. Add 
with the same value as . Remove transaction-type
element.

What's in 
foo.bar.testfacade.TestFacadeImplOpenEJBTest.testPersistStrecke(TestFacadeImplOpenEJBTest.java:103)?

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl


Re: OpenEJB - Missing required persistence.xml

2008-02-15 Thread Karsten.Ohme
Hi,

well it works now. Because I have changed the persistence provider to 
Hibernate. The problem now is that entities are not persisted. persist() simply 
does nothing. But no error is shown.

The persistence.xml is as follows. I have also a full log of the whole 
Hibernate. I cannot find an error.


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";>

org.hibernate.ejb.HibernatePersistence

java:jdbc/DerbyDatabase








The log:

DEBUG - opened session at timestamp: 12030966900
DEBUG - id unsaved-value: 0
DEBUG - transient instance of: foo.bar.testfacade.model.Strecke
DEBUG - saving transient instance
DEBUG - saving [foo.bar.testfacade.model.Strecke#]
DEBUG - processing cascade ACTION_PERSIST for: foo.bar.testfacade.model.Strecke
DEBUG - done processing cascade ACTION_PERSIST for: 
foo.bar.testfacade.model.Strecke
DEBUG - Wrapped collection in role: foo.bar.testfacade.model.Strecke.punkte
DEBUG - delaying identity-insert due to no transaction in progress
DEBUG - processing cascade ACTION_PERSIST for: foo.bar.testfacade.model.Strecke
DEBUG - cascade ACTION_PERSIST for collection: 
foo.bar.testfacade.model.Strecke.punkte
DEBUG - cascading to persist: foo.bar.testfacade.model.Punkt
DEBUG - id unsaved-value: 0
DEBUG - transient instance of: foo.bar.testfacade.model.Punkt
DEBUG - saving transient instance
DEBUG - saving [foo.bar.testfacade.model.Punkt#]
DEBUG - delaying identity-insert due to no transaction in progress
DEBUG - cascading to persist: foo.bar.testfacade.model.Punkt
DEBUG - id unsaved-value: 0
DEBUG - transient instance of: foo.bar.testfacade.model.Punkt
DEBUG - saving transient instance
DEBUG - saving [foo.bar.testfacade.model.Punkt#]
DEBUG - delaying identity-insert due to no transaction in progress
DEBUG - cascading to persist: foo.bar.testfacade.model.Punkt
DEBUG - id unsaved-value: 0
DEBUG - transient instance of: foo.bar.testfacade.model.Punkt
DEBUG - saving transient instance
DEBUG - saving [foo.bar.testfacade.model.Punkt#]
DEBUG - delaying identity-insert due to no transaction in progress
DEBUG - cascading to persist: foo.bar.testfacade.model.Punkt
DEBUG - id unsaved-value: 0
DEBUG - transient instance of: foo.bar.testfacade.model.Punkt
DEBUG - saving transient instance
DEBUG - saving [foo.bar.testfacade.model.Punkt#]
DEBUG - delaying identity-insert due to no transaction in progress
DEBUG - cascading to persist: foo.bar.testfacade.model.Punkt
DEBUG - id unsaved-value: 0
DEBUG - transient instance of: foo.bar.testfacade.model.Punkt
DEBUG - saving transient instance
DEBUG - saving [foo.bar.testfacade.model.Punkt#]
DEBUG - delaying identity-insert due to no transaction in progress
DEBUG - done cascade ACTION_PERSIST for collection: 
foo.bar.testfacade.model.Strecke.punkte
DEBUG - done processing cascade ACTION_PERSIST for: 
foo.bar.testfacade.model.Strecke
DEBUG - closing session
DEBUG - connection already null in cleanup : no action


Re: OpenEJB - Missing required persistence.xml

2008-02-15 Thread Karsten.Ohme
Not working, the tables are not created. Now I get this:

Auto-commit can not be set while enrolled in a transaction

javax.ejb.EJBException: The bean encountered a non-application exception.; 
nested exception is: 
 
org.apache.openjpa.persistence.PersistenceException: Auto-commit can not be set 
while enrolled in a transaction
at 
org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException(BaseEjbProxyHandler.java:366)
at 
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:251)
at 
org.apache.openejb.util.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
at $Proxy29.persistStrecke(Unknown Source)
at 
foo.bar.testfacade.TestFacadeImplOpenEJBTest.testPersistStrecke(TestFacadeImplOpenEJBTest.java:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
at 
org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
at 
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at 
org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
at 
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at 
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at 
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at 
org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at 
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by:  
org.apache.openjpa.persistence.PersistenceException: Auto-commit can not be set 
while enrolled in a transaction
at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:549)
at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:449)
at 
org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:170)
at 
org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:130)
at 
org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:186)
at 
org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
at 
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
at 
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
at 
org.apache.openejb.persistence.JtaEntityManagerRegistry.getEntityManager(JtaEntityManagerRegistry.java:105)
at 
org.apache.openejb.persistence.JtaEntityManager.getEntityManager(JtaEntityManager.java:61)
at 
org.apache.openejb.persistence.JtaEntityManager.persist(JtaEntityManager.java:97)
at 
foo.bar.testfacade.TestFacadeImpl.persistStrecke(TestFacadeImpl.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at 
org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:146)
at 
org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:129)
at 
org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:67)
at 
org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:210)
at 
org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.ja

Re: OpenEJB - Missing required persistence.xml

2008-02-14 Thread David Blevins


On Feb 14, 2008, at 6:29 AM, <[EMAIL PROTECTED]> <[EMAIL PROTECTED] 
> wrote:



Thanks a lot again, I have now made one errors progress:

Now the problem seems to be that the entities in the database are  
not automatically created. Is this possible or do I have to do it on  
my own?


Thanks,
Karsten

javax.ejb.EJBException: The bean encountered a non-application  
exception.; nested exception is:
	  
org.apache.openjpa.persistence.ArgumentException: Table 'tpg- 
server.strecke' doesn't exist {prepstmnt 5511938 SELECT t0.id,  
t0.name FROM strecke t0 WHERE (t0.name = ?) [params=(String) Meine  
Strecke]} [code=1146, state=42S02]


Excellent.  You're through all the hard stuff.  This error here is  
because the tables don't exist, which is very easy to fix.  In your  
persistence.xml file add the following OpenJPA specific property:


http://java.sun.com/xml/ns/persistence";  
version="1.0">


  



  value="buildSchema(ForeignKeys=true)"/>


  


What this is going to do is tell OpenJPA to auto-create all your  
tables, all your primary keys and all foreign keys exactly to match  
your objects. A very excellent feature indeed.


You should be all set.

A warning in advance for any new JPA user, by default all objects will  
detach at the end of a transaction; people typically discover this  
when the go to remove or update an object they fetched previously and  
get an exception like "You cannot perform operation delete on detached  
object".  The part that's sneaky is that a test case has no  
transaction, so unless specified otherwise a transaction will start  
and complete around each ejb method call and then as a result  
persistent objects passed back as return values will detach.


There are a couple ways to deal with that.

The first is to use PersistenceContextType.EXTENDED for EntityManager  
refs instead of the default of PersistenceContextType.TRANSACTION.   
The "injection-of-entitymanager" example in our examples zip shows how  
to do that.  (it's also available here: http://svn.apache.org/repos/asf/openejb/tags/openejb-3.0-beta-2/examples/injection-of-entitymanager/)


The second is to use a technique to execute transactions in your test  
code.  That's described here:  http://openejb.apache.org/3.0/unit-testing-transactions.html



-David



Re: OpenEJB - Missing required persistence.xml

2008-02-14 Thread Jacek Laskowski
On Thu, Feb 14, 2008 at 6:29 AM,  <[EMAIL PROTECTED]> wrote:

>  Now the problem seems to be that the entities in the database are not 
> automatically created. Is this possible or do I have to do it on my own?

What do you mean by "not automatically created"? If you execute
EntityManager.persist() method they should be there. If they are not,
that's the issue. Without persist you should not expect to see any
entities in the db unless you execute sql scripts or something to put
them in.

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl


RE: OpenEJB - Missing required persistence.xml

2008-02-14 Thread Karsten.Ohme
Thanks a lot again, I have now made one errors progress:

Now the problem seems to be that the entities in the database are not 
automatically created. Is this possible or do I have to do it on my own?

Thanks,
Karsten

javax.ejb.EJBException: The bean encountered a non-application exception.; 
nested exception is: 
 
org.apache.openjpa.persistence.ArgumentException: Table 'tpg-server.strecke' 
doesn't exist {prepstmnt 5511938 SELECT t0.id, t0.name FROM strecke t0 WHERE 
(t0.name = ?) [params=(String) Meine Strecke]} [code=1146, state=42S02]
at 
org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException(BaseEjbProxyHandler.java:366)
at 
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:251)
at 
org.apache.openejb.util.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
at $Proxy29.findStrecke(Unknown Source)
at 
foo.bar.testfacade.TestFacadeImplOpenEJBTest.testFindStrecke(TestFacadeImplOpenEJBTest.java:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
at 
org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
at 
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at 
org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
at 
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at 
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at 
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at 
org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at 
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by:  
org.apache.openjpa.persistence.ArgumentException: Table 'tpg-server.strecke' 
doesn't exist {prepstmnt 5511938 SELECT t0.id, t0.name FROM strecke t0 WHERE 
(t0.name = ?) [params=(String) Meine Strecke]} [code=1146, state=42S02]
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:851)
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:773)
at 
org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:525)
at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:237)
at 
org.apache.openjpa.persistence.QueryImpl.getSingleResult(QueryImpl.java:300)
at foo.bar.testfacade.TestFacadeImpl.findStrecke(TestFacadeImpl.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at 
org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:146)
at 
org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:129)
at 
org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:67)
at 
org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:210)
at 
org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:188)
at 
org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:165)
at 
org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:217)
at 
org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:77)
at 
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:245)

Re: OpenEJB - Missing required persistence.xml

2008-02-13 Thread David Blevins


On Feb 13, 2008, at 6:26 AM, <[EMAIL PROTECTED]> <[EMAIL PROTECTED] 
> wrote:



I get:

Apache OpenEJB 3.0-beta-2build: 20080131-03:38
http://openejb.apache.org/
- openejb.home = C:\workspace\TestFacade\target
- openejb.base = C:\workspace\TestFacade\target
- Configuring Service(id=Default Security Service,  
type=SecurityService, provider-id=Default Security Service)
- Configuring Service(id=Default Transaction Manager,  
type=TransactionManager, provider-id=Default Transaction Manager)
- Configuring Service(id=My DataSource, type=Resource, provider- 
id=Default JDBC Database)
- Configuring Service(id=My Unmanaged DataSource, type=Resource,  
provider-id=Default JDBC Database)
- Configuring Service(id=My JMS Resource Adapter, type=Resource,  
provider-id=Default JMS Resource Adapter)
- Configuring Service(id=My JMS Connection Factory, type=Resource,  
provider-id=Default JMS Connection Factory)
- Configuring Service(id=Default JDK 1.3 ProxyFactory,  
type=ProxyFactory, provider-id=Default JDK 1.3 ProxyFactory)
- Configuring Service(id=My CMP Container, type=Container, provider- 
id=Default CMP Container)
- Configuring Service(id=My BMP Container, type=Container, provider- 
id=Default BMP Container)
- Configuring Service(id=My Stateful Container, type=Container,  
provider-id=Default Stateful Container)
- Configuring Service(id=My Stateless Container, type=Container,  
provider-id=Default Stateless Container)
- Configuring Service(id=My MDB Container , type=Container, provider- 
id=Default MDB Container)

[...]


For some strange reason when I was editing and using the openejb.xml  
the error was different; the tables in the database were not created.




Based on that output, it looks like you've got a 'conf' directory  
under 'C:\workspace\TestFacade\target'.  When we see one of those, we  
unpack a complete setup of security, logging, and an openejb.xml  
file.  You can either delete the conf directory or simply put an  
openejb.xml file in there containing nothing more than "" as  
openejb will never overwrite it if it sees one is there (same with all  
the files in conf/).  If you delete the conf/ directory we try and  
tailor things a bit more for embedded testing; mostly shorter log  
lines with no date/time, as well we try and stop activemq and hsqldb  
from writing files to your disk that would have to be cleaned up  
manually.



   @Before
   public void initContext() throws Exception {
   Properties properties = new Properties();
   properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,

"org.apache.openejb.client.LocalInitialContextFactory");


   if (DB_MODE == MYSQL) {
   properties.setProperty("Default\\ JDBC\\  
Database.Password", "tpg");

   properties.setProperty("Default\\ JDBC\\ Database.JdbcUrl",
   "jdbc:mysql://localhost:3306/tpg-server");
   properties.setProperty("Default\\ JDBC\\  
Database.JdbcDriver",

   "com.mysql.jdbc.Driver");
   properties.setProperty("Default\\ JDBC\\  
Database.UserName", "tpg");

   properties.setProperty(
   "Default\\ JDBC\\ Database.ConnectionInterface",
   "javax.sql.DataSource");
   }
   if (DB_MODE == DERBY) {
   properties.setProperty("Default\\ JDBC\\ Database.JdbcUrl",
   "jdbc:derby:derbyDB;create=true");
   properties.setProperty("Default\\ JDBC\\  
Database.JdbcDriver",

   "org.apache.derby.jdbc.EmbeddedDriver");
   properties.setProperty(
   "Default\\ JDBC\\ Database.ConnectionInterface",
   "javax.sql.DataSource");
   }

   InitialContext initialContext = new InitialContext(properties);
   Object ref =  
initialContext.lookup(TestFacadeImpl.class.getSimpleName()

   + "Remote");
   service = (TestFacade) ref;
   }


That's a cool trick.  I never thought of doing that.  You need to  
remove the '\\' as java.util.Properties won't do any escaping on  
setProperties.  The escaping only happens when properties data is read  
from a text file or an xml -- and in each situation the escaping rules  
are different.


I'd definitely use the 'new://Resource' syntax i showed you and shy  
away from using "Default JDBC Database" as the resource name.  Reason  
being is that it will be much easier to see if your setup is working  
or not.  You could use the same name for your DERBY and MYSQL  
Resources, but I'd use different, more descriptive names so that it's  
easier to see with certainty via the log output which is getting used.


Something like this would be most reliable:

   if (DB_MODE == MYSQL) {
   properties.setProperty("MySqlDatabase", "new://Resource? 
type=DataSource");
   properties.setProperty("MySqlDatabase.JdbcUrl",  
"jdbc:mysql://localhost:3306/tpg-server");
   properties.setProperty("MySqlDatabase.JdbcDriver",  
"com.mysql.jdbc.Driver");

   

Re: OpenEJB - Missing required persistence.xml

2008-02-13 Thread Jacek Laskowski
On Feb 13, 2008 6:26 AM,  <[EMAIL PROTECTED]> wrote:

> - Unexpected exception from beforeCompletion; transaction will roll back
>  
> org.apache.openjpa.persistence.PersistenceException: null
> at 
> org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq.getConnection(AbstractJDBCSeq.java:162)
> at 
> org.apache.openjpa.jdbc.kernel.TableJDBCSeq.allocateSequence(TableJDBCSeq.java:366)
> at 
> org.apache.openjpa.jdbc.kernel.TableJDBCSeq.nextInternal(TableJDBCSeq.java:266)
> at 
> org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq.next(AbstractJDBCSeq.java:60)

I guess it's because of your invalid persistence.xml setting for
java:/DefaultDS. Did you change it?
I think it should be My DataSource.

Jacek


-- 
Jacek Laskowski
http://www.JacekLaskowski.pl


RE: OpenEJB - Missing required persistence.xml

2008-02-13 Thread Karsten.Ohme
)
Caused by: javax.transaction.SystemException
at 
org.apache.openjpa.ee.RegistryManagedRuntime$TransactionManagerRegistryFacade.suspend(RegistryManagedRuntime.java:176)
at 
org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq.getConnection(AbstractJDBCSeq.java:158)
... 55 more


For some strange reason when I was editing and using the openejb.xml the error 
was different; the tables in the database were not created.


Thanks,
Karsten

-----Ursprüngliche Nachricht-
Von: David Blevins [mailto:[EMAIL PROTECTED] 
Gesendet: Mittwoch, 13. Februar 2008 00:54
An: users@openejb.apache.org
Betreff: Re: OpenEJB - Missing required persistence.xml

It seems like what's happening is eclipse isn't configured to copy in  
the src/*/resources files into the related build output directories.

To see if I could replicate the issue, I grabbed our injection-of- 
entitymanager example from the examples zip and generated an eclipse  
project for it using 'mvn eclipse:eclipse' on the command line.  Then  
I added the M2_REPO variable[1].  When it asked me if I wanted to  
rebuild everything I said yes.  After I was able to run the test case  
in eclipse.

Here's the relevant part of my .classpath file when all that was done:

   
   
   
   

The goal is that "src/main/java" and "src/main/resources" should  
output into "target/classes".  And "src/test/java" and "src/test/ 
resources" should output into "target/test-classes".  If both of those  
happen correctly, you shouldn't need any  entries in your  
openejb.xml file at all.

If you can post your .classpath file for pattern-management-impl  
that'd be great.

On a side note, you can configure data sources from within your test  
case (and delete your openejb.xml entirely) like so:

 Properties p = new Properties();
 p.put(Context.INITIAL_CONTEXT_FACTORY,  
"org.apache.openejb.client.LocalInitialContextFactory");

 p.put("myDataSource", "new://Connector?type=DataSource");
 p.put("myDataSource.JdbcDriver",  
"org.apache.derby.jdbc.EmbeddedDriver");
 p.put("myDataSource.JdbcUrl",  
"jdbc:derby:derbyDB;create=true");

 Context context = new InitialContext(p);

-David

[1]  http://people.apache.org/~dblevins/eclipse-howto/new-variable.tiff

On Feb 11, 2008, at 10:34 AM, <[EMAIL PROTECTED]> <[EMAIL PROTECTED] 
 > wrote:

> Hi,
>
> I'm experimenting for one day with OpenEJB 3.0-beta-2, but I'm  
> stuck. I
> have tried different approaches to test EJBs, ejb3unit, JBoss
> embeddable, but OpenEJB seems to be the best, although it also does  
> not
> work for me.
>
> I always get a
>
> - FAIL ... PatternManagementDaoImpl:  Missing required persistence.xml
> for @PersistenceContext ref "em" to unit "pattern-managementPu"
>
> What's wrong? It is there. And where should it be placed? In META-INF
> like usually? It seems that it is later found.
>
> What I want to do is to use an Apache Derby database (in memory) which
> is automatically initilialized. What do I have to define and where,  
> that
> this works?
>
> Can I define the order in which the EJB modules are loaded?
>
> Thanks,
> Karsten
>
> Apache OpenEJB 3.0-beta-2build: 20080131-03:38
> http://openejb.apache.org/
> - openejb.home = C:\workspace\pattern-management\pattern-management- 
> impl
> - openejb.base = C:\workspace\pattern-management\pattern-management- 
> impl
> - Configuring Service(id=Default Security Service,  
> type=SecurityService,
> provider-id=Default Security Service)
> - Configuring Service(id=Default Transaction Manager,
> type=TransactionManager, provider-id=Default Transaction Manager)
> - Configuring Service(id=Derby Database, type=Resource,
> provider-id=Default JDBC Database)
> - Configuring Service(id=Default JDK 1.3 ProxyFactory,
> type=ProxyFactory, provider-id=Default JDK 1.3 ProxyFactory)
> - Configuring Service(id=Default Stateless Container, type=Container,
> provider-id=Default Stateless Container)
> - Found EjbModule in classpath:
> C:\workspace\pattern-management\pattern-management-impl\src\main 
> \resourc
> es
> - Found EjbModule in classpath:
> C:\workspace\pattern-management\pattern-management-impl\src\test 
> \resourc
> es
> - Configuring app:
> C:\workspace\networkstorage-management\networkstorage-management-impl 
> \ta
> rget\classes
> - Loaded Module:
> C:\workspace\networkstorage-management\networkstorage-management-impl 
> \ta
> rget\classes
> - Configuring app:
> C:\workspace\pattern-management\pattern-management-impl\target\classes
> - FAIL ... PatternManagementDaoImpl:  Missing required persistence.xml
> for @PersistenceCo

Re: OpenEJB - Missing required persistence.xml

2008-02-12 Thread David Blevins
It seems like what's happening is eclipse isn't configured to copy in  
the src/*/resources files into the related build output directories.


To see if I could replicate the issue, I grabbed our injection-of- 
entitymanager example from the examples zip and generated an eclipse  
project for it using 'mvn eclipse:eclipse' on the command line.  Then  
I added the M2_REPO variable[1].  When it asked me if I wanted to  
rebuild everything I said yes.  After I was able to run the test case  
in eclipse.


Here's the relevant part of my .classpath file when all that was done:

  
  
  

  

The goal is that "src/main/java" and "src/main/resources" should  
output into "target/classes".  And "src/test/java" and "src/test/ 
resources" should output into "target/test-classes".  If both of those  
happen correctly, you shouldn't need any  entries in your  
openejb.xml file at all.


If you can post your .classpath file for pattern-management-impl  
that'd be great.


On a side note, you can configure data sources from within your test  
case (and delete your openejb.xml entirely) like so:


Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,  
"org.apache.openejb.client.LocalInitialContextFactory");


p.put("myDataSource", "new://Connector?type=DataSource");
p.put("myDataSource.JdbcDriver",  
"org.apache.derby.jdbc.EmbeddedDriver");
p.put("myDataSource.JdbcUrl",  
"jdbc:derby:derbyDB;create=true");


Context context = new InitialContext(p);

-David

[1]  http://people.apache.org/~dblevins/eclipse-howto/new-variable.tiff

On Feb 11, 2008, at 10:34 AM, <[EMAIL PROTECTED]> <[EMAIL PROTECTED] 
> wrote:



Hi,

I'm experimenting for one day with OpenEJB 3.0-beta-2, but I'm  
stuck. I

have tried different approaches to test EJBs, ejb3unit, JBoss
embeddable, but OpenEJB seems to be the best, although it also does  
not

work for me.

I always get a

- FAIL ... PatternManagementDaoImpl:Missing required persistence.xml
for @PersistenceContext ref "em" to unit "pattern-managementPu"

What's wrong? It is there. And where should it be placed? In META-INF
like usually? It seems that it is later found.

What I want to do is to use an Apache Derby database (in memory) which
is automatically initilialized. What do I have to define and where,  
that

this works?

Can I define the order in which the EJB modules are loaded?

Thanks,
Karsten

Apache OpenEJB 3.0-beta-2build: 20080131-03:38
http://openejb.apache.org/
- openejb.home = C:\workspace\pattern-management\pattern-management- 
impl
- openejb.base = C:\workspace\pattern-management\pattern-management- 
impl
- Configuring Service(id=Default Security Service,  
type=SecurityService,

provider-id=Default Security Service)
- Configuring Service(id=Default Transaction Manager,
type=TransactionManager, provider-id=Default Transaction Manager)
- Configuring Service(id=Derby Database, type=Resource,
provider-id=Default JDBC Database)
- Configuring Service(id=Default JDK 1.3 ProxyFactory,
type=ProxyFactory, provider-id=Default JDK 1.3 ProxyFactory)
- Configuring Service(id=Default Stateless Container, type=Container,
provider-id=Default Stateless Container)
- Found EjbModule in classpath:
C:\workspace\pattern-management\pattern-management-impl\src\main 
\resourc

es
- Found EjbModule in classpath:
C:\workspace\pattern-management\pattern-management-impl\src\test 
\resourc

es
- Configuring app:
C:\workspace\networkstorage-management\networkstorage-management-impl 
\ta

rget\classes
- Loaded Module:
C:\workspace\networkstorage-management\networkstorage-management-impl 
\ta

rget\classes
- Configuring app:
C:\workspace\pattern-management\pattern-management-impl\target\classes
- FAIL ... PatternManagementDaoImpl:Missing required persistence.xml
for @PersistenceContext ref "em" to unit "pattern-managementPu"
- FAIL ... TestFacadeImpl:  Missing required persistence.xml for
@PersistenceContext ref "em" to unit "pattern-managementPu"
- Jar not loaded.
C:\workspace\pattern-management\pattern-management-impl\target 
\classes.

Module failed validation.
AppModule(path=C:\workspace\pattern-management\pattern-management- 
impl\t

arget\classes)
- Configuring app:
C:\workspace\pattern-management\pattern-management-impl\src\main 
\resourc

es
- Configuring PersistenceUnit(name=pattern-managementPu,  
provider=null)

- Loaded Module:
C:\workspace\pattern-management\pattern-management-impl\src\main 
\resourc

es
- Configuring app:
C:\workspace\pattern-management\pattern-management-impl\src\test 
\resourc

es
- Configuring PersistenceUnit(name=pattern-managementPu,  
provider=null)

- Loaded Module:
C:\workspace\pattern-management\pattern-management-impl\src\test 
\resourc

es
- Creating ProxyFactory(id=Default JDK 1.3 ProxyFactory)
- Creating TransactionManager(id=Default Transaction Manager)
- Creating SecurityService(id=Default Security Service)
- Creating Resource(id=Derby Database)
- Creating Container(id=Default Sta

Re: OpenEJB - Missing required persistence.xml

2008-02-11 Thread Jacek Laskowski
On Feb 11, 2008 10:34 AM,  <[EMAIL PROTECTED]> wrote:

> - FAIL ... PatternManagementDaoImpl:Missing required persistence.xml
> for @PersistenceContext ref "em" to unit "pattern-managementPu"
>
> What's wrong? It is there. And where should it be placed? In META-INF
> like usually? It seems that it is later found.

"like usually"? That's how EJB3 spec mandates it so we should follow
the rule and we do. Can you jar -tf  and send the output
here? Could you show persistence.xml too so we can look at it?

> Can I define the order in which the EJB modules are loaded?

Not in a spec-compliant way. I'm not sure if you can do it in openejb
either, but would rather wait for Dave/Dain's reply before counting on
mine.

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl