Graeme,

Thanks for the excellent example! However, creating the JNDI InitalContext
fails:

Error handling the request: javax.servlet.ServletException:
javax.naming.CommunicationException: Can't find SerialContextProvider

After reading up on JNDI, it looks as though I need a "service provider"
like LDAP, RMI, or the new "filesystem" provider.

Is this true? Do I need to setup a JNDI "directory" to get this approach to
work?

Thanks again,
Brad

----- Original Message -----
From: "Graeme Jackson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 23, 2001 4:00 AM
Subject: Re: [castor-dev] JSP support?


> Brad,
>
> We have an application that uses JNDI to store a reference to the JDO
object.
> The application initialises (in a sevlet upon start up) as follows:
>
> jdo = new JDO();
> jdo.setLogWriter(writer);
> jdo.setConfiguration(getClass().getResource("database.xml").toString());
> jdo.setDatabaseName( "mydb" );
>
> //create the RMI registry on port 1099 (default);
> new sun.rmi.registry.RegistryImpl(1099);
>
> // create the JNDI Context
> Context ctx = new InitialContext();
>  ctx.addToEnvironment(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
> "com.sun.jndi.rmi.registry.RegistryContextFactory" );
>
> //Bind the database to the JNDI context
> ctx.rebind("java:comp/env/jdo/mydb",jdo);
>
> Subsequent JSPs then obtain a Database reference using:
>
> //retreive the database from JNDI
> jdo = (JDO)ctx.lookup("java:comp/env/jdo/mydb");
> db= jdo.getDatabase();
>
> Hope this helps,
>
> Graeme
>
> Brad Matlack wrote:
>
> > I'm trying to apply the example Java application to a JSP environment,
and I
> > am now running into this exception:
> > TransactionNotInProgressException: This transaction is not open...
> >
> > By this message, I am assuming that instead of
> > db = jdo.getDatabase();
> > I have to use
> > db = (Database) ctx.lookup( "java:comp/env/jdo/mydb" );
> >
> > Is this correct for JSP? (The documentation says YES for EJB)
> > If yes, then, what is, or where can I find, the correct syntax for the
> > lookup()?
> > And finally, are there any JSP examples out in the world???
> >
> > Thank you,
> > Brad
> >
> > -----------------------------------------------------------
> > 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
>

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to