Here's an example from the archives on how to do it with weblogic. Only
catch is a transactional datasource has to be used. Have you seen this ??
Hi Patrick,
The following works
(on Weblogic 5.1 sp 10)
//////////////// START ////////////////////////
package top.secret.config.
import java.util.Hashtable;
import weblogic.common.*;
import javax.naming.InitialContext;
import javax.naming.Context;
import java.io.PrintWriter;
import org.exolab.castor.jdo.JDO;
import org.exolab.castor.util.Logger;
public class ConfigureJDO implements T3StartupDef
{
public static final String wlTransactionManager
= "weblogic/transaction/TransactionManager";
public static final String databaseName = "OEMREP";
public static final String jndiName = "dashboard-jdo";
public static final String dbConfigFileKey
= "databaseConfigurationFile";
public ConfigureJDO() { }
private T3ServicesDef services;
public void setServices(T3ServicesDef srvcs)
{
services = srvcs;
}
public String startup(String name,Hashtable args)
throws Exception
{
String loggingKey = "ConfigureJDO.startup()";
InitialContext context = new InitialContext();
JDO jdo = null;
String dbConfigFile = "database.xml";
// look for a database configuration file arg
if (args != null && args.containsKey(dbConfigFileKey))
dbConfigFile = (String)args.get(dbConfigFileKey);
System.out.println(loggingKey+" >> creating new jdo");
System.out.println(loggingKey+" >> using db configuration file
"+dbConfigFile);
PrintWriter writer = new Logger(System.out).setPrefix(jndiName);
ClassLoader klassLoader = this.getClass().getClassLoader();
// create a new JDO
jdo = new JDO();
jdo.setClassLoader(klassLoader);
jdo.setLogWriter(writer);
jdo.setConfiguration(getClass
().getResource(dbConfigFile).toString());
jdo.setDatabaseName(databaseName);
jdo.setTransactionManager(wlTransactionManager);
// register JDO in JNDI
System.out.println(loggingKey+" >> binding jdo to jndi as "
+jndiName);
try
{
context.bind(jndiName,jdo);
}
catch (Exception e)
{
System.out.println(e);
}
return "jdo created and bound to jndi";
}
}
////////////////// END //////////////////////////
we have this class in a jar file along with a database.xml file and a
mapping.xml. We deploy this "config" jar in our weblogic class path and
access and initialize it from the weblogic.properties file like so..
weblogic.system.startupClass.configureJDO=top.secret.config.ConfigureJDO
#weblogic.system.startupArgs.configureJDO=databaseConfigurationFile=database
.xml
Also something to keep in mind about EJBs, Transactions, and Weblogic. We
ran into a totally bizarre bug a while back (with BMP entity beans using
castor). ejbc was succeeding but it was generating incorrect code. i.e.
ejbCreate did not have a transaction (getTransaction was failing) even tho
our transaction descriptor was "required". It turns out that while
ejbcing,
weblogic/classes was in our ejbc class path before the weblogic jar files
and it was causing this to happen. Changing them around fixed this
problem.
Presumably because this was a bug that shipped with WL 5.1 and was fixed in
one of the service packs (service pack jars).
Hope this helps.
-shehryar
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 14, 2001 10:42 PM
To: [EMAIL PROTECTED]
Subject: [castor-dev] Castor configuration in WebLogic
Good morning,
I already wrote about the problems I'm experiencing with transactions using
Castor with WebLogic.
First of all, thanks to all who wrote me. Unfortunately I've still have
this problem so I want to post my question using other words:
Does somebody know how to configure the JDO object to work with Weblogic
application server (I saw how to write the database.xml file to point to
the JNDI datasource, but I don't know how to register the object in JNDI,
...)
Thanks a lot and bye
Patrick
Patrick Herber
Software Engineer
CSC Switzerland AG
Technologie und Softwareentwicklung
Binzm�hlestrasse 14
CH-8050 Z�rich
Phone: +41 (0)1 307 26 53
Fax: +41 (0)1 307 22 10
Mobile: +41 (0)79 211 35 01
E-Mail: [EMAIL PROTECTED]
http://www.ch.csc.com/
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
References:
Castor configuration in WebLogic
From: [EMAIL PROTECTED]
Prev by Date: Re: [castor-dev] Referencing 'type' in external mapping
file
Next by Date: RE: [castor-dev] Anyone know of any performance issues
with Casto r?
Prev by thread: Castor configuration in WebLogic
Next by thread: Unmarshalling unknown java
Index(es):
Date
Thread
Gabor Dolla
<agdolla@grav To: [EMAIL PROTECTED]
iton.hu> cc:
Subject: Re: [castor-dev] castor jdo &
ibm websphere
12/03/2001
02:43 PM
Please
respond to
castor-dev
>
> We used toplink on the websphere project. The problem we had was
probably
> a db2 driver issue. A rollback exception was thrown when a commit was
> attempted. That may or may not be the problem here.
>
> Have you been able to bind a jdo to the jndi ??
>
I used Castor with JBoss with no problem. JBoss has a module which
does it all. It initializes Castor, binds it to jndi, from a client
I can look it up, and use it.
For websphere there is no such module. I tried to use the JBoss module, but
I can not make it work. The original module assigns a name to the JDO
instance (JDO.setTransactionManager), then Castor looks it up with jndi
and use it. With websphere TransactionManager can not be found with
jndi (or at least I can not find it). If I leave that line out, then
I receive an exception, saying that there is no transaction in progress.
I even tried to use Castor/JDO from jsp directly, but that didn't work
either.
JBoss rules.
Gabor
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev