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.
b) You have to be very careful with the properties:
# "25" not allowed, not even 25<blank>, but
        mail.smtp.port=25
# "smtp" not allowed, not even smtp<blank>!!
        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.

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

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-sql>begin 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.

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.

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).

Best regards,

Jens


Hi altogether,

i am using OpenEJB 3.x as standalone edition for JUnit tests and i tried to
get OpenEJB Examples running on Tomcat 6.0.x. on Oracle 10g.

I have problems configuring the persistence units and/or datasources. I am
not quite sure what the problem is:

persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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";>
        <!--
        only one persistence unit per project by JPA Tools supported
        -->
        <!--
        <persistence-unit name="JPATestProject">
        </persistence-unit>
        -->
        <persistence-unit name="beds_pu" transaction-type="JTA">
                <provider>org.hibernate.ejb.HibernatePersistence</provider>
                <jta-data-source>OracleORCL</jta-data-source>
                <non-jta-data-source>OracleORCLUnmanaged</non-jta-data-source> 
        <class>info.toerber.beds.model.Test</class>
        </persistence-unit>
</persistence>

in one of my session beans i am declaring a datasource like:
@Resource(name="OracleORCL")
    DataSource dataSource;

In standalone for JUnit-Test it seems to be that OpenEJB always takes its
default Database HSQL.
Is this correct?
Is it possible to change this to an Oracle Datasource?

here is my openejb.xml in META-INF for standalone and in <tomcat>/conf for
Tomcat deployment:
<openejb>
        <Resource id="OracleORCL" type="DataSource">
    #  Oracle example
    #
    #  This connector will not work until you download the driver at:
    #  http://otn.oracle.com/software/tech/java/sqlj_jdbc/content.html
    JdbcDriver  oracle.jdbc.OracleDriver
    JdbcUrl     jdbc:oracle:thin:@192.168.2.96:1521:ORCL
    UserName    openejb
    Password    openejb
        JtaManaged true
</Resource>
<Resource id="OracleORCLUnmanaged" type="DataSource">
    #  Oracle example
    #
    #  This connector will not work until you download the driver at:
    #  http://otn.oracle.com/software/tech/java/sqlj_jdbc/content.html
    JdbcDriver  oracle.jdbc.OracleDriver
    JdbcUrl     jdbc:oracle:thin:@192.168.2.96:1521:ORCL
    UserName    openejb
    Password    openejb
        JtaManaged  false
</Resource>
</openejb>

The examples are running in Tomcat, but always on HSQL as i can see with

if (this.entityManager != null) {
                                Object delegate = 
this.entityManager.getDelegate();
                                if (delegate instanceof HibernateEntityManager) 
{
                                                HibernateEntityManager 
hibernateEntityManager =
(HibernateEntityManager) delegate;
                                                Session s = 
hibernateEntityManager.getSession();
                                                Connection conn = 
s.connection();
                                                inspectConnection(conn);

private void inspectConnection(Connection conn) throws SQLException {
                DatabaseMetaData dataBaseMetaData = conn.getMetaData();
                // The drivers are included with OpenEJB 3.0 and HSQLDB is the 
default
database.
                System.out.println(dataBaseMetaData.getDatabaseMajorVersion());
                System.out.println(dataBaseMetaData.getDatabaseMinorVersion());
                System.out.println(dataBaseMetaData.getDatabaseProductName());
                
System.out.println(dataBaseMetaData.getDatabaseProductVersion());
                
System.out.println(dataBaseMetaData.getDefaultTransactionIsolation());
                System.out.println(dataBaseMetaData.getDriverMajorVersion());
                System.out.println(dataBaseMetaData.getDriverMinorVersion());
                System.out.println(dataBaseMetaData.getDriverName());
                System.out.println(dataBaseMetaData.getDriverVersion());

I could change the default Persistence Provider, but it's not running on my
Oracle Datasource.
Looked in the documentation and i can see that HSQL is the default database.
But how and where can i change it always or for a specific persistence unit
or for a resource in standalone and/or Tomcat?

Btw. the persistence unit works if i take this in Eclipse JPA Tools:
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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";>
        <!--
        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">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <!-- use persistence.xml right mouse Synchronize classes to get actual
list -->
      <class>info.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/p21552884/TimerBean.java TimerBean.java 
http://www.nabble.com/file/p21552884/TimerBeanLocal.java TimerBeanLocal.java 
http://www.nabble.com/file/p21552884/TimerServletContextListener.java
TimerServletContextListener.java 
http://www.nabble.com/file/p21552884/TimerBeanLocalTest.java
TimerBeanLocalTest.java 
-- 
View this message in context: 
http://www.nabble.com/OpenEJB-on-Oracle-tp20294024p21552884.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to