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/07/03 17:19:23 UTC
ojb.properties, weblogic, and threads
I thought I had worked all the bugs out of my Weblogic-with-OJB
configuration,
but I guess I was wrong.
I am using Weblogic to run a servlet which calls a simple test application.
As long as access is done in a single thread, there is no problem.
But when I spawn a new thread, and try to retrieve a broker within the new
thread, I get an exception indicating that OJB.properties cannot be found.
I would have thought this is a simple classpath problem, except that
there is no problem obtaining a broker in the orginating thread. Has anyone
encountered this before?
I have my OJB.properties, repository files and compiled class files in
C:\bea\user_projects\bonnie\applications\ActiveBill\WEB-INF\classes
where ActiveBill is the deployed application. I am not using a startup
class to bind the OJB.properties location, because I was told at some
point that this is not needed for a strictly servlet based application (no
EJBs).
Here is the code :
public class AccountUpdater extends Thread
{
private PersistenceBroker broker = null;
public void run()
{
for (int i=0;i<10;i++)
{
try
{
broker = PersistenceBrokerFactory.defaultPersistenceBroker();
broker.beginTransaction();
AccountInterface acc = retrieveAccountByNumber("1234");
broker.commitTransaction();
}
catch (Exception e)
{
broker.abortTransaction();
System.out.print(e.getMessage());
e.printStackTrace();
}
finally {
broker.close();
}
}
}
The exception is thrown at the line which calls defaultPersistenceBroker()
Here is the exception :
[BOOT] ERROR: Cannot get OJB properties file, use default settings!
[org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl] INFO: Create
Pers
istenceBroker instance pool, pool configuration was {whenExhaustedAction=0,
maxI
dle=-1, maxActive=21, maxWait=5000, removeAbandoned=false,
numTestsPerEvictionRu
n=10, testWhileIdle=false, minEvictableIdleTimeMillis=600000,
testOnReturn=false
, logAbandoned=false, removeAbandonedTimeout=300,
timeBetweenEvictionRunsMillis=
-1, testOnBorrow=false}
[org.apache.ojb.broker.metadata.RepositoryPersistor] INFO: OJB Descriptor
Reposi
tory: file:/C:/bea/user_projects/bonnie/repository.xml
java.lang.NullPointerException
at dbtests.AccountUpdater.run(AccountUpdater.java:64)
in testDatabase
accessed the database
in AccountUpdater.run
will try to get a broker
java.lang.NullPointerException
at dbtests.AccountUpdater.run(AccountUpdater.java:64)
thanks,
Bonnie MacKellar
software engineer
Mobius Management Systems, Inc.
bmackell@mobius.com