Hi Christophe and Lucy,
I add your guide with minor modifications to OJB deployment doc.
Could you please review the doc?
Find it on CVS
http://cvs.apache.org/viewcvs.cgi/db-ojb/xdocs/deployment.xml
regards,
Armin
----- Original Message -----
From: "Christophe Lombart" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Tuesday, March 18, 2003 10:36 PM
Subject: Re: Deploy OJB in WebLogic Server
> Just to complete the information provided by Lucy, you can find here
how
> to deploy OJB (PB) on weblogic. It is quite similar to Jboss.
> I think Thomas should be interested to receive this small install
guide
> for weblogic (Tested only on Weblogic 7):
>
> 1. Add the OJB jar files and depedencies into the Weblogic classpath.
> 2. Compile the following classes (see at the end of this mail) and add
> them to the weblogic classpath.
> 3. Register via the weblogic console the startup class (OjbPbStartup).
> The JNDI name and the OJB.properties file path can be specified as
> parameters in this startup class (see the code).
> 4. As usual create the connection pool and the datasource.
> 5. Check the following entries in the OJB.properties :
>
>
ConnectionFactoryClass=org.apache.ojb.broker.accesslayer.ConnectionFacto
ryManagedImpl
> OJBTxManagerClass=org.apache.ojb.odmg.JTATxManager
>
>
JTATransactionManagerClass=org.apache.ojb.otm.transaction.factory.Weblog
icTransactionManagerFactory
>
> 6. Modify the connection information in the repository.xml (specify
the
> datasource name):
>
> <jdbc-connection-descriptor
> jcd-alias="default"
> default-connection="true"
> platform="Hsqldb"
> jdbc-level="2.0"
> jndi-datasource-name="datasource_demodb"
> 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>
>
> </jdbc-connection-descriptor>
>
> 7. Write a session bean similar to thoses provided for the JBOSS
samples.
>
>
> I'm interesting to know if someone make a small comparaison between
EJB
> CMP 2.0 and OJB in term of performance, development cost, lifecycle,
> cache management... It should interesting for my current project.
>
>
> Thanks,
> Christophe
>
>
>
>
> ----------------------------------------------------------------------
------------
> OjbPbFactory
> ----------------------------------------------------------------------
------------
> package org.apache.ojb.weblogic;
>
> import org.apache.ojb.broker.ta.PersistenceBrokerFactoryIF;
>
>
> public interface OjbPbFactory
> {
>
> public static String DEFAULT_JNDI_NAME = "PBFactory";
> public PersistenceBrokerFactoryIF getInstance();
>
> }
>
>
> ----------------------------------------------------------------------
------------
> OjbPbFactoryImpl
> ----------------------------------------------------------------------
------------
> package org.apache.ojb.weblogic;
>
> import org.apache.ojb.broker.ta.PersistenceBrokerFactoryFactory;
> import org.apache.ojb.broker.ta.PersistenceBrokerFactoryIF;
>
>
> /**
> * PB Factory wrapper class for weblogic
> *
> */
> public class OjbPbFactoryImpl implements OjbPbFactory
>
>
> public PersistenceBrokerFactoryIF getInstance()
> {
> return PersistenceBrokerFactoryFactory.instance();
> }
>
> }
>
> ----------------------------------------------------------------------
------------
> OjbStartup
> ----------------------------------------------------------------------
------------
> package org.apache.ojb.weblogic;
>
> import javax.naming.*;
>
> import org.apache.ojb.broker.ta.PersistenceBrokerFactoryFactory;
> import org.apache.ojb.broker.ta.PersistenceBrokerFactoryIF;
>
> import weblogic.common.T3ServicesDef;
> import weblogic.common.T3StartupDef;
> import java.util.Hashtable;
>
> /**
> * This startup class created and binds an instance of a
> * PersistenceBrokerFactoryIF into JNDI.
> */
> public class OjbPbStartup
> implements T3StartupDef, OjbPbFactory
>
>
>
> private String defaultPropsFile =
> "org/apache/ojb/weblogic/OJB.properties";
>
> private T3ServicesDef services;
>
> public void setServices (T3ServicesDef services)
> {
> this.services = services;
> }
>
>
> public PersistenceBrokerFactoryIF getInstance()
> {
> return PersistenceBrokerFactoryFactory.instance();
> }
>
>
> public String startup (String name, Hashtable args)
> throws Exception
> {
>
> try
>
> String jndiName = (String)args.get ("jndiname");
> if (jndiName == null || jndiName.length () == 0)
> jndiName = OjbPbFactory.DEFAULT_JNDI_NAME;
>
> String propsFile = (String)args.get ("propsfile");
> if (propsFile == null || propsFile.length () == 0)
>
> System.setProperty("OJB.properties",
efaultPropsFile );
> }
> else
> {
> System.setProperty("OJB.properties", propsFile );
> }
>
> InitialContext ctx = new InitialContext ();
> OjbPbFactory factory = new OjbPbFactoryImpl();
> bind (ctx, jndiName, factory);
>
> // return a message for logging
> return "Bound OJB PersistenceBrokerFactoryIF to " +
jndiName;
> }
> catch (Exception e)
>
> e.printStackTrace();
> // return a message for logging
> return "Startup Class error : impossible to bind OJB PB
> factory";
> }
>
> }
>
> private void bind(Context ctx, String name, Object val)
> throws NamingException
> {
> Name n;
> for (n = ctx.getNameParser("").parse(name); n.size() > 1; n =
> n.getSuffix(1))
> {
> String ctxName = n.get(0);
> try
> {
> ctx = (Context) ctx.lookup(ctxName);
> }
> catch (NameNotFoundException namenotfoundexception)
> {
> ctx = ctx.createSubcontext(ctxName);
> }
> }
> ctx.bind(n.get(0), val);
> }
>
> }
>
>
> Lucy Zhao wrote:
>
> >Christophe:
> >
> >I'm able to deploy OJB in WebLogic Server. My approach is quite the
same as
> >yours: created a weblogic startup class and bind the PBFactoryIF to
JNDI
> >tree. Here are the issues I've experienced:
> >1) WebLogic server seems not like the "java:/" prefix added to the
JNDI
> >name. It throws "javax.naming.OperationNotSupportedException: bind
not
> >allowed in a ReadOnlyContext; remaining name '/ojb/PBAPI'" . The
problem
> >went away if remove "java:/" from jndi name. In the session EJB, the
code
> >will be like this:
> >pbf = ((PBFactoryIF) context.lookup("ojb.PBAPI")).getInstance();
> >
> >2) In repository-database.xml, change the user id and password to :
> > username="system"
> > password="weblogic"
> > I guess a new user ( resembles database user id and password)
could be
> >created in weblogic security domain and assign it to a certain group
may
> >also work. But haven't tried.
> >
> >Please let me know if this helps.
> >
> >Cheers!
> >Lucy Zhao
> >
> >-----Original Message-----
> >From: Christophe Lombart [mailto:[EMAIL PROTECTED]
> >Sent: Wednesday, March 12, 2003 7:44 PM
> >To: OJB Users List
> >Subject: Re: Deploy OJB in WebLogic Server
> >
> >
> >I'm trying to do this via a weblogic startup class. Via this startup
> >class, I'm putting the PB factory into a JNDI tree. This part is
> >working but I got an exception whith the datasource and I don't
> >understand why : SecurityPrivilegeActionException.
> >In a session bean, I lookup to the PB facotry and try to execute a
> >query. At this time, I got this exception.
> >
> >Christophe
> >
> >
> >Lucy Zhao wrote:
> >
> >
> >
> >>Have anybody deployed OJB in a WebLogic Server? And wrote an MBean
for
> >>WebLogic Server?
> >>
> >>Thanks!
> >>
> >>Lucy Zhao
> >>
> >>
> >>
> >>
> >>
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]