You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-user@jakarta.apache.org by Roy Russo <ro...@jboss.com> on 2005/03/22 16:49:03 UTC

jndi in webapp

Hello Sliders,

We are using slide 2.1 as the basis of our CMS for JBoss Portal. Until now, we used the default file system store, but also wanted to allow for users to implement the jdbc store. Since slide is running inside our Portal webapp, it was having trouble finding the jndi-name.

I made a slight modification to the code in org.apache.slide.store.impl.rdbms.J2EEStore.java, from various suggestions in this mailing list and my own tinkering. The changes are below:

Staring on line ~119 of J2EEStore.java:
            // Initialize database
            Context initCtx = new InitialContext();
            //Context envCtx = (Context) initCtx.lookup("java:comp/env");
            //ds = (DataSource) envCtx.lookup(datasource);
            ds = (DataSource)initCtx.lookup("java:/" + datasource);

We currently deploy our own datasource "PortalDS", as part of the global portal ds. So in the domains.xml file as a ds name, we simply use:

<parameter name="datasource">PortalDS</parameter>

Of course, we needed to make sure the ds was deployed by JBoss before slide could see it. 

This seems to be an ongoing issue with people on this mailing list, so my suggestion would be that the changes made to J2EEStore.java be incorporated to the slide build, and perhaps allow a config variable dictate whether slide is running inside a webapp where the current jndi lookup method cannot find the ds.

I mainly used this post as a reference: http://mail-archives.eu.apache.org/mod_mbox/jakarta-slide-user/200309.mbox/%3C000b01c3738a$9d05ccf0$5e00200a@zero.priv.malva.com.ua%3E

Regards,
Roy Russo
JBoss Portal Developer