Re: OpenEJB+Tomcat+Oracle+Toplink

2009-02-22 Thread petko

Ok. I make a mistake when i write this post.  The datebase name is ok.
I try witout this line

property name=Context.INITIAL_CONTEXT_FACTORY  
value=org.apache.openejb.client.LocalInitialContextFactory /

and everything is the same.

openejb.log output:

2009-02-22 17:39:59,171 - INFO  - Found ejb module EjbModule in war /Project
2009-02-22 17:40:00,875 - INFO  - Configuring enterprise application:
C:\Program Files\apache-tomcat-6.0.18\temp\0-Project
2009-02-22 17:40:01,156 - INFO  - Configuring PersistenceUnit(name=PUM,
provider=oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider)
2009-02-22 17:40:01,156 - INFO  - Configuring PersistenceUnit(name=PUL,
provider=oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider)
2009-02-22 17:40:01,156 - INFO  - Enterprise application C:\Program
Files\apache-tomcat-6.0.18\temp\0-Project loaded.
2009-02-22 17:40:01,156 - INFO  - Assembling app: C:\Program
Files\apache-tomcat-6.0.18\temp\0-Project
2009-02-22 17:40:01,218 - INFO  - PersistenceUnit(name=PUM,
provider=oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider)
2009-02-22 17:40:01,875 - INFO  - PersistenceUnit(name=PUL,
provider=oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider)
2009-02-22 17:40:01,984 - INFO  - Jndi(name=ClientFacadeRemote) --
Ejb(deployment-id=ClientFacade)
2009-02-22 17:40:01,984 - INFO  - Jndi(name=TasksFacadeRemote) --
Ejb(deployment-id=TasksFacade)
2009-02-22 17:40:01,984 - INFO  - Created Ejb(deployment-id=TasksFacade,
ejb-name=TasksFacade, container=My Stateless Container)
2009-02-22 17:40:01,984 - INFO  - Created Ejb(deployment-id=ClientFacade,
ejb-name=ClientFacade, container=My Stateless Container)
2009-02-22 17:40:01,984 - INFO  - Deployed Application(path=C:\Program
Files\apache-tomcat-6.0.18\temp\0-Project)

Should I make a correcetion on My Stateless Container?
Thanks, 


David Blevins wrote:
 
 The datasource names in your persistence.xml (DBFirst, DBSec) do not  
 match the names of the datasources you configured in your openejb.xml  
 (DBM, DBL).
 
 I'm suspicious of this line in the persistence.xml:
 
 property name=Context.INITIAL_CONTEXT_FACTORY  
 value=org.apache.openejb.client.LocalInitialContextFactory /
 
 I don't think any good can come to that as the only thing you can  
 lookup from the LocalInitialContextFactory is EJB references.  I  
 suspect that might be there for the transaction manager lookup.  We do  
 ship with an implementation the Toplink JTATransactionController  
 interface and will set it if we see you are using Toplink as your  
 persistence provider, so all should work without any OpenEJB-specific  
 flags in your persistence properties.
 
 If you still see the issue, post the openejb.log output.  That should  
 help us see how everything is being built.
 
 -David
 
 On Feb 20, 2009, at 4:19 AM, petko wrote:
 

 Hello ,

 In my project i am using OpenEJB with Tomcat and  Oracle 10g with  
 Toplink as
 provider
 I have problems configuring the persistence units and/or  
 datasources. I am
 not quite sure what the problem is.
 The structure of ejb jar folder is:
 -projectjar.jar
--com 
--META-INF,
 where in META-INF folder i have only two xml files
-- ejb-jar.xml
-- persistence.xml
 Because i have two database, i have two persistence-unit with  
 different
 names PUM and PUL
 Content of persistence.xml is:
 persistence version=1.0 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;
 persistence-unit name=PUM transaction-type=JTA

  
 provider 
 oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider/ 
 provider
  jta-data-sourceDBFirst/jta-data-source
  non-jta-data-sourceDBFirstUnmanaged/non-jta-data-source
  classcom.Client/class
  exclude-unlisted-classestrue/exclude-unlisted-classes
  properties
  property name=toplink.logging.level value=WARNING /
  property name=toplink.logging.level.sql value=FINEST /
  property name=toplink.logging.level.ejb value=FINEST /
  property name=Context.INITIAL_CONTEXT_FACTORY
 value=org.apache.openejb.client.LocalInitialContextFactory /
  /properties
 /persistence-unit
 persistence-unit name=PUL transaction-type=JTA

  
 provider 
 oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider/ 
 provider
  jta-data-sourceDBSec/jta-data-source
  non-jta-data-sourceDBSecUnmanaged/non-jta-data-source
  classcom.Tasks/class
  exclude-unlisted-classestrue/exclude-unlisted-classes
  properties
  property name=toplink.logging.level value=WARNING /
  property name=toplink.logging.level.sql value=FINEST /
  property name=toplink.logging.level.ejb value=FINEST /
  property name=Context.INITIAL_CONTEXT_FACTORY
 

OpenEJB+Tomcat+Oracle+Toplink

2009-02-20 Thread petko

Hello ,

In my project i am using OpenEJB with Tomcat and  Oracle 10g with Toplink as
provider
I have problems configuring the persistence units and/or datasources. I am
not quite sure what the problem is.
The structure of ejb jar folder is:
-projectjar.jar
--com   
--META-INF,
where in META-INF folder i have only two xml files
-- ejb-jar.xml
-- persistence.xml
Because i have two database, i have two persistence-unit with different
names PUM and PUL
Content of persistence.xml is:
persistence version=1.0 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; 
persistence-unit name=PUM transaction-type=JTA 

provideroracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider/provider
 
jta-data-sourceDBFirst/jta-data-source 
non-jta-data-sourceDBFirstUnmanaged/non-jta-data-source 
classcom.Client/class 
exclude-unlisted-classestrue/exclude-unlisted-classes 
properties 
property name=toplink.logging.level value=WARNING / 
property name=toplink.logging.level.sql value=FINEST / 
property name=toplink.logging.level.ejb value=FINEST / 
property name=Context.INITIAL_CONTEXT_FACTORY
value=org.apache.openejb.client.LocalInitialContextFactory / 
/properties 
/persistence-unit 
persistence-unit name=PUL transaction-type=JTA 

provideroracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider/provider
 
jta-data-sourceDBSec/jta-data-source 
non-jta-data-sourceDBSecUnmanaged/non-jta-data-source 
classcom.Tasks/class 
exclude-unlisted-classestrue/exclude-unlisted-classes 
properties 
property name=toplink.logging.level value=WARNING / 
property name=toplink.logging.level.sql value=FINEST / 
property name=toplink.logging.level.ejb value=FINEST / 
property name=Context.INITIAL_CONTEXT_FACTORY
value=org.apache.openejb.client.LocalInitialContextFactory / 
/properties 
/persistence-unit
Content of ejb-jar is:
ejb-jar xmlns=http://java.sun.com/xml/ns/javaee;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
metadata-complete=true version=3.0
xsi:schemaLocation=http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd; 
enterprise-beans 
session 
display-nameClientFacade/display-name 
ejb-nameClientFacade/ejb-name 
business-remotecom.ClientFacadeRemote/business-remote 
ejb-classcom.ClientFacade/ejb-class 
session-typeStateless/session-type 
transaction-typeContainer/transaction-type 
persistence-context-ref 

persistence-context-ref-namecom.ClientFacade/em/persistence-context-ref-name
 
persistence-unit-namePUM/persistence-unit-name 

persistence-context-typeTransaction/persistence-context-type 
injection-target 

injection-target-classcom.ClientFacade/injection-target-class 

injection-target-nameem/injection-target-name 
/injection-target 
/persistence-context-ref 
security-identity 
use-caller-identity / 
/security-identity 
/session 
session 
display-nameTasksFacade/display-name 
ejb-nameTasksFacade/ejb-name 
business-remotecom.tasks.TasksFacadeRemote/business-remote 
ejb-classcom.tasks.TasksFacade/ejb-class 
session-typeStateless/session-type 
transaction-typeContainer/transaction-type 
persistence-context-ref 

persistence-context-ref-namecom.tasks.TasksFacade/em/persistence-context-ref-name
 
persistence-unit-namePUL/persistence-unit-name 

persistence-context-typeTransaction/persistence-context-type 
injection-target 

injection-target-classcom.tasks.TasksFacade/injection-target-class 

injection-target-nameem/injection-target-name 
/injection-target 
/persistence-context-ref 
security-identity 
use-caller-identity / 
/security-identity 
/session 
/enterprise-beans 
/ejb-jar

In openejb.xml i put
Resource id=DBM type=DataSource
  JdbcDriver oracle.jdbc.OracleDriver 
  JdbcUrl jdbc:oracle:thin:@server:1521:db 
   UserName user
   Password user
/Resource 
Resource id=DBL type=DataSource
   JdbcDriver oracle.jdbc.OracleDriver 
   JdbcUrl 

Re: OpenEJB+Tomcat+Oracle+Toplink

2009-02-20 Thread David Blevins
The datasource names in your persistence.xml (DBFirst, DBSec) do not  
match the names of the datasources you configured in your openejb.xml  
(DBM, DBL).


I'm suspicious of this line in the persistence.xml:

property name=Context.INITIAL_CONTEXT_FACTORY  
value=org.apache.openejb.client.LocalInitialContextFactory /


I don't think any good can come to that as the only thing you can  
lookup from the LocalInitialContextFactory is EJB references.  I  
suspect that might be there for the transaction manager lookup.  We do  
ship with an implementation the Toplink JTATransactionController  
interface and will set it if we see you are using Toplink as your  
persistence provider, so all should work without any OpenEJB-specific  
flags in your persistence properties.


If you still see the issue, post the openejb.log output.  That should  
help us see how everything is being built.


-David

On Feb 20, 2009, at 4:19 AM, petko wrote:



Hello ,

In my project i am using OpenEJB with Tomcat and  Oracle 10g with  
Toplink as

provider
I have problems configuring the persistence units and/or  
datasources. I am

not quite sure what the problem is.
The structure of ejb jar folder is:
-projectjar.jar
   --com
   --META-INF,
where in META-INF folder i have only two xml files
   -- ejb-jar.xml
   -- persistence.xml
Because i have two database, i have two persistence-unit with  
different

names PUM and PUL
Content of persistence.xml is:
persistence version=1.0 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;
persistence-unit name=PUM transaction-type=JTA

 
provider 
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider/ 
provider

jta-data-sourceDBFirst/jta-data-source
non-jta-data-sourceDBFirstUnmanaged/non-jta-data-source
classcom.Client/class
exclude-unlisted-classestrue/exclude-unlisted-classes
properties
property name=toplink.logging.level value=WARNING /
property name=toplink.logging.level.sql value=FINEST /
property name=toplink.logging.level.ejb value=FINEST /
property name=Context.INITIAL_CONTEXT_FACTORY
value=org.apache.openejb.client.LocalInitialContextFactory /
/properties
/persistence-unit
persistence-unit name=PUL transaction-type=JTA

 
provider 
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider/ 
provider

jta-data-sourceDBSec/jta-data-source
non-jta-data-sourceDBSecUnmanaged/non-jta-data-source
classcom.Tasks/class
exclude-unlisted-classestrue/exclude-unlisted-classes
properties
property name=toplink.logging.level value=WARNING /
property name=toplink.logging.level.sql value=FINEST /
property name=toplink.logging.level.ejb value=FINEST /
property name=Context.INITIAL_CONTEXT_FACTORY
value=org.apache.openejb.client.LocalInitialContextFactory /
/properties
/persistence-unit
Content of ejb-jar is:
ejb-jar xmlns=http://java.sun.com/xml/ns/javaee;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
metadata-complete=true version=3.0
xsi:schemaLocation=http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd;
enterprise-beans
session
display-nameClientFacade/display-name
ejb-nameClientFacade/ejb-name
business-remotecom.ClientFacadeRemote/business-remote
ejb-classcom.ClientFacade/ejb-class
session-typeStateless/session-type
transaction-typeContainer/transaction-type
persistence-context-ref

persistence-context-ref-namecom.ClientFacade/em/persistence- 
context-ref-name

persistence-unit-namePUM/persistence-unit-name

persistence-context-typeTransaction/persistence-context-type
injection-target

injection-target-classcom.ClientFacade/injection-target-class

injection-target-nameem/injection-target-name
/injection-target
/persistence-context-ref
security-identity
use-caller-identity /
/security-identity
/session
session
display-nameTasksFacade/display-name
ejb-nameTasksFacade/ejb-name
business-remotecom.tasks.TasksFacadeRemote/business-remote
ejb-classcom.tasks.TasksFacade/ejb-class
session-typeStateless/session-type
transaction-typeContainer/transaction-type
persistence-context-ref

persistence-context-ref-namecom.tasks.TasksFacade/em/persistence- 
context-ref-name

   

Re: OpenEJB on Oracle

2009-02-11 Thread JensToerber
;
 xsi:schemaLocation=http://java.sun.com/xml/ns/persistence
 http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd;
   !--
   only one persistence unit per project by JPA Tools supported
   --
   !--
   persistence-unit name=JPATestProject
   /persistence-unit
   --
   persistence-unit name=beds_pu transaction-type=RESOURCE_LOCAL
   providerorg.hibernate.ejb.HibernatePersistence/provider
   !-- use persistence.xml right mouse Synchronize classes to get
 actual list --
   classinfo.toerber.beds.model.Test/class
   properties
  property name=hibernate.dialect
 value=org.hibernate.dialect.Oracle10gDialect/
  property name=hibernate.connection.driver_class
 value=oracle.jdbc.OracleDriver/
  property name=hibernate.connection.username value=openejb/
  property name=hibernate.connection.password value=openejb/
  property name=hibernate.connection.url
 value=jdbc:oracle:thin:@192.168.2.96:1521:ORCL/
  property name=hibernate.max_fetch_depth value=3/
  !-- JPA Tools looks for this setting(?), so does not always drop
 the table as announced --
  property name=hibernate.hbm2ddl.auto value=update /
!--
  creates table at start and drops at the end!!
  property name=hibernate.hbm2ddl.auto value=create-drop /
--
  !-- cache configuration
  property
 name=hibernate.ejb.classcache.org.hibernate.ejb.test.Item
 value=read-write/
  property
 name=hibernate.ejb.collectioncache.org.hibernate.ejb.test.Item.distributors
 value=read-write, RegionName/
  --
 
  !-- alternatively to class and property declarations, you
 can use a regular hibernate.cfg.xml file --
  !-- property name=hibernate.ejb.cfgfile
 value=/org/hibernate/ejb/test/hibernate.cfg.xml/ --
   /properties
/persistence-unit
 /persistence
 
 Any help welcome.
 Thanks in advance.
 
 Jens Toerber
 

-- 
View this message in context: 
http://www.nabble.com/OpenEJB-on-Oracle-tp20294024p21952439.html
Sent from the OpenEJB User mailing list archive at Nabble.com.



Re: OpenEJB on Oracle

2009-01-26 Thread David Blevins


On Jan 19, 2009, at 2:20 PM, JensToerber wrote:



Hi David,

thanks a lot for your support:

I)
i tried the javax.mail.Session Resource:

What i found out:
a) If you specify the pass-through Properties in
Resource id=BedsMailSession type=javax.mail.Session
# mail.host=
mail.pop3.user=jens.toerber
mail.pop3.host=pop.web.de
mail.pop3.port=110
mail.smtp.host=smtp.web.de
mail.smtp.port=25
mail.transport.protocol=smtp
mail.smtp.auth=true
mail.smtp.user=jens.toerber
password=thrillie
/Resource

you get a WARN-Level log-entry that those Properties are not  
supported. I
guess INFO-Level with a hint that they are passed through would be  
better.


Right, exactly.  That's an oversight on our part.  We'll need to get  
that code updated not to warn in situations where properties are  
passed directly through.


Logged that so we can track it:  
https://issues.apache.org/jira/browse/OPENEJB-989


b) You have to be very careful with the properties:
# 25 not allowed, not even 25blank, but
mail.smtp.port=25
# smtp not allowed, not even smtpblank!!
mail.transport.protocol=smtp
# smtp.web.de not allowed, but
mail.smtp.host=smtp.web.de

, hence you have to be very careful and the values you specified do  
not
work. I could not test everything, because there are different types  
of
smtp-servers (pop3 before smtp, smtp authentification, ...). I guess  
also


mail.smtp.user=jens.toerber

is not correct, but

mail.smtp.user=jens.toerber


, but i cannot prove it.


My mistake for showing with quotes, I forgot that java.util.Properties  
will not strip those out.


I was a bit surprised to find that java.util.Properties doesn't strip  
the whitespace off the end of a property value.  I find that strange  
as it will strip the whitespace off the front and end of the property  
name and will strip the whitespace off the front of the property  
value.  Seems inconsistent, but I can understand why they did it that  
way.


In our situation I don't think it's useful.  We do have a more  
powerful subclass of java.util.Properties we use and in that we could  
add an option to trim whitespace off the end of property values as well.


Added a jira for this as well:  
https://issues.apache.org/jira/browse/OPENEJB-990

But if you take care, Mail-Sessions are working. Would be great to  
really

document this very precise.


Added this doc with the text from the thread.

http://cwiki.apache.org/OPENEJBx30/configuring-javamail.html

It could likely be more verbose perhaps even show a bean that uses  
javamail.  Contributions are very welcome.  If you're interested in  
helping I can hook you up in our wiki.



II)
New-Connection-sql:
JBoss has in it's datasource the new-connection-sql element and  
Weblogic 8.1
has an InitSQL on it's connection pool. Hence i could say, they  
support this

feature, and so should Openejb, but to be more specific:
a) In Oracle you may change NLS_SORT (XGERMAN_DIN) via ALTER  
SESSION ...

b) You may enable Database SQL trace:
ALTER SESSION SET SQL_TRACE=true (ok, you may do this by
DBMS_SESSION.SET_SQL_TRACE (sql_trace IN BOOLEAN), ... even from a  
different

session)
c) You may set the Oprimzer Mode for Oracle:
JBoss *-ds.xml:
...
 new-connection-sqlbegin EXECUTE IMMEDIATE 'ALTER SESSION SET
NLS_SORT=''XGERMAN_DIN''';EXECUTE IMMEDIATE 'ALTER SESSION SET
optimizer_mode=''FIRST_ROWS'''; end;/new-connection-sql
...

Ok, not very typical. Hence i guess there are a lot of samples for  
needing a

New-Connection-SQL statement.

There may by EntityManager Interceptors or Listeners in EJB3, but our
Deployers like to control it like that.

Would be great to have this feature in Openejb as well.


We're using commons-dbcp for our jdbc connection pooling.  If it has  
such functionality it should be fairly straightforward to wire it in.



III)
Timer
I'll attach my sample:
Simple Timer Bean with a Timeout-Method and an initialization  
Method, which

is called by a ServletContextListener.

The example is working in JBoss 4.2. In Openejb-JUnit it is also  
working,
but i suppose it is because in my test i hold a reference to the  
TimerBean.

That's why i tried to put a reference to the TimerBean in the
ServletContextListener as an attribute in the ServletContext to  
simulate the

JUnit-Test behaviour.

It gets initialized, but never fires in Tomcat 6.0.18 and Openejb  
3.1 in the

Container, but as already said in the JUnit test.

Any help appreciated.


That might be a little tricky to debug without an app that can  
reproduce the issue.


IV) I think CXF is ok delivered with Openejb. Would be nice to hear,  
if you
try to upgrade the versions i told you, to support Hibernate without  
any

changes (it's because our old applications are used to it).


It should be possible to upgrade CXF or remove it entirely provided  
you also remove the openejb-cxf jar.  Likely upgrading the slf4j jars  
without 

Re: OpenEJB on Oracle

2009-01-19 Thread JensToerber
://www.nabble.com/OpenEJB-on-Oracle-tp20294024p21552837.html
Sent from the OpenEJB User mailing list archive at Nabble.com.



Re: OpenEJB on Oracle

2009-01-09 Thread JensToerber

Hi,

addition:

Tried to get my application running with Hibernate as JPA-Provider on Tomcat
with Openejb:
Openejb is loaded during startup of Tomcat, hence the Classes in
openejb-webapp\lib (yes lib) are loaded very early. Take care to do the
same Class Loading Order in your Development environment, otherwise you
can't compare the two infrastructures.

There seems to be a problem with slf4j-api-1.3.1.jar and
slf4j-jdk14-1.3.1.jar (part of Openejb 3.1).

I had to update these to version 1.5.2. (otherwise LinkageError or no such
Method Error), because i use Hibernate-Entitymanager 3.4.0.GA and
Hibernate-Annotations 3.4.0.GA (and the corresponding delivered dependencies
see below).

I also had to copy all Hibernate jars into openejb-webapp\lib folder
instead of in WEB-INF\lib (is this really intended?), otherwise you get
NoClassDef Found Error:

09.01.2009  23:10   443.432 antlr.jar
09.01.2009  23:1026.360 asm.jar
09.01.2009  23:10   282.338 cglib.jar
09.01.2009  23:10   313.898 dom4j.jar
09.01.2009  23:10   279.714 hibernate-annotations.jar
09.01.2009  23:1066.993 hibernate-commons-annotations.jar
09.01.2009  23:10 2.266.769 hibernate-core.jar
09.01.2009  23:10   119.292 hibernate-entitymanager.jar
10.01.2009  01:49 0 hibernate.txt
09.01.2009  23:10   471.005 javassist.jar
09.01.2009  23:13   230 Readme_Hibernate.txt
09.01.2009  23:1117.384 slf4j-api-1.5.2.jar
09.01.2009  23:11 8.643 slf4j-jdk14-1.5.2.jar

As i wrote TimerService is working in JUnit-Tests, but not in Tomcat with
Openejb! It is initialized, but fires never. No special Openejb-Log-Entry
for this. Any idea about this?

With the Transaction-Openejb-Logging-Fix now transactions work.

Still have to test Mail Session. Additionally access to InnermostConnection
(we are using some features of the Oracle Driver).

JSF 1.2 and EJB-Injection currently no problem. 

Best regards,

Jens


JensToerber wrote:
 
 Hi David,
 
 thanks a lot. Yes, had a little problems with my logging and some
 Openejb-Auto-Correction-Logging-Entries are a little bit confusing for me.
 
 There are hopefully only 2 things left.
 
 Currently i am assembling all hints together and then will try to get
 everything running on Tomcat with Openejb:
 
 1.) DataSource-Resource:
 You may specify connection properties. Is it possible to specify a SQL
 statement on new connection?
 The idea is to execute some ALTER SESSION ... statements for Oracle.
 
 Ok i know and also read here that you may take an
 Oracle-Session-Logon-Trigger where you may execute some statements.
 And some things may be configurable via connection properties.
 We are used by JBoss to configure it in the JBoss *-ds.xml file
 new-connection-sql/.
 
 2.) javax.mail.Session:
 There is no property specified in the documentation for Resource in
 openejb.xml.
 Is it configured via System properties (hm, how about several applications
 querying using different servers) or does each client have to take care of
 the mail settings?
 Could not find very much about this topic.
 
 Thanks in advance.
 
 Best regards,
 
 Jens
 
 David Blevins wrote:
 
 
 On Dec 28, 2008, at 2:12 PM, JensToerber wrote:
 

 Hi again,
 
 Hi Jens!
 
 I did not manage to run OpenEJB on Oracle in JUnit-Test if i  
 configure it
 like this:
 p.put(DATASOURCE, new://Resource?type=DataSource);
p.put(DATASOURCE + .JdbcDriver, oracle.jdbc.OracleDriver);
// it is not working thin driver is complaining about missing
 username and/or password
// p.put(DATASOURCE + .JdbcUrl, jdbc:oracle:thin: +  
 USERNAME +
 / + PASSWORD + @192.168.2.96:1521:ORCL);
p.put(DATASOURCE + .JdbcUrl, jdbc:oracle:thin: + USERNAME  
 + /
 + PASSWORD + @192.168.2.99:1521:XE);
p.put(oracle.jdbc.user, USERNAME);
p.put(oracle.jdbc.username, USERNAME);
p.put(oracle.jdbc.password, PASSWORD);
p.put(user, openejb);
p.put(password, openejb);
p.put(DATASOURCE + .JdbcUsername, openejb);
p.put(DATASOURCE + .JdbcPassword, openejb);
// openejb always sets the username to sa and password to 
 
 You'll want to specify the username and password properties as  
 follows:
 
  p.put(Oracle, new://Resource?type=DataSource);
  p.put(Oracle.JdbcDriver, oracle.jdbc.OracleDriver);
  p.put(Oracle.JdbcUrl, jdbc:oracle:thin: 
 192.168.2.99:1521:XE);
  p.put(Oracle.Username, foo);
  p.put(Oracle.Password, bar);
 
 Or if you want to use a DATASOURCE variable as you showed in your  
 code then like this:
 
  String DATASOURCE = Oracle;
  String USERNAME = foo;
  String PASSWORD = bar;
 
  p.put(DATASOURCE, new://Resource?type=DataSource);
  p.put(DATASOURCE + .JdbcDriver, oracle.jdbc.OracleDriver);
  p.put(DATASOURCE + .JdbcUrl, jdbc:oracle:thin: 
 192.168.2.99:1521:XE);
  p.put(DATASOURCE

Re: OpenEJB on Oracle

2008-12-28 Thread JensToerber

Hi again,

because of time issues i changed temporarily back to JBoss with an EAR.
I will change this, when i am ready with the first step of development.

What i found out:
I did not manage to run OpenEJB on Oracle in JUnit-Test if i configure it
like this:
p.put(DATASOURCE, new://Resource?type=DataSource);
p.put(DATASOURCE + .JdbcDriver, oracle.jdbc.OracleDriver);
// it is not working thin driver is complaining about missing
username and/or password
// p.put(DATASOURCE + .JdbcUrl, jdbc:oracle:thin: + USERNAME +
/ + PASSWORD + @192.168.2.96:1521:ORCL);
p.put(DATASOURCE + .JdbcUrl, jdbc:oracle:thin: + USERNAME + /
+ PASSWORD + @192.168.2.99:1521:XE);
p.put(oracle.jdbc.user, USERNAME);
p.put(oracle.jdbc.username, USERNAME);
p.put(oracle.jdbc.password, PASSWORD);
p.put(user, openejb);
p.put(password, openejb);
p.put(DATASOURCE + .JdbcUsername, openejb);
p.put(DATASOURCE + .JdbcPassword, openejb);
// openejb always sets the username to sa and password to 

If you do something like this:

ds = (DataSource)retContext.lookup(java:/openejb/Resource/OracleORCL);
BasicManagedDataSource bds = (BasicManagedDataSource) 
ds;
// needed otherwise wrong username/password set
bds.setUserName(openejb); // before: sa
bds.setPassword(openejb); // before: 
// works but has currently no effect for standalone 
tests
retContext.rebind(java:/openejb/Resource/OracleORCL, 
ds);

Then it temporarily works, but not for newly created Connections via
Persistence-Context.

It seems that in this configuration case OpenEJB always sets the User to
sa and password to .

Then i found something here to configure OpenEJB in JUnit-Tests via
openejb.xml:
Properties properties = getProperties(); 

URL config =  
this.getClass().getClassLoader().getResource(META-INF/openejb.xml); 
properties.setProperty(openejb.configuration,
config.toExternalForm()); 

Context retContext = null;

try {
retContext = new InitialContext(properties);

   ...

Then Oracle Datasource is working in JUnit-Tests.
Fine.

Got Timer running in OpenEJB JUnit-Test. It's straight forward.

I tried to get an MDB running. This is working now in my JBoss (without
OpenEJB), not yet tested in Tomcat with OpenEJB, but it is not working in
OpenEJB-JUnit-Test.

Initialization is working, OpenEJB does not complain about missing Queue in
configuration.

I don't know if it should work in JUnit-Test.
Here my inspection code:
obj = retContext.lookup(queue);
if (obj instanceof ActiveMQQueue) {
ActiveMQQueue activeMQQueue  = 
(ActiveMQQueue) obj;

String physicalName = 
activeMQQueue.getPhysicalName(); // value of
destination of openejb.xml - Resource ...destination .../resource 
log.debug(physicalName:  + 
physicalName);
String qualifiedName = 
activeMQQueue.getQualifiedName(); //
queue://physicalName
log.debug(qualifiedName:  + 
qualifiedName);   
String destinationTypeAsString =
activeMQQueue.getDestinationTypeAsString(); // Queue
log.debug(destinationTypeAsString:  + 
destinationTypeAsString);   
// may throw JMSException:
String queueName = 
activeMQQueue.getQueueName(); // equals to
physicalName (?)
log.debug(queueName:  + queueName);   

Map options = 
activeMQQueue.getOptions(); // currently null
log.debug(options:  + options);   

Properties ps = 
activeMQQueue.getProperties();
logProperties(ps);
log.debug(ps:  + ps); 

}

I'll add my current openejb.xml file (for JUnit-Test).

Currenlty i am not quite sure how to configure an ActiveMQ persistent Queue
in OpenEJB.

ActiveMQ creates the Destination on the fly. In JBoss you have to configure
Queues in advance to be persistent. Non-persistent are created on the fly.

There is a service-jar.xml in openejb.war\org.apache.openejb.tomcat\META-INF
or openejb.war\WEB-INF\classes\META-INF

Re: OpenEJB on Oracle

2008-12-28 Thread JensToerber

Hi again,

because of time issues i changed temporarily back to JBoss with an EAR.
I will change this, when i am ready with the first step of development.

I changed to Hibernate in OpenEJB3.1-JUnit-Tests and it works fine so far.

What i found out:
I did not manage to run OpenEJB on Oracle in JUnit-Test if i configure it
like this:
p.put(DATASOURCE, new://Resource?type=DataSource);
p.put(DATASOURCE + .JdbcDriver, oracle.jdbc.OracleDriver);
// it is not working thin driver is complaining about missing
username and/or password
// p.put(DATASOURCE + .JdbcUrl, jdbc:oracle:thin: + USERNAME +
/ + PASSWORD + @192.168.2.96:1521:ORCL);
p.put(DATASOURCE + .JdbcUrl, jdbc:oracle:thin: + USERNAME + /
+ PASSWORD + @192.168.2.99:1521:XE);
p.put(oracle.jdbc.user, USERNAME);
p.put(oracle.jdbc.username, USERNAME);
p.put(oracle.jdbc.password, PASSWORD);
p.put(user, openejb);
p.put(password, openejb);
p.put(DATASOURCE + .JdbcUsername, openejb);
p.put(DATASOURCE + .JdbcPassword, openejb);
// openejb always sets the username to sa and password to 

If you do something like this:

ds = (DataSource)retContext.lookup(java:/openejb/Resource/OracleORCL);
BasicManagedDataSource bds = (BasicManagedDataSource) 
ds;
// needed otherwise wrong username/password set
bds.setUserName(openejb); // before: sa
bds.setPassword(openejb); // before: 
// works but has currently no effect for standalone 
tests
retContext.rebind(java:/openejb/Resource/OracleORCL, 
ds);

Then it temporarily works, but not for newly created Connections via
Persistence-Unit.

It seems that in this configuration case OpenEJB always sets the User to
sa and password to .

Then i found something here to configure OpenEJB in JUnit-Tests via
openejb.xml:
Properties properties = getProperties(); 

URL config =  
this.getClass().getClassLoader().getResource(META-INF/openejb.xml); 
properties.setProperty(openejb.configuration,
config.toExternalForm()); 

Context retContext = null;

try {
retContext = new InitialContext(properties);

   ...

Then Oracle Datasource is working in JUnit-Tests.
Fine.

Got Timer running in OpenEJB JUnit-Test. It's straight forward.

I tried to get an MDB running. This is working now in my JBoss (without
OpenEJB), not yet tested in Tomcat with OpenEJB, but it is not working in
OpenEJB-JUnit-Test.

Initialization is working, OpenEJB does not complain about missing Queue in
configuration.

I don't know if it should work in JUnit-Test.
Here my inspection code:
obj = retContext.lookup(queue);
if (obj instanceof ActiveMQQueue) {
ActiveMQQueue activeMQQueue  = 
(ActiveMQQueue) obj;

String physicalName = 
activeMQQueue.getPhysicalName(); // value of
destination of openejb.xml - Resource ...destination .../resource 
log.debug(physicalName:  + 
physicalName);
String qualifiedName = 
activeMQQueue.getQualifiedName(); //
queue://physicalName
log.debug(qualifiedName:  + 
qualifiedName);   
String destinationTypeAsString =
activeMQQueue.getDestinationTypeAsString(); // Queue
log.debug(destinationTypeAsString:  + 
destinationTypeAsString);   
// may throw JMSException:
String queueName = 
activeMQQueue.getQueueName(); // equals to
physicalName (?)
log.debug(queueName:  + queueName);   

Map options = 
activeMQQueue.getOptions(); // currently null
log.debug(options:  + options);   

Properties ps = 
activeMQQueue.getProperties();
logProperties(ps);
log.debug(ps:  + ps); 

}

I'll add my current openejb.xml file (for JUnit-Test).

Currenlty i am not quite sure how to configure an ActiveMQ persistent Queue
in OpenEJB.

ActiveMQ creates the Destination on the fly. In JBoss you have to configure
Queues in advance to be persistent. Non-persistent are created on the fly.

There is a service-jar.xml in openejb.war

Re: OpenEJB on Oracle

2008-12-28 Thread David Blevins


On Dec 28, 2008, at 2:12 PM, JensToerber wrote:



Hi again,


Hi Jens!

I did not manage to run OpenEJB on Oracle in JUnit-Test if i  
configure it

like this:
p.put(DATASOURCE, new://Resource?type=DataSource);
   p.put(DATASOURCE + .JdbcDriver, oracle.jdbc.OracleDriver);
   // it is not working thin driver is complaining about missing
username and/or password
   // p.put(DATASOURCE + .JdbcUrl, jdbc:oracle:thin: +  
USERNAME +

/ + PASSWORD + @192.168.2.96:1521:ORCL);
   p.put(DATASOURCE + .JdbcUrl, jdbc:oracle:thin: + USERNAME  
+ /

+ PASSWORD + @192.168.2.99:1521:XE);
   p.put(oracle.jdbc.user, USERNAME);
   p.put(oracle.jdbc.username, USERNAME);
   p.put(oracle.jdbc.password, PASSWORD);
   p.put(user, openejb);
   p.put(password, openejb);
   p.put(DATASOURCE + .JdbcUsername, openejb);
   p.put(DATASOURCE + .JdbcPassword, openejb);
   // openejb always sets the username to sa and password to 


You'll want to specify the username and password properties as  
follows:


p.put(Oracle, new://Resource?type=DataSource);
p.put(Oracle.JdbcDriver, oracle.jdbc.OracleDriver);
p.put(Oracle.JdbcUrl, jdbc:oracle:thin: 
192.168.2.99:1521:XE);

p.put(Oracle.Username, foo);
p.put(Oracle.Password, bar);

Or if you want to use a DATASOURCE variable as you showed in your  
code then like this:


String DATASOURCE = Oracle;
String USERNAME = foo;
String PASSWORD = bar;

p.put(DATASOURCE, new://Resource?type=DataSource);
p.put(DATASOURCE + .JdbcDriver, oracle.jdbc.OracleDriver);
p.put(DATASOURCE + .JdbcUrl, jdbc:oracle:thin: 
192.168.2.99:1521:XE);

p.put(DATASOURCE + .Username, USERNAME);
p.put(DATASOURCE + .Password, PASSWORD);

Note that all properties are not case-sensitive, so username and  
password will work as will UsErNaMe and pAsSwOrD and so on.


With the way you have it configured, you should see these four  
warnings in your log file saying that your guesses are not correct:


WARN - Property JdbcUsername not supported by Oracle
WARN - Property jdbc.username not supported by Oracle
WARN - Property JdbcPassword not supported by Oracle
WARN - Property jdbc.user not supported by Oracle
WARN - Property jdbc.password not supported by Oracle


Then i found something here to configure OpenEJB in JUnit-Tests via
openejb.xml:
Properties properties = getProperties();

URL config =
this.getClass().getClassLoader().getResource(META-INF/openejb.xml);
properties.setProperty(openejb.configuration,
config.toExternalForm());

Context retContext = null;

try {
retContext = new InitialContext(properties);

   ...

Then Oracle Datasource is working in JUnit-Tests.
Fine.


That's also a fine way to configure things for a test case.


Got Timer running in OpenEJB JUnit-Test. It's straight forward.


Great!

I tried to get an MDB running. This is working now in my JBoss  
(without
OpenEJB), not yet tested in Tomcat with OpenEJB, but it is not  
working in

OpenEJB-JUnit-Test.

Initialization is working, OpenEJB does not complain about missing  
Queue in

configuration.

I don't know if it should work in JUnit-Test.
Here my inspection code:
obj = retContext.lookup(queue);
if (obj instanceof ActiveMQQueue) {
ActiveMQQueue activeMQQueue  = 
(ActiveMQQueue) obj;

	String physicalName = activeMQQueue.getPhysicalName(); // value  
of

destination of openejb.xml - Resource ...destination .../resource
log.debug(physicalName:  + 
physicalName);
String qualifiedName = 
activeMQQueue.getQualifiedName(); //
queue://physicalName
log.debug(qualifiedName:  + 
qualifiedName); 
String destinationTypeAsString =
activeMQQueue.getDestinationTypeAsString(); // Queue
	log.debug(destinationTypeAsString:  +  
destinationTypeAsString);	

// may throw JMSException:
String queueName = 
activeMQQueue.getQueueName(); // equals to
physicalName (?)
log.debug(queueName:  + queueName);   
  
Map options = 
activeMQQueue.getOptions(); // currently null
log.debug(options:  + options);   
  
Properties ps = 
activeMQQueue.getProperties();
logProperties(ps);
log.debug(ps:  + ps

Re: OpenEJB on Oracle

2008-12-10 Thread David Blevins

(excuse the delay - vacation)

On Nov 22, 2008, at 6:54 AM, JensToerber wrote:


Hint:
If you try to run it as openejb-3.1.war you get trouble with the
installer.jsp, because the install-Button there expects ContextPath
/openejb. It's better to run it as openejb.xml, because otherwise  
you get

several config files (openejb.xml and openejb-3.1.xml) in
conf/Catalina/localhost.


We'll have to make note of that somewhere.

Still have to test this for persistent Messages. But this is the  
step after

the next step.


Let us know how that went.


In the Examples i could change the JpaServlet to

public class JpaServlet extends HttpServlet {
   @Resource(name = OracleORCL, type = javax.sql.DataSource.class)
   private javax.sql.DataSource ds;

   @PersistenceUnit(name = jpa-example)
   private EntityManagerFactory emf; // only injected if not in a
container?

   @PersistenceContext(name = jpa-example)
   private EntityManager em;
...

Now the DataSource ds is injected and working on Oracle.


Great.

But i don't get the EntityManager injected. It is always null. Don't  
know

why.


Per spec, servlets aren't allowed @PersistenceContext injection as the  
context propagation models (TRANSACTION and EXTENDED) don't really fit  
for a servlet.  Definitely something we should add a validation  
message for so at the least you would get a warning saying it won't  
work and why.



But my call to categoryDaoLocal.persist(category) fails with no ending
exceptions like:

http://localhost:8080/HotelWebProject/servlet/TestServletilterChain.java:206)
   at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:233)

[...]

   at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44
7)
   at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.IllegalArgumentException: can't parse argument  
number

   at java.text.MessageFormat.makeFormat(MessageFormat.java:1330)
   at java.text.MessageFormat.applyPattern(MessageFormat.java:450)
   at java.text.MessageFormat.init(MessageFormat.java:350)
   at org.apache.openejb.util.Logger$4.compute(Logger.java:108)
   at org.apache.openejb.util.Logger$4.compute(Logger.java:107)
   at org.apache.openejb.util.Memoizer$1.call(Memoizer.java:42)
   at

[...]

An invalidly formatted i18n message text slipped into one of our  
Messages.properties files right before the release went out.  This has  
been fixed in the coming 3.1.1 (https://issues.apache.org/jira/browse/OPENEJB-950 
)


A workaround is to set the related logging category to ERROR:

  log4j.category.Transaction = ERROR


Next steps then are:
- Get our application work (MyFaces 1.2, Facelets, Timer, MDBs with
persistent Messages on Tomcat Cluster hopefully with Openejb)
- try to change JPA-Provider to Hibernate (still haven't looked for
automatically database schema update in OpenJPA-Provider)


Let us know if you need any help with those.

-David



Re: OpenEJB on Oracle

2008-11-22 Thread JensToerber
 JdbcDriver = org.foo.OrangeDriver
 JdbcUrl = jdbc:orange:some:stuff
 JtaManaged = false
   /Resource
 
 {app}/META-INF/persistence.xml
   persistence-unit name=orange-unit
jta-data-sourceOrange/jta-data-source
non-jta-data-sourceOrangeUnamanged/non-jta-data-source
   /persistence-unit
 
 If you don't do exactly that, we will do various things to attempt to  
 figure out how to make things work.  In the 3.1 release the logging  
 for that is a bit better and we won't alter your persistence.xml  
 without telling you exactly what we are setting it to so you can  
 either use those values explicitly or more easily figure out what the  
 right values should look like.
 
 Here is a test case which shows the steps we'll take to make things  
 work.  At least it shows the input and resulting persistence-unit  
 changes.  Warning I just notices some of the javadoc isn't quite right:
   
 http://svn.apache.org/repos/asf/openejb/tags/openejb-3.0/container/openejb-core/src/test/java/org/apache/openejb/config/AutoConfigPersistenceUnitsTest.java
 
 I guess you know that in the Documentation the Oracle Datasource has  
 the
 MySQL Driver and not the Oracle Driver.
 
 We didn't know, thanks!  I've updated the page.
 
 Is there any working sample with an Oracle Datasource, which i could  
 try?
 
 I could create one for you but I couldn't legally give it to you with  
 the oracle drivers in it.  Instead, I made you an example setup that  
 uses derby rather than hsqldb.
 
 All I've done with this binary is:
   1. Install OpenEJB war into Tomcat and booted Tomcat.
   2. Edited the auto-created tomcat.base/conf/openejb.xml file
   2.1.  Set all JdbcDriver attributes to  
 org.apache.derby.jdbc.EmbeddedDriver
   2.2.  Set all JdbcUrl attributes to  
 jdbc:derby:sampleDB;create=true
   2.3.  Renamed the two Resource declarations to make it more  
 obvious in the log file (optional)
   3. Added derby jars to tomcat.base/lib/
   4. Restart
 
 I actually deleted the hsql jars from tomcat.base/webapps/openejb/lib/  
 for good measure, but you don't need to go that far.
 
 Hope this helps!
 
 -David
 
 
 
 
 
http://www.nabble.com/file/p20637148/persistence.xml persistence.xml 
http://www.nabble.com/file/p20637148/Constants.java Constants.java 
http://www.nabble.com/file/p20637148/CategoryDao.java CategoryDao.java 
http://www.nabble.com/file/p20637148/CategoryDaoLocal.java
CategoryDaoLocal.java  http://www.nabble.com/file/p20637148/DaoAll.java
DaoAll.java  http://www.nabble.com/file/p20637148/openejb.xml openejb.xml 
-- 
View this message in context: 
http://www.nabble.com/OpenEJB-on-Oracle-tp20294024p20637148.html
Sent from the OpenEJB User mailing list archive at Nabble.com.



Re: OpenEJB on Oracle

2008-11-15 Thread JensToerber
 --
   classinfo.toerber.beds.model.Test/class
   properties
  property name=hibernate.dialect
 value=org.hibernate.dialect.Oracle10gDialect/
  property name=hibernate.connection.driver_class
 value=oracle.jdbc.OracleDriver/
  property name=hibernate.connection.username value=openejb/
  property name=hibernate.connection.password value=openejb/
  property name=hibernate.connection.url
 value=jdbc:oracle:thin:@192.168.2.96:1521:ORCL/
  property name=hibernate.max_fetch_depth value=3/
  !-- JPA Tools looks for this setting(?), so does not always drop
 the table as announced --
  property name=hibernate.hbm2ddl.auto value=update /
!--
  creates table at start and drops at the end!!
  property name=hibernate.hbm2ddl.auto value=create-drop /
--
  !-- cache configuration
  property
 name=hibernate.ejb.classcache.org.hibernate.ejb.test.Item
 value=read-write/
  property
 name=hibernate.ejb.collectioncache.org.hibernate.ejb.test.Item.distributors
 value=read-write, RegionName/
  --
 
  !-- alternatively to class and property declarations, you
 can use a regular hibernate.cfg.xml file --
  !-- property name=hibernate.ejb.cfgfile
 value=/org/hibernate/ejb/test/hibernate.cfg.xml/ --
   /properties
/persistence-unit
 /persistence
 
 Any help welcome.
 Thanks in advance.
 
 Jens Toerber
 
http://www.nabble.com/file/p20516594/openejb.log openejb.log 
http://www.nabble.com/file/p20516594/openejb.log openejb.log 
-- 
View this message in context: 
http://www.nabble.com/OpenEJB-on-Oracle-tp20294024p20516594.html
Sent from the OpenEJB User mailing list archive at Nabble.com.



OpenEJB on Oracle

2008-11-02 Thread JensToerber
/class
  properties
 property name=hibernate.dialect
value=org.hibernate.dialect.Oracle10gDialect/
 property name=hibernate.connection.driver_class
value=oracle.jdbc.OracleDriver/
 property name=hibernate.connection.username value=openejb/
 property name=hibernate.connection.password value=openejb/
 property name=hibernate.connection.url
value=jdbc:oracle:thin:@192.168.2.96:1521:ORCL/
 property name=hibernate.max_fetch_depth value=3/
 !-- JPA Tools looks for this setting(?), so does not always drop
the table as announced --
 property name=hibernate.hbm2ddl.auto value=update /
 !--
 creates table at start and drops at the end!!
 property name=hibernate.hbm2ddl.auto value=create-drop /
 --
 !-- cache configuration
 property
name=hibernate.ejb.classcache.org.hibernate.ejb.test.Item
value=read-write/
 property
name=hibernate.ejb.collectioncache.org.hibernate.ejb.test.Item.distributors
value=read-write, RegionName/
 --

 !-- alternatively to class and property declarations, you can
use a regular hibernate.cfg.xml file --
 !-- property name=hibernate.ejb.cfgfile
value=/org/hibernate/ejb/test/hibernate.cfg.xml/ --
  /properties
   /persistence-unit
/persistence

Any help welcome.
Thanks in advance.

Jens Toerber
-- 
View this message in context: 
http://www.nabble.com/OpenEJB-on-Oracle-tp20294024p20294024.html
Sent from the OpenEJB User mailing list archive at Nabble.com.