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\org.apache.openejb.tomcat\META-INF.

Until now i had no time to test OpenEJB with
Transaction-Logger-Configuration-Workaround. I'll do this if i am ready with
my first step and try to get the application running on Tomcat with OpenEJB.

Best regards,

Jens Törber

David Blevins wrote:
> 
> (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
> 
> 
> 
http://www.nabble.com/file/p21196502/openejb.xml openejb.xml 
-- 
View this message in context: 
http://www.nabble.com/OpenEJB-on-Oracle-tp20294024p21196502.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to