Hi again,

i got it partly working on Oracle database.

My problem was, that my <Resource .../>.declaration in openejb.xml was wrong
(Tomcat-Resource style, shame on me, but good to have the xsd now) and
openejb switched to the default datasource. I don't know if i like this
behaviour with no at least WARN entry in openejb.log.

I upgraded to openejb-3.1 now.

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.

Now i have the attached config: openejb.xml

As you can see i removed the default datasources and added my Oracle
datasources. If you remove the default datasources you also have to
configure ActiveMQ for the new Datasource:
See
...
<Resource id="My JMS Resource Adapter" type="ActiveMQResourceAdapter">
...

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

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.

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

In the Examples the JpaBean is not working on Oracle, because the
GeneratorType is AUTO -> IDENTITY. I switched this to Sequence, otherwise
you need a trigger or something like that on the Oracle table to generate
the Primary Key-Value.

Therefore the JpaServlet-Sample is designed for RESOURCE_LOCAL
(emf.createEntityManager() is called) and for Databases with AUTO-Increment
PKs.

Then i tried to get my application working.
Injection in MyFaces 1.2.x (downloaded dummy.war by K??) and Servlet of
Local-Stateless SessionBean is working or JNDI-Lookup:

@EJB(beanName="CategoryDao")
        private CategoryDaoLocal categoryDaoLocal;
        
        public CategoryDaoLocal getCategoryDaoLocal() {
                return categoryDaoLocal;
        }

        public void setCategoryDaoLocal(CategoryDaoLocal categoryDaoLocal) {
                this.categoryDaoLocal = categoryDaoLocal;
        }
        
        /**
         * spring
         * <bean id="calculator" 
        class="org.springframework.jndi.JndiObjectFactoryBean"> 
        <property name="jndiName" value="CalculatorLocal"/> 
        <property name="jndiEnvironment"> 
            <props> 
                <prop key="java.naming.factory.initial"> 
                    org.apache.openejb.client.LocalInitialContextFactory 
                </prop> 
            </props> 
        </property> 
                </bean>
         */
        @Override
        protected void service(HttpServletRequest request, HttpServletResponse
response)
                        throws ServletException, IOException {
                PrintWriter out = response.getWriter();
                
                Context ctx = null;
                Properties jndiEnv = new Properties(); 
                jndiEnv.setProperty("java.naming.factory.initial",
"org.apache.openejb.client.LocalInitialContextFactory"); 

                try {
                        ctx = new InitialContext(jndiEnv);
                        Object obj = ctx.lookup("CategoryDaoLocal");
                        if (obj != null) {
                                if (obj instanceof CategoryDaoLocal) {
                                        this.categoryDaoLocal = 
(CategoryDaoLocal) obj;
                                } else {
                                        out.println("obj is not instanceof 
CategoryDaoLocal");
                                }
                        } else {
                                out.println("obj is null");
                        }
                } catch (NamingException ex) {
                        ex.printStackTrace(out);
                }
                if (this.categoryDaoLocal != null) {
                        Category category = new Category();
                        category.setCategory("category");
                        // currently tomcat exceptions during this call, so 
lookup works:
                        this.categoryDaoLocal.persist(category);
                        out.println("<h1>categoryId: " + 
category.getCategoryId() + "</h1>");
                } else {                        
                        out.println("<h1>categoryDaoLocal is null</h1>");
                }
        }

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.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:191)
        at
org.apache.openejb.tomcat.catalina.OpenEJBValve.invoke(OpenEJBValve.j
ava:45)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:128)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:102)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:286)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:845)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ss(Http11Protocol.java:583)
        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
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
        at java.util.concurrent.FutureTask.run(FutureTask.java:123)
        at org.apache.openejb.util.Memoizer.compute(Memoizer.java:49)
        ... 27 more
java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException:
can
't parse argument number
        at
java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:205)
        at java.util.concurrent.FutureTask.get(FutureTask.java:80)
        at org.apache.openejb.util.Memoizer.compute(Memoizer.java:53)
        at org.apache.openejb.util.Logger.formatMessage(Logger.java:185)
        at org.apache.openejb.util.Logger.debug(Logger.java:234)
        at
org.apache.openejb.core.transaction.JtaTransactionPolicy.beginTransac
tion(JtaTransactionPolicy.java:235)
        at
org.apache.openejb.core.transaction.TxRequired.<init>(TxRequired.java
:54)
        at
org.apache.openejb.core.transaction.JtaTransactionPolicyFactory.creat
eTransactionPolicy(JtaTransactionPolicyFactory.java:36)
        at
org.apache.openejb.core.transaction.EjbTransactionUtil.createTransact
ionPolicy(EjbTransactionUtil.java:55)
        at
org.apache.openejb.core.stateless.StatelessContainer._invoke(Stateles
sContainer.java:200)
        at
org.apache.openejb.core.stateless.StatelessContainer.invoke(Stateless
Container.java:169)
        at
org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbO
bjectProxyHandler.java:217)
        at
org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectPr
oxyHandler.java:77)
        at
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHa
ndler.java:286)
        at $Proxy67.persist(Unknown Source)
        at
info.toerber.web.servlets.TestServlet.service(TestServlet.java:77)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:233)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:191)
        at
org.apache.openejb.tomcat.catalina.OpenEJBValve.invoke(OpenEJBValve.j
ava:45)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:128)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:102)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:286)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:845)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ss(Http11Protocol.java:583)
        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
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
        at java.util.concurrent.FutureTask.run(FutureTask.java:123)
        at org.apache.openejb.util.Memoizer.compute(Memoizer.java:49)
        ... 27 more
java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException:
can
't parse argument number
        at
java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:205)
        at java.util.concurrent.FutureTask.get(FutureTask.java:80)
        at org.apache.openejb.util.Memoizer.compute(Memoizer.java:53)
        at org.apache.openejb.util.Logger.formatMessage(Logger.java:185)
        at org.apache.openejb.util.Logger.debug(Logger.java:234)
        at
org.apache.openejb.core.transaction.JtaTransactionPolicy.beginTransac
tion(JtaTransactionPolicy.java:235)
        at
org.apache.openejb.core.transaction.TxRequired.<init>(TxRequired.java
:54)
        at
org.apache.openejb.core.transaction.JtaTransactionPolicyFactory.creat
eTransactionPolicy(JtaTransactionPolicyFactory.java:36)
        at
org.apache.openejb.core.transaction.EjbTransactionUtil.createTransact
ionPolicy(EjbTransactionUtil.java:55)
        at
org.apache.openejb.core.stateless.StatelessContainer._invoke(Stateles
sContainer.java:200)
        at
org.apache.openejb.core.stateless.StatelessContainer.invoke(Stateless
Container.java:169)
        at
org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbO
bjectProxyHandler.java:217)
        at
org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectPr
oxyHandler.java:77)
        at
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHa
ndler.java:286)
        at $Proxy67.persist(Unknown Source)
        at
info.toerber.web.servlets.TestServlet.service(TestServlet.java:77)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:233)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:191)
        at
org.apache.openejb.tomcat.catalina.OpenEJBValve.invoke(OpenEJBValve.j
ava:45)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:128)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:102)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:286)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:845)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ss(Http11Protocol.java:583)
        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
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
        at java.util.concurrent.FutureTask.run(FutureTask.java:123)
        at org.apache.openejb.util.Memoizer.compute(Memoizer.java:49)
        ... 27 more
java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException:
can
't parse argument number
        at
java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:205)
        at java.util.concurrent.FutureTask.get(FutureTask.java:80)
        at org.apache.openejb.util.Memoizer.compute(Memoizer.java:53)
        at org.apache.openejb.util.Logger.formatMessage(Logger.java:185)
        at org.apache.openejb.util.Logger.debug(Logger.java:234)
        at
org.apache.openejb.core.transaction.JtaTransactionPolicy.beginTransac
tion(JtaTransactionPolicy.java:235)
        at
org.apache.openejb.core.transaction.TxRequired.<init>(TxRequired.java
:54)
        at
org.apache.openejb.core.transaction.JtaTransactionPolicyFactory.creat
eTransactionPolicy(JtaTransactionPolicyFactory.java:36)
        at
org.apache.openejb.core.transaction.EjbTransactionUtil.createTransact
ionPolicy(EjbTransactionUtil.java:55)
        at
org.apache.openejb.core.stateless.StatelessContainer._invoke(Stateles
sContainer.java:200)
        at
org.apache.openejb.core.stateless.StatelessContainer.invoke(Stateless
Container.java:169)
        at
org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbO
bjectProxyHandler.java:217)
        at
org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectPr
oxyHandler.java:77)
        at
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHa
ndler.java:286)
        at $Proxy67.persist(Unknown Source)
        at
info.toerber.web.servlets.TestServlet.service(TestServlet.java:77)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:233)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:191)
        at
org.apache.openejb.tomcat.catalina.OpenEJBValve.invoke(OpenEJBValve.j
ava:45)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:128)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:102)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:286)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:845)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ss(Http11Protocol.java:583)
        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
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
        at java.util.concurrent.FutureTask.run(FutureTask.java:123)
        at org.apache.openejb.util.Memoizer.compute(Memoizer.java:49)
        ... 27 more
java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException:
can
't parse argument number
        at
java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:205)
        at java.util.concurrent.FutureTask.get(FutureTask.java:80)
        at org.apache.openejb.util.Memoizer.compute(Memoizer.java:53)
        at org.apache.openejb.util.Logger.formatMessage(Logger.java:185)
        at org.apache.openejb.util.Logger.debug(Logger.java:234)
        at
org.apache.openejb.core.transaction.JtaTransactionPolicy.beginTransac
tion(JtaTransactionPolicy.java:235)
        at
org.apache.openejb.core.transaction.TxRequired.<init>(TxRequired.java
:54)
        at
org.apache.openejb.core.transaction.JtaTransactionPolicyFactory.creat
eTransactionPolicy(JtaTransactionPolicyFactory.java:36)
        at
org.apache.openejb.core.transaction.EjbTransactionUtil.createTransact
ionPolicy(EjbTransactionUtil.java:55)
        at
org.apache.openejb.core.stateless.StatelessContainer._invoke(Stateles
sContainer.java:200)
        at
org.apache.openejb.core.stateless.StatelessContainer.invoke(Stateless
Container.java:169)
        at
org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbO
bjectProxyHandler.java:217)
        at
org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectPr
oxyHandler.java:77)
        at
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHa
ndler.java:286)
        at $Proxy67.persist(Unknown Source)
        at
info.toerber.web.servlets.TestServlet.service(TestServlet.java:77)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:233)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:191)
        at
org.apache.openejb.tomcat.catalina.OpenEJBValve.invoke(OpenEJBValve.j
ava:45)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:128)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:102)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:286)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:845)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ss(Http11Protocol.java:583)
        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
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
        at java.util.concurrent.FutureTask.run(FutureTask.java:123)
        at org.apache.openejb.util.Memoizer.compute(Memoizer.java:49)
        ... 27 more
java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException:
can
't parse argument number
        at
java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:205)
        at java.util.concurrent.FutureTask.get(FutureTask.java:80)
        at org.apache.openejb.util.Memoizer.compute(Memoizer.java:53)
        at org.apache.openejb.util.Logger.formatMessage(Logger.java:185)
        at org.apache.openejb.util.Logger.debug(Logger.java:234)
        at
org.apache.openejb.core.transaction.JtaTransactionPolicy.beginTransac
tion(JtaTransactionPolicy.java:235)
        at
org.apache.openejb.core.transaction.TxRequired.<init>(TxRequired.java
:54)

a) It's only logged to the Console in Tomcat, so had some trouble to get
this log.
b) I tried to change it according to the testing-transactions in the
openejb-examples-1.0. But i got the same Exceptions.

I'll attach my persistence.xml, CategoryDao and CategoryDaoLocal. There is
no WARN, ERROR, ... entry for this in openejb.log. 

I was a little confused what went wrong and therefore looked for a simple
JNDI-Lookup sample to be sure that Injection works. I agree that support is
very good and quick as mentioned there.

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)

Our application is currently running on JBoss 4.2.2. @EJB is not currently
working there in Servlet-Engine, but in this context and my collegue is
looking forward to this feature. Currently we are doing this by Spring
JNDI-Factory-Bean.

One of our customers insists on Tomcat and not to use JBoss. So still some
work to do.

In different project we want to save system resources. So would be great to
get this environment working.

Any help appreciated.

Thanks in advance.

Best regards,

JT


David Blevins wrote:
> 
> On Nov 15, 2008, at 7:42 AM, JensToerber wrote:
> 
>> During start of tomcat with openejb ejb-examples-1.0 Web-App  
>> deployed i get
>> the attached openejb.log.
> 
> Looking at your log file it seems you still have the HQSL data sources  
> configured and active in your openejb.xml:
> 
> 2008-11-15 16:30:03,000 - INFO  - Configuring Service(id=My  
> DataSource, type=Resource, provider-id=Default JDBC Database)
> 2008-11-15 16:30:03,000 - INFO  - Configuring Service(id=OracleORCL,  
> type=Resource, provider-id=Default JDBC Database)
> 2008-11-15 16:30:03,000 - INFO  - Configuring  
> Service(id=OracleORCLUnmanaged, type=Resource, provider-id=Default  
> JDBC Database)
> 2008-11-15 16:30:03,000 - INFO  - Configuring Service(id=My Unmanaged  
> DataSource, type=Resource, provider-id=Default JDBC Database)
> 
> If you delete "My DataSource" and "My Unmanaged DataSource" everything  
> will likely just work.  We don't need them for anything and are only  
> there to demonstrate a working setup.
> 
> It should work with them in the openejb.xml, but then you have to  
> either a) move the oracle datasource declarations to the top so we  
> know those are your preferred default datasources, or b) list <jta- 
> data-source>OracleORCL</jta-data-source> and <non-jta-data- 
> source>OracleORCLUnmanaged</non-jta-data-source> in your persistence- 
> unit.
> 
> Really, before reading further I would:
> 
>    1. Replace the openejb 3.0 war with the openejb 3.1 war (better  
> logging, really helps us find issues)
>    2. Delete the unneeded <Resource> declarations from tomcat.base/ 
> conf/openejb.xml
>    3. Make sure your persistence.xml uses the <Resource> declared for  
> <jta-data-source> and <non-jta-data-source> (do *not* use  
> openjpa.ConnectionDriverName)
> 
> That should be good right there.  If that doesn't work, try the  
> example I've included at the bottom.  If that's not clear enough, post  
> your log, openejb.xml, and persistence.xml
> 
> 
>> In Tomcat this is not possible:
>>
>> <persistence-unit transaction-type="JTA" name="jpa-example">
>>    <class>org.superbiz.servlet.JpaBean</class>
>>
>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</ 
>> provider>
>>        <properties>
>>            <property name="openjpa.jdbc.SynchronizeMappings"
>>                      value="buildSchema"/>
>>          <property name="openjpa.ConnectionURL"
>>                       
>> value="jdbc:oracle:thin:@192.168.2.96:1521:orcl"/>
>>
>>            <property name="openjpa.ConnectionDriverName"
>>                      value="oracle.jdbc.OracleDriver"/>
>>              <!-- don't specify a username/password otherwise:
>>              java.lang.UnsupportedOperationException: Not supported by  
>> BasicDataSource
>>      at
>> org 
>> .apache 
>> .commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:902)
>> -->
>>            <property name="openjpa.ConnectionUserName"
>>                      value="openejb"/>
>>
>>            <property name="openjpa.ConnectionPassword"
>>                      value="openejb"/>
>>
>>        </properties>
>>  </persistence-unit>
>>
>> I created my own standalone test application with a BasicDataSource  
>> and i am
>> able to connect to Oracle. Tomcat does not seem to allow this in its  
>> own
>> environment with a username and password.
> 
> Right, and adding connection information other than <jta-data-source>  
> or <non-jta-data-source>OracleORCLUnmanaged</non-jta-data-source> in  
> your persistence-unit declaration is almost guaranteed not to work.   
> I've just created a JIRA
> (https://issues.apache.org/jira/browse/OPENEJB-959 
> ) so we can add some checking to make sure people are not supplying  
> things like "openjpa.ConnectionURL" and equivalent.  Hopefully that  
> will help future users from going off the beaten path.
> 
>> 4.) @PersistenceContext -> persistence.xml -> <tomcat_home>/conf/ 
>> openejb.xml
>> (the simplest solution i guess)
> 
> This is the preferred way.
> 
>> Is there an openejb.xsd for openejb.xml (Tomcat has its  
>> <Resource ... > and
>> Openejb its <Resource ...> but different)?
> 
> Here's a schema: 
> http://svn.apache.org/repos/asf/openejb/tags/openejb-3.0/container/openejb-core/src/main/resources/schema/openejb.xsd
> 
> Though the real information you want is likely here:
> 
> http://openejb.apache.org/3.0/containers-and-resources.html#ContainersandResources-Resources
> 
>> Is it possible to take the
>> org.apache.openjpa.persistence.PersistenceProviderImpl to connect to  
>> Oracle
>> or only to HSQL?
> 
> Any db with a compliant driver will work.
> 
>> I tried to take Hibernate as the JPA-Provider, because i am really  
>> confused
>> right now. Got problems in getting running this because of  
>> incompatible
>> jars, so my problem.
> 
> Right, Hibernate uses an old version of ASM.  This was a real pain for  
> users so in OpenEJB 3.1 we essentially got rid of our dependency on  
> asm so there should be no issue.  But definitely don't do that now, I  
> suspect you'll be looking at a working example in no time.
> 
>> What is really confusing me is the following:
>> <persistence-unit transaction-type="JTA" name="jpa-example">
>>    <jta-data-source>OracleORCL</jta-data-source>
>>    <non-jta-data-source>OracleORCLUnmanaged</non-jta-data-source>
>>    <class>org.superbiz.servlet.JpaBean</class>
>>
>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</ 
>> provider>
>>    <properties>
>>            <property name="openjpa.jdbc.SynchronizeMappings"
>> value="buildSchema"/>
>>    </properties>
>> </persistence-unit>
>> (Btw. i changed the JpaServlet.java to work with a JTA managed
>> EntityManager)
>>
>> Currently i get a NullPointerException at
>>
>> EntityManager em = emf.createEntityManager();
>>
>> in JpaServlet (see second attached openejb.log).
> 
> That persistence-unit declaration looks spot on and should work given  
> the log output from the first log.  There is no second log, the first  
> one was listed twice, so I'm not sure what may have happened.
> 
>> With
>>    <jta-data-source>jdbc/myoracle</jta-data-source>
>>    <non-jta-data-source>jdbc/myoracle</non-jta-data-source>
>> (configured in <WEB-APP>/META-INF/context.xml:
>> <Resource name="jdbc/myoracle" auth="Container"
>>              type="javax.sql.DataSource"
>> driverClassName="oracle.jdbc.OracleDriver"
>>              url="jdbc:oracle:thin:@192.168.2.96:1521:orcl"
>>              username="openejb" password="openejb" maxActive="20"
>> maxIdle="10"
>>              maxWait="-1"/>)
>> i get a connection to a HSQL-DB?
> 
> This would work if the <Resource> was configured in the tomcat/conf/ 
> server.xml, but we don't yet have support for "webapp" resources being  
> exported (i.e. shared) to OpenEJB. Definitely something we plan to add  
> though.
> 
>> Does openejb take a default datasource (in openejb.xml) if a  
>> configured is
>> not found or wrong or ...?
>> I even tried to change the autoatically generated Datasource- 
>> Resources in
>> <tomcat_home>/conf/openejb.xml to Oracle and still got a HSQL(?).
> 
> So here is the logic we have for selecting a data source for the  
> persistence-unit.  First, if you added connection info via vendor  
> properties in your persistence-unit the persistence provider will  
> likely ignore the datasource we give it and create connections behind  
> our back resulting in nothing working.
> 
> Ideally, things should look like this:
> 
> {openejb.or.tomcat.base}/conf/openejb.xml
>   <Resource id="Orange" type="DataSource">
>     JdbcDriver = org.foo.OrangeDriver
>     JdbcUrl = jdbc:orange:some:stuff
>     JtaManaged = true
>   </Resource>
> 
>   <Resource id="OrangeUnmanaged" type="DataSource">
>     JdbcDriver = org.foo.OrangeDriver
>     JdbcUrl = jdbc:orange:some:stuff
>     JtaManaged = false
>   </Resource>
> 
> {app}/META-INF/persistence.xml
>   <persistence-unit name="orange-unit">
>        <jta-data-source>Orange</jta-data-source>
>        <non-jta-data-source>OrangeUnamanged</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.

Reply via email to