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 "Bates, Alex" <AB...@teradata-ncr.com> on 2003/12/31 19:18:33 UTC

Has anyone run OJB on WebLogic 8.1?

I tried following the instructions in the deployment documentation for OJB,
creating a startup class for WebLogic similar to the example posted on the
website.  

I'm getting an error that WL is unable to bind the factory to JNDI.  Then,
downstream of course I get errors that ojb/defaultODMG is not bound (we're
using the ODMG API).  

Here's the error binding to JNDI, and code for startup classes.  Am I doing
something wrong?  We are trying to port to WL 8.1 for an urgent customer
request, so any help is appreciated.

--------

<Info> <<WLS Kernel>> <> <BEA-000287> <Invoking startup class:
org.apache.ojb.weblogic.OjbODMGStartup.startup(null)>
 
<Info> <WebLogicServer> <wusab210009-0n9> <myserver> <main> <<WLS Kernel>>
<> <BEA-000288> <org.apache.ojb.weblogic.OjbODMGStartup reports: Startup
Class error: impossible to bind OJB ODMG factory> 

--------

Here is the code:

public interface OjbODMGFactory extends ODMGJ2EEFactory, Serializable {

}


public class OjbODMGStartup implements OjbODMGFactory, T3StartupDef,
Serializable {

    private String DEFAULT_JNDI_NAME = "ojb/defaultODMG";
    private String defaultPropsFile =
            "org/apache/ojb/weblogic/OJB.properties";

    private T3ServicesDef services;

    public void setServices (T3ServicesDef services)
    {
        this.services = services;
    }

    public Implementation getInstance()
    {
        return OJBJ2EE_2.getInstance();
    }

    public String startup (String name, Hashtable args)
            throws Exception
    {

        try
        {
            String jndiName = (String)args.get ("jndiname");
            if (jndiName == null || jndiName.length () == 0)
                jndiName = DEFAULT_JNDI_NAME;

            String propsFile = (String)args.get ("propsfile");
            if (propsFile == null || propsFile.length () == 0)
            {
                System.setProperty("OJB.properties", defaultPropsFile  );
            }
            else
            {
                System.setProperty("OJB.properties", propsFile  );
            }

            InitialContext ctx = new InitialContext ();
            bind (ctx, jndiName, this);

            // return a message for logging
            return "Bound OJBODMGFactory to " + jndiName;
        }
        catch (Exception e)
        {
            e.printStackTrace();
            // return a message for logging
            return
                    "Startup Class error: impossible to bind OJB ODMG
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);
    }
}

--------


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org