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 Ju...@Bertelsmann.de on 2003/06/23 12:17:04 UTC

Newbie: JBoss + MySQL

Hello,

I have some big newbie problems. Maybe anybody can help! I'm trying to use
the OJB ODMG API with a MySQL Database and JBoss (3.0.6). I have followed
the steps necessary for deploying OJB on JBoss. That means I created the
ojb.sar folder in the deploy folder an included the necessary files. My
repository_database.xml file contains the following entry:

<jdbc-connection-descriptor
	jcd-alias="default"
	default-connection="true"
	platform="MySQL"
	jdbc-level="2.0"
	jndi-datasource-name="java:DefaultDS"
   	driver="org.gjt.mm.mysql.Driver"
   	protocol="jdbc"
   	subprotocol="mysql"
   	dbalias="//localhost:3306/Monitoring"
   	username="monitor"
   	password="password"
      eager-release="true"
   	batch-mode="false"
      useAutoCommit="0"
      ignoreAutoCommitExceptions="false"
>
      <connection-pool
          maxActive="21"
          validationQuery="" />

      <sequence-manager
className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
          <attribute attribute-name="grabSize" attribute-value="20"/>
          <attribute attribute-name="autoNaming" attribute-value="true"/>
          <attribute attribute-name="globalSequenceId"
attribute-value="false"/>
          <attribute attribute-name="globalSequenceStart"
attribute-value="10000"/>
      </sequence-manager>
</jdbc-connection-descriptor>

The ODMG Factory gets started:

[PBFactory] Starting
[PBFactory] PBFactory: org.apache.ojb.jboss.PBFactory /
DefaultDomain:service=PBAPI,name=ojb/PBAPI
[PBFactory] Lookup PBFactory via 'java:/ojb/PBAPI'
[PBFactory] Started
[ODMGFactory] Starting
[STDOUT] ** OJB-ODMG MBean integration
[STDOUT] ** ODMGFactory: org.apache.ojb.jboss.ODMGFactory /
DefaultDomain:service=ODMG,name=ojb/defaultODMG
[STDOUT] ** Use ODMGFactory via lookup:
[STDOUT] ** ODMGFactory factory = (ODMGFactory)
ctx.lookup(java:/ojb/defaultODMG)
[STDOUT] ** Implementation odmg = factory.getInstance();
[ODMGFactory] Started

The Datasource is also bound:
[DefaultDS] Bound connection factory for resource adapter 'JBoss
LocalTransaction JDBC Wrapper' to JNDI name 'java:/DefaultDS'

I have written a web application, that I deploy on JBoss. It contains a
Servlet which is loaded on start up with the following init() methode (just
to test the connection):


***********************init-Methode*****************************************
*******
Context context = null;
try
{
  context = new InitialContext();
}
catch (NamingException e)
{
  logger.error(THIS_CLASS + "Could not instantiate InitialContext", e);
  throw new OJBRuntimeException("Could not instantiate InitialContext", e);
}

ODMGFactory factory = null;
try
{
  factory = (ODMGFactory) context.lookup("java:/ojb/defaultODMG");
}
catch (NamingException e)
{
  logger.error(THIS_CLASS + "ctx.lookup(java:/ojb/defaultODMG) failed", e);
  throw new OJBRuntimeException("Could not lookup ODMG factory instance",
e);
}

Implementation odmg = factory.getInstance();
logger.info(THIS_CLASS + "Found odmg factory: " + factory + " and get
Implementation instance: " + odmg);

Database db = odmg.newDatabase();
try
{
  db.open("default", Database.OPEN_READ_WRITE);
}
catch (ODMGException e)
{
  logger.error(THIS_CLASS + "Database open failed", e);
  throw new OJBRuntimeException("Unable to open database using ODMG api",
e);
}    
***********************init-Methode
END************************************************        

But when starting my JBoss this Servlet-init() methode never seems to get
reached. Instead I get the following errors:

[STDOUT] [org.apache.ojb.broker.core.NamingLocator] INFO: 
[STDOUT] Init NamingLocator
[STDOUT] [org.apache.ojb.broker.core.NamingLocator] INFO: 
[STDOUT] Properties for creating the initial context: null
[STDOUT] [org.apache.ojb.odmg.JTATxManager] ERROR: 
[STDOUT] Cannot get the external transaction from the external TM
[jbossweb] Stopped
WebApplicationContext[/monitoring,jar:file:/home/wink05/jboss-3.0.6/server/d
efault/tmp/deploy/server/default/deploy/dev-monitoring.war/38.dev-monitoring
.war!/]
.....
...



So what am I doing wrong?? 

Thanks in advance, Julia.

abort transaction causes TransactionNotInProgressException

Posted by Joerg Lensing <in...@softcon-lensing.de>.
Hello,
pleas look at this code:

        Transaction tx = getActiveTransaction();
        if(tx.isOpen()) {
            tx.abort();
        }


this causes :

[org.apache.ojb.odmg.TransactionImpl] INFO: Abort transaction was called 
on tx org.apache.ojb.odmg.TransactionImpl@c9161b, associated PB was 
org.apache.ojb.broker.core.PoolablePersistenceBroker@7a9c0f
2003-06-23 13:47:58,031 WARN  - Unhandled Exception thrown: class 
org.odmg.TransactionNotInProgressException


what am I doing wrong?

joerg