You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Bonnie MacKellar <BM...@mobius.com> on 2003/04/07 18:46:18 UTC

more problems with OJB 1.0, Weblogic, and MsSqlServer

I have finally reached the point where I am debugging problems with OJB (as
opposed
to XML errors).

I am fundamentally confused about something. I am trying to use OJB in a
servlet (JSP),
using JNDI and JTA, with Weblogic 7 as the app server. Note that we are NOT
using
EJBs. Which set of deployment instructions should I follow, the ones for
setting up
servlets or the ones for deploying under Weblogic? Currently, I am following
both
as much as possible. But for example, the Weblogic instructions talk about
compiling
a startup class - does that apply to me? I would not have thought so.

I am trying to connect with this simple code :
PersistenceBroker broker = null;
    try
    {
        broker = PersistenceBrokerFactory.
                    defaultPersistenceBroker();
                    
        Query query = new QueryByCriteria(People.class, null);
        

I get the following exception

[org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl] WARN: ### No
'def
ault' jdbc-connection-descriptor defined, you could not use the
'defaultPersiste
nceBroker()' method ###
org.apache.ojb.broker.PBFactoryException: There was no default-PBKey
specified
        at
org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl.defaultP
ersistenceBroker(Unknown Source)
        at
org.apache.ojb.broker.PersistenceBrokerFactory.defaultPersistenceBrok
er(Unknown Source)
        at DatabaseAccess.Database.hitDatabase(Database.java:29)
        at jsp_servlet.__tryojb._jspService(__tryojb.java:91)
        at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
        at
weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1058)
        at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:401)
        at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:445)
        at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:306)
        at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:5412)
        at
weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:744)
        at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:3086)
        at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2544)
        at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
        at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:

I have this entry in repository_database.xml :


   <!-- Datasource example -->
    <!-- jdbc-connection-descriptor
        jcd-alias="default"
        default-connection="true"
   		platform="MsSqlServer"
   		jdbc-level="2.0"
   		jndi-datasource-name="OJBTXDataSource"
   		username="admin"
   		password="ActiveBill"
		eager-release="false"
        batch-mode="false"
        useAutoCommit="0"
        ignoreAutoCommitExceptions="false"
   >
        <sequence-manager
className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl">
            <attribute attribute-name="grabSize" attribute-value="20"/>
        </sequence-manager>

In OJBProperties.xml, I have set
ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFactoryMa
nagedImpl

and
OJBTxManagerClass=org.apache.ojb.odmg.JTATxManager
JTATransactionManagerClass=org.apache.ojb.odmg.transaction.WeblogicTransacti
onManagerFactory

and
ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCachePerBrokerImpl

Am I approaching this the right way?

thanks,
Bonnie MacKellar

Re: more problems with OJB 1.0, Weblogic, and MsSqlServer

Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Bonnie,

----- Original Message -----
From: "Bonnie MacKellar" <BM...@mobius.com>
To: <oj...@db.apache.org>
Sent: Monday, April 07, 2003 6:46 PM
Subject: more problems with OJB 1.0, Weblogic, and MsSqlServer


>
> I have finally reached the point where I am debugging problems with
OJB (as
> opposed
> to XML errors).
>
> I am fundamentally confused about something. I am trying to use OJB in
a
> servlet (JSP),
> using JNDI and JTA, with Weblogic 7 as the app server. Note that we
are NOT
> using
> EJBs. Which set of deployment instructions should I follow, the ones
for
> setting up
> servlets or the ones for deploying under Weblogic? Currently, I am
following
> both
> as much as possible. But for example, the Weblogic instructions talk
about
> compiling
> a startup class - does that apply to me? I would not have thought so.

You don't have to bind a Startup class to JNDI, it's possible to use
the PB-api as in your example.

If you use extern transaction control (means container managed tx or
UserTransaction) then use the ConnectionFactoryManagedImpl,
this implementation ignores OJB's intern commit calls. Otherwise use
the ConnectionFactoryPooledImpl / ConnectionFactoryNotPooledImpl.

Same thing for OJBTxManagerClass, use org.apache.ojb.odmg.JTATxManager
if tx was controlled by appServer, else use the local version.

Rest of the configuration properties looks fine (hope so).

>
> I am trying to connect with this simple code :
> PersistenceBroker broker = null;
>     try
>     {
>         broker = PersistenceBrokerFactory.
>                     defaultPersistenceBroker();
>
>         Query query = new QueryByCriteria(People.class, null);
>
>
> I get the following exception
>
> [org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl] WARN:
### No
> 'def
> ault' jdbc-connection-descriptor defined, you could not use the
> 'defaultPersiste
> nceBroker()' method ###
> org.apache.ojb.broker.PBFactoryException: There was no default-PBKey
> specified

Strange, because your jdbc-connection-descriptor
set 'default-connection="true"'. Does OJB found the
correct repository file?
Did you have tried using the jcd-alias name?
broker = PersistenceBrokerFactory.
                     createPersistenceBroker(new PBKey("default"));

or better change the jcd-alias name and try again.

regards,
Armin




>         at
> org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl.defaultP
> ersistenceBroker(Unknown Source)
>         at
> org.apache.ojb.broker.PersistenceBrokerFactory.defaultPersistenceBrok
> er(Unknown Source)
>         at DatabaseAccess.Database.hitDatabase(Database.java:29)
>         at jsp_servlet.__tryojb._jspService(__tryojb.java:91)
>         at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
>         at
> weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
> (ServletStubImpl.java:1058)
>         at
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
> pl.java:401)
>         at
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
> pl.java:445)
>         at
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
> pl.java:306)
>         at
> weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
> n.run(WebAppServletContext.java:5412)
>         at
> weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
> eManager.java:744)
>         at
> weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
> rvletContext.java:3086)
>         at
> weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
> pl.java:2544)
>         at
weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
>         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:
>
> I have this entry in repository_database.xml :
>
>
>    <!-- Datasource example -->
>     <!-- jdbc-connection-descriptor
>         jcd-alias="default"
>         default-connection="true"
>    platform="MsSqlServer"
>    jdbc-level="2.0"
>    jndi-datasource-name="OJBTXDataSource"
>    username="admin"
>    password="ActiveBill"
> eager-release="false"
>         batch-mode="false"
>         useAutoCommit="0"
>         ignoreAutoCommitExceptions="false"
>    >
>         <sequence-manager
>
className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImp
l">
>             <attribute attribute-name="grabSize"
attribute-value="20"/>
>         </sequence-manager>
>
> In OJBProperties.xml, I have set
>
ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFacto
ryMa
> nagedImpl
>
> and
> OJBTxManagerClass=org.apache.ojb.odmg.JTATxManager
>
JTATransactionManagerClass=org.apache.ojb.odmg.transaction.WeblogicTrans
acti
> onManagerFactory
>
> and
> ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCachePerBrokerImpl
>
> Am I approaching this the right way?
>
> thanks,
> Bonnie MacKellar
>