Martin Gainty wrote:
Mark

have you been able to implement JNDI (standalone) in TC?
No, I never tried.

i see craig's comment on implementing JNDI in org.apache.catalina.Container.java
 * <li><b>Resources</b> - JNDI directory context enabling access to static
 *     resources, enabling custom linkages to existing server components when
 *     Catalina is embedded in a larger server.
 * </ul>
i *thought* Catalina would need to be 'embedded' into A J2EE AppServer (such as 
Glassfish)
to implement JNDI functionality?

thanks,
Martin Gainty ______________________________________________ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.




Date: Sun, 27 Sep 2009 12:38:11 -0400
From: mark.shif...@yale.edu
Subject: Re: debugging model classes tied to Tomcat datasources
To: users@tomcat.apache.org

Hi:
This is what I do for testing. I made a class for creating a jndi directory and I create this in my main, then I can get a datasource from the jndi directory just like I do it when running tomcat.

jndi.properties
java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory
java.naming.factory.url.pkgs=org.apache.naming
java.naming.provider.url=java

 public static void create_JNDI(){
//jndi.properties must be on the classpath to make the initial context //you can either add the environment manually vida infra or have a jndi.properties file
/*              Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.naming.java.javaURLContextFactory");
            env.put(Context.URL_PKG_PREFIXES,"org.apache.naming");
            env.put(Context.PROVIDER_URL,"java");
            Context initial = new InitialContext(env);*/
                try {
                        Context initial = new InitialContext();
                        Context javaCompEnv = initial.
createSubcontext(new CompositeName().add("java:")).
                                createSubcontext("comp").
                                createSubcontext("env");
                        Context jdbc = javaCompEnv.createSubcontext("jdbc");

                        DataSource dataSource = setupDataSource();
                        jdbc.bind("mydatasourcet", dataSource);
                } catch (NamingException e) {
                        throw new RuntimeException(e);
                }

        }

private static DataSource setupDataSource() {
// BasicDataSource is from DBCP commons or it is repackaged by tomcat as //org.apache.tomcat.dbcp.dbcp.BasicDataSource BasicDataSource ds = new BasicDataSource(); //this is from DBCP commons
        ds.setDriverClassName("yourdrivergoeshere");
        ds.setUsername("user");
        ds.setPassword("pwxxx");
        ds.setUrl("yourjdbcurlgoeshere");
        ds.setMaxActive(4);
        ds.setMaxIdle(4);
        return ds;
    }
mas

Eric P wrote:
Hi,

(Tomcat newb alert)

I've got a simple database servlet application that has a few model classes on the back end.

I have the model classes pretty well genericized so that they could (almost) be utilized outside of Tomcat by another app, but they do utilize the Tomcat data sources I've set up (via an InitialContext data source lookup). So this makes it impossible (?) to execute the model classes outside of Tomcat.

Does anyone have any suggestions about how they would approach this problem so that they could debug and/or utilize these model classes that rely on database access?

Thanks for reading.  I'm open to any/all ideas.
Eric P.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

_________________________________________________________________
Hotmail® has ever-growing storage! Don’t worry about storage limits.
http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to