HOW DOES TOMCAT JNDI CONNECTION POOLING WORKS
Hi all, My questing is derived from the sample code given at : http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-how to.html#Database%20Connection%20Pool%20(DBCP)%20Configurations If you can see the subsection 4(i.e. testcode) of section MySQL DBCP Example, to get a connection following code is used: *** Context ctx = new InitialContext(); if(ctx == null ) throw new Exception(Boom - No Context); DataSource ds = (DataSource)ctx.lookup( java:comp/env/jdbc/TestDB); if (ds != null) { Connection conn = ds.getConnection(); *** I guess by doing this a connection is obtained FROM THE POOL providing that a connection is free in the pool. I have got two questions regarding this- Q 1. Does tomcat really looks into the pool to get me a connection? or it just creates a newone? I am asking this question because I am seeing(using eclipse debugger) two connection opened at the same time even after defining maxActive=1 maxIdle=1 in my application'c context Q 2. once your database operation is done you free the connection using conn.close(); by doing this are we pushing the connection back into pool? if not then how is pool maintained? Any help is appreciated --RahulJoshi - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: HOW DOES TOMCAT JNDI CONNECTION POOLING WORKS
1. Does tomcat really look into the pool? Yes. The pool code is really the commons DBCP project code refactored slightly to avoid collisions with the real DBCP project code. 2. on conn.close(), are we really pushing the connection back into the pool? Yes. Sorry I can't help you on the Eclipse debugger question since I don't use it. It may be an artifact of the debugger or maybe DBCP's code. You might find the DBCP project documentation helpful in answering these questions though. --David rahul wrote: Hi all, My questing is derived from the sample code given at : http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-how to.html#Database%20Connection%20Pool%20(DBCP)%20Configurations If you can see the subsection 4(i.e. testcode) of section MySQL DBCP Example, to get a connection following code is used: *** Context ctx = new InitialContext(); if(ctx == null ) throw new Exception(Boom - No Context); DataSource ds = (DataSource)ctx.lookup( java:comp/env/jdbc/TestDB); if (ds != null) { Connection conn = ds.getConnection(); *** I guess by doing this a connection is obtained FROM THE POOL providing that a connection is free in the pool. I have got two questions regarding this- Q 1. Does tomcat really looks into the pool to get me a connection? or it just creates a newone? I am asking this question because I am seeing(using eclipse debugger) two connection opened at the same time even after defining maxActive=1 maxIdle=1 in my application'c context Q 2. once your database operation is done you free the connection using conn.close(); by doing this are we pushing the connection back into pool? if not then how is pool maintained? Any help is appreciated --RahulJoshi - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- === David Smith Network Operations Supervisor Department of Entomology College of Agriculture Life Sciences Cornell University 2132 Comstock Hall Ithaca, NY 14853 Phone: 607.255.9571 Fax: 607.255.0939 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tomcat JNDI / JMX port
Hi, What is i am trying to do: Connect 4.1.27 tomcat to JMX client MC4J in a differenct port What is the issue:The port which tomcat uses be default is 1099 How can you help:Can you please let me know how to change the default port 1099 Why do i need it: I have more than 1 tomcat is a very powerful machine and want to enable jmx for each of it Please please help me Regards Guru
RE: Tomcat JNDI Realm + Active Directory Server
Two things that I noticed. I don't know how correct they are, but it seems to work in my environment. 1. In my Realm definition Realm I have connectionName and connectionPassword attributes which specify the user that can login to AD and query and authenticate others. 2. My Realm definition is in the context of my webapp and my web.xml configuration looks something like the following: security-constraint^M web-resource-collection^M web-resource-nameLogin Screen/web-resource-name^M url-pattern/Login.jsp/url-pattern^M /web-resource-collection^M ^M auth-constraint ^M role-nameMIS Distribution/role-name^M /auth-constraint^M /security-constraint^M I never use the context name in my web.xml like you have setup with moretests. Hope this helps. Kal -Original Message- From: Luis Durán [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 19, 2005 6:23 PM To: tomcat-user@jakarta.apache.org Subject: Tomcat JNDI Realm + Active Directory Server I had a hard time trying to configure Tomcat to authenticate with MS Active Directory Service, i tried a lot of samples, i edited them but i didn't get nothing. This is the last configuration i tried: /META-INF/context-xml: ?xml version=1.0 encoding=UTF-8? Context path=/moretests Realm className=org.apache.catalina.realm.JNDIRealm debug=99 connectionURL=ldap://192.168.200.2:389; referrals=follow userBase=cn=Users,dc=w2ksvr,dc=local userSearch=(sAMAccountName={0}) userSubtree=true userRoleName=memberOf roleBase=cn=Users,dc=w2ksvr,dc=local roleSearch=(sAMAccountName={0}) roleSubtree=true rolename=cn / /Context I gave the shot to the bind mode and to the password comparison mode with any results. /WEB-INF/web.xml: ?xml version=1.0 encoding=UTF-8? web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; version=2.4 login-config auth-methodBASIC/auth-method realm-namemoretests/realm-name /login-config session-config session-timeout 30 /session-timeout /session-config welcome-file-list welcome-file index.jsp /welcome-file /welcome-file-list security-constraint web-resource-collection web-resource-namewhole site/web-resource-name url-pattern/*/url-pattern http-methodGET/http-method /web-resource-collection auth-constraint role-nameprueba/role-name /auth-constraint /security-constraint security-role descriptionUsuario/description role-nameprueba/role-name /security-role /web-app Of course, i have created that group inside ADS and populated it with a user called elebis with a simple password. I even browsed ADS with ldap browser and everything seemed ok, Does anybody know why am I doing wrong? Can anybody help me to work around it? Thanks in advanced, pals -- Luis Edgardo Durán Lebis Soporte Técnico y Sistemas http://mipagina.cantv.net/elebis [EMAIL PROTECTED] 0416-7580991 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] CONFIDENTIALITY NOTE: All e-mail sent to or from this address will be received by the Waterfield Group corporate e-mail system and is subject to archival, monitoring, and/or review by someone other than the recipient or the sender. This e-mail and any of its attachments may contain proprietary information, which is privileged and confidential. This e-mail is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution, copying, or action taken in relation to the contents of and attachments to this e-mail is strictly prohibited and may be unlawful. If you have received this e-mail in error, please notify the sender immediately and permanently delete the original and any copy of this e-mail and any printout. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tomcat JNDI Realm + Active Directory Server
I had a hard time trying to configure Tomcat to authenticate with MS Active Directory Service, i tried a lot of samples, i edited them but i didn't get nothing. This is the last configuration i tried: /META-INF/context-xml: ?xml version=1.0 encoding=UTF-8? Context path=/moretests Realm className=org.apache.catalina.realm.JNDIRealm debug=99 connectionURL=ldap://192.168.200.2:389; referrals=follow userBase=cn=Users,dc=w2ksvr,dc=local userSearch=(sAMAccountName={0}) userSubtree=true userRoleName=memberOf roleBase=cn=Users,dc=w2ksvr,dc=local roleSearch=(sAMAccountName={0}) roleSubtree=true rolename=cn / /Context I gave the shot to the bind mode and to the password comparison mode with any results. /WEB-INF/web.xml: ?xml version=1.0 encoding=UTF-8? web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; version=2.4 login-config auth-methodBASIC/auth-method realm-namemoretests/realm-name /login-config session-config session-timeout 30 /session-timeout /session-config welcome-file-list welcome-file index.jsp /welcome-file /welcome-file-list security-constraint web-resource-collection web-resource-namewhole site/web-resource-name url-pattern/*/url-pattern http-methodGET/http-method /web-resource-collection auth-constraint role-nameprueba/role-name /auth-constraint /security-constraint security-role descriptionUsuario/description role-nameprueba/role-name /security-role /web-app Of course, i have created that group inside ADS and populated it with a user called elebis with a simple password. I even browsed ADS with ldap browser and everything seemed ok, Does anybody know why am I doing wrong? Can anybody help me to work around it? Thanks in advanced, pals -- Luis Edgardo Durán Lebis Soporte Técnico y Sistemas http://mipagina.cantv.net/elebis [EMAIL PROTECTED] 0416-7580991 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Embedded Tomcat JNDI/JDBC Configuration Questions
Hi! I've successfully created a project that embeds Tomcat. Excellent! I can see the sample page and the manager app, reporting Tomcat 5.5.9. Now I'm working on deploying a .war file programatically: public void registerWAR(String contextPath, String absolutePath) throws Exception { Context context = this.embedded.createContext(contextPath, absolutePath); context.setReloadable(false); this.host.addChild(context); } I pass in the path and the location of the .war file. When I run the application the .war file is found and exploded to the /ROOT directory properly. Inside of the .war file is a context.xml file. The jdbc/db resource is defined in context.xml, inside of the .war file with the following: Resource name=jdbc/db auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/db parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value /parameter parameter namemaxIdle/name value30/value /parameter parameter namemaxWait/name value1/value /parameter parameter nameusername/name valuefoo/value /parameter parameter namepassword/name valuebar/value /parameter parameter namedriverClassName/name valuecom.mysql.jdbc.Driver/value /parameter parameter nameurl/name valuejdbc:mysql://localhost:3306/reger?autoReconnect=true/value /parameter /ResourceParams When I make a call to my application the code inside the .war file attempts to connect to the database like this: private static final String jndiPrePend = java:comp/env/; private static final String jndiDB = jdbc/db; public static Connection getConnection(){ Connection conn=null; try{ Context ctx = new InitialContext(); if(ctx != null){ DataSource ds = (DataSource)ctx.lookup(jndiPrePend + jndiDB); if(ds != null){ conn = ds.getConnection(); return conn; } } } catch (Exception e){ e.printStackTrace(); util.errorsave(e); } return null; } But I get the following error in the console window, repeatedly, each time my app tries to connect to the db: javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory. java:132) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304) at org.apache.naming.NamingContext.lookup(NamingContext.java:792) at org.apache.naming.NamingContext.lookup(NamingContext.java:139) at org.apache.naming.NamingContext.lookup(NamingContext.java:780) at org.apache.naming.NamingContext.lookup(NamingContext.java:139) at org.apache.naming.NamingContext.lookup(NamingContext.java:780) at org.apache.naming.NamingContext.lookup(NamingContext.java:139) at org.apache.naming.NamingContext.lookup(NamingContext.java:780) at org.apache.naming.NamingContext.lookup(NamingContext.java:152) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:136) at javax.naming.InitialContext.lookup(InitialContext.java:351) at reger.db.RunSQL(db.java:64) at reger.db.RunSQL(db.java:124) at reger.scheduler.MasterThread.setupThread(MasterThread.java:377) at reger.scheduler.MasterThread.run(MasterThread.java:48) It looks like the jndi/jdbc resource isn't configured correctly and/or isn't available to the code from the .war file running inside of the embedded tomcat. Questions: 1) Is my jndiPrePend variable correct? It works for a standard deployment on a non-embedded tomcat. 2) Is there anything special I need to do to get a jndi/jdbc resource configured under the embedded tomcat? 3) Does the error message I'm seeing point to anything that I need to change? Thanks, Joe
Tomcat, JNDI, Active Directory
Hi! Is there anyone out there who would like to figure out what I am doing wrong when trying to create a realm in Tomcat that is supposed to authenitcate users over JNDI against an Active Directory server. In my server.xml I have the following Realm className=org.apache.catalina.realm.JNDIRealm connectionURL=ldap://192.168.10.10:389; alternateURL=ldap://192.168.10.10:389; userBase=ou=Users,dc=alfa-moving,dc=se userPattern=uid={0},ou=Users,dc=alfa-moving,dc=se roleBase=ou=Users,dc=alfa-moving,dc=se roleName=cn debug=99 / The log from tomcat says the following 004-10-14 16:04:04 JNDIRealm[Catalina]: Connecting to URL ldap://192.168.10.10:389 2004-10-14 16:04:16 JNDIRealm[Catalina]: lookupUser(JKP_konf) 2004-10-14 16:04:16 JNDIRealm[Catalina]: dn=uid=JKP_konf,ou=Users,dc=alfa-moving,dc=se 2004-10-14 16:04:16 JNDIRealm[Catalina]: validating credentials by binding as the user 2004-10-14 16:04:16 JNDIRealm[Catalina]: binding as uid=JKP_konf,ou=Users,dc=alfa-moving,dc=se 2004-10-14 16:04:16 JNDIRealm[Catalina]: bind attempt failed 2004-10-14 16:04:16 JNDIRealm[Catalina]: Username JKP_konf NOT successfully authenticated When I look in the gui of AD I se a tree like this Active Directory Users and Computers --+alfa-moving.se + Users --+JKP_konf So, what have I done wrong ... somehow it always seem to be me who does the errors... .-) Thanks in advance Roland Carlsson ps: This is a crosspost of what I posted in the JNDI-forum at java.sun.com yesterday but got no answers (jet). Sent using the Microsoft Entourage 2004 for Mac Test Drive. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat, JNDI, Active Directory
On Fri, Oct 15, 2004 at 08:18:56AM +0200, Roland Carlsson wrote: : Is there anyone out there who would like to figure out what I am doing wrong : when trying to create a realm in Tomcat that is supposed to authenitcate : users over JNDI against an Active Directory server. Why not try this: authenticate against AD using something other than Tomcat. It's easier to troubleshoot if you strip away the layers, then methodically test each one till you find the culprit. I don't know what tools AD would have for this; but many LDAP implementations have standalone tools for searching the directory. You could fire up something of that nature to test the DN and such you have in your Tomcat config. -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Sv: Tomcat, JNDI, Active Directory
Hello! Thanks for your answer! I'll try to find a tool that can help me but I appreciate some tips if anyone have used a good tool for this. Regards Roland Carlsson Den 04-10-15 15.16, skrev QM [EMAIL PROTECTED]: On Fri, Oct 15, 2004 at 08:18:56AM +0200, Roland Carlsson wrote: : Is there anyone out there who would like to figure out what I am doing wrong : when trying to create a realm in Tomcat that is supposed to authenitcate : users over JNDI against an Active Directory server. Why not try this: authenticate against AD using something other than Tomcat. It's easier to troubleshoot if you strip away the layers, then methodically test each one till you find the culprit. I don't know what tools AD would have for this; but many LDAP implementations have standalone tools for searching the directory. You could fire up something of that nature to test the DN and such you have in your Tomcat config. -QM Sent using the Microsoft Entourage 2004 for Mac Test Drive. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tomcat, JNDI, Active Directory
conn.disconnect(); } catch( LDAPException e ) { System.out.println( Error: + e.toString() ); } return; } private static void simpleBind2( int version, LDAPConnection conn, String host, int port,String dn, String passwd ) { try { System.out.println(Simple bind with connection method...); // connect to the server conn.connect( host, port ); // authenticate to the server with the connection method try { conn.bind( version, dn, passwd.getBytes(UTF8) ); } catch (UnsupportedEncodingException u){ throw new LDAPException( UTF8 Invalid Encoding, LDAPException.LOCAL_ERROR, (String)null, u); } System.out.println((conn.isBound()) ? \n\tAuthenticated to the server ( simple )\n: \n\tNot authenticated to the server\n); // disconnect with the server conn.disconnect(); } catch( LDAPException e ) { System.out.println( Error: + e.toString() ); } return; } private static void SSLBind( int version, String host, int SSLPort, String dn, String passwd ) { // Set the socket factory for this connection only LDAPJSSESecureSocketFactory ssf = new LDAPJSSESecureSocketFactory(); LDAPConnection conn = new LDAPConnection(ssf); try { System.out.println(SSL bind...); // connect to the server conn.connect( host, SSLPort); // authenticate to the server with the connection method try { conn.bind( version, dn, passwd.getBytes(UTF8) ); } catch (UnsupportedEncodingException u){ throw new LDAPException( UTF8 Invalid Encoding, LDAPException.LOCAL_ERROR, (String)null, u); } System.out.println((conn.isBound()) ? \n\tAuthenticated to the server ( ssl )\n: \n\tNot authenticated to the server\n); // disconnect with the server conn.disconnect(); } catch( LDAPException e ) { System.out.println( Error: + e.toString() ); } return; } } --- END GetAuthenticated.java --- -Original Message- From: Roland Carlsson [mailto:[EMAIL PROTECTED] Sent: Friday, October 15, 2004 10:49 AM To: TomcatUsers Subject: Sv: Tomcat, JNDI, Active Directory Hello! Thanks for your answer! I'll try to find a tool that can help me but I appreciate some tips if anyone have used a good tool for this. Regards Roland Carlsson Den 04-10-15 15.16, skrev QM [EMAIL PROTECTED]: On Fri, Oct 15, 2004 at 08:18:56AM +0200, Roland Carlsson wrote: : Is there anyone out there who would like to figure out what I am doing wrong : when trying to create a realm in Tomcat that is supposed to authenitcate : users over JNDI against an Active Directory server. Why not try this: authenticate against AD using something other than Tomcat. It's easier to troubleshoot if you strip away the layers, then methodically test each one till you find the culprit. I don't know what tools AD would have for this; but many LDAP implementations have standalone tools for searching the directory. You could fire up something of that nature to test the DN and such you have in your Tomcat config. -QM Sent using the Microsoft Entourage 2004 for Mac Test Drive. - 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]
Re: Known problem with tomcat, jndi datasourc - PLEASE HELP
Hi Can pleae you give me pointers to solutions to the problem of a null for teh driverclass name, there seems to be no solution in the archives till date. Thanks. Prasad --- MARU, SOHIL (SBCSI) [EMAIL PROTECTED] wrote: Hello All, I have been scouring the mailing list archives and lot of other places. I am seeing a problem configuring a datasource with Tomcat. I have put the following entry in my server.xml Context path=/loa docBase=C:\software\eclipse\workspace\HRTechnology\TOMCAT_ROOT reloadable=true Resource name=jdbc/loacenet auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/loacenet . . . . parameter namepassword/name valuedatabasepassword/value /parameter parameter nameurl/name valuejdbc:oracle:[EMAIL PROTECTED]:1521:[sid]/value /parameter parameter namedriverClassName/name valueoracle.jdbc.driver.OracleDriver/value /parameter parameter nameusername/name valueuser/value /parameter /ResourceParams /Context However when I try to load my plugin in the struts application, I get the following exception. I looked at everything on archives and on there people were complaining about NULL for driverClassName, in my case, it reads the drivername and url properly and still blows up. Please help. I am using Tomcat 5.0 with the latest ojdbc14.jar/commons-dbcp-1.1.jar in common/lib and am trying to connect to oracle 8.1.7. org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class ' oracle.jdbc.driver.OracleDriver' for connect URL 'jdbc:oracle:[EMAIL PROTECTED] :1521:[sid]', cause: java.sql.SQLException: No suitable driver at java.sql.DriverManager.getDriver(DriverManager.java:243) at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou rce.java:743) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource .java:518) at com.sbc.hrtech.framework.utility.InitializerPlugin.init(InitializerPl ugin.java:41) at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServle t.java:1158) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473) at javax.servlet.GenericServlet.init(GenericServlet.java:256) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper. java:1044) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:88 7) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex t.java:3960) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4 283) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125) at org.apache.catalina.core.StandardHost.start(StandardHost.java:832) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:518 ) at org.apache.catalina.core.StandardService.start(StandardService.java:5 19) at org.apache.catalina.core.StandardServer.start(StandardServer.java:234 5) at org.apache.catalina.startup.Catalina.start(Catalina.java:598) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:297) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:398) Excpetion in InitializerPlugin The java code in the plugin is as follows Context init = new InitialContext(); Context ctx = (Context) init.lookup(java:comp/env); DataSource dataSource = (DataSource) ctx.lookup(jdbc/loacenet); c = dataSource.getConnection(); -- line which blows up
Re: Known problem with tomcat, jndi datasourc - PLEASE HELP
Prasad, I DID. Did you miss it? Here it is again. First check you logs and see if any error messages are showing up. As a just for kicks try thing, move the username up in the configuration to before the password. Crazy thing but it caused mine to not see the password. I don't think you will get back any indications in the java trace that the password is bad but the logs will show trying to connect with the proper user but no reference to password. Note: It will not list the password in the log but will say password yes or something like that. Let us know what you find. Also give use you system info: Tomcat=5 OS=? JDK=? Doug www.parsonstechnical.com - Original Message - From: prasad chaturvedula [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Friday, April 09, 2004 2:49 AM Subject: Re: Known problem with tomcat, jndi datasourc - PLEASE HELP Hi Can pleae you give me pointers to solutions to the problem of a null for teh driverclass name, there seems to be no solution in the archives till date. Thanks. Prasad --- MARU, SOHIL (SBCSI) [EMAIL PROTECTED] wrote: Hello All, I have been scouring the mailing list archives and lot of other places. I am seeing a problem configuring a datasource with Tomcat. I have put the following entry in my server.xml Context path=/loa docBase=C:\software\eclipse\workspace\HRTechnology\TOMCAT_ROOT reloadable=true Resource name=jdbc/loacenet auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/loacenet . . . . parameter namepassword/name valuedatabasepassword/value /parameter parameter nameurl/name valuejdbc:oracle:[EMAIL PROTECTED]:1521:[sid]/value /parameter parameter namedriverClassName/name valueoracle.jdbc.driver.OracleDriver/value /parameter parameter nameusername/name valueuser/value /parameter /ResourceParams /Context However when I try to load my plugin in the struts application, I get the following exception. I looked at everything on archives and on there people were complaining about NULL for driverClassName, in my case, it reads the drivername and url properly and still blows up. Please help. I am using Tomcat 5.0 with the latest ojdbc14.jar/commons-dbcp-1.1.jar in common/lib and am trying to connect to oracle 8.1.7. org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class ' oracle.jdbc.driver.OracleDriver' for connect URL 'jdbc:oracle:[EMAIL PROTECTED] :1521:[sid]', cause: java.sql.SQLException: No suitable driver at java.sql.DriverManager.getDriver(DriverManager.java:243) at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou rce.java:743) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource .java:518) at com.sbc.hrtech.framework.utility.InitializerPlugin.init(InitializerPl ugin.java:41) at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServle t.java:1158) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473) at javax.servlet.GenericServlet.init(GenericServlet.java:256) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper. java:1044) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:88 7) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex t.java:3960) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4 283) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125) at org.apache.catalina.core.StandardHost.start(StandardHost.java:832) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:518 ) at org.apache.catalina.core.StandardService.start(StandardService.java:5 19) at org.apache.catalina.core.StandardServer.start(StandardServer.java:234 5) at org.apache.catalina.startup.Catalina.start(Catalina.java:598) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:297) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:398) Excpetion in InitializerPlugin The java code in the plugin is as follows Context init = new InitialContext(); Context ctx = (Context) init.lookup(java:comp/env); DataSource dataSource = (DataSource
RE: Known problem with tomcat, jndi datasourc - PLEASE HELP
Prasad, My internet access is down right now, as soon as I get that up and running I will send you a link to the archives where I saw a thread regarding your problem. Thanks, Sohil -Original Message- From: prasad chaturvedula [mailto:[EMAIL PROTECTED] Sent: Friday, April 09, 2004 1:50 AM To: Tomcat Users List Subject: Re: Known problem with tomcat, jndi datasourc - PLEASE HELP Hi Can pleae you give me pointers to solutions to the problem of a null for teh driverclass name, there seems to be no solution in the archives till date. Thanks. Prasad --- MARU, SOHIL (SBCSI) [EMAIL PROTECTED] wrote: Hello All, I have been scouring the mailing list archives and lot of other places. I am seeing a problem configuring a datasource with Tomcat. I have put the following entry in my server.xml Context path=/loa docBase=C:\software\eclipse\workspace\HRTechnology\TOMCAT_ROOT reloadable=true Resource name=jdbc/loacenet auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/loacenet . . . . parameter namepassword/name valuedatabasepassword/value /parameter parameter nameurl/name valuejdbc:oracle:[EMAIL PROTECTED]:1521:[sid]/value /parameter parameter namedriverClassName/name valueoracle.jdbc.driver.OracleDriver/value /parameter parameter nameusername/name valueuser/value /parameter /ResourceParams /Context However when I try to load my plugin in the struts application, I get the following exception. I looked at everything on archives and on there people were complaining about NULL for driverClassName, in my case, it reads the drivername and url properly and still blows up. Please help. I am using Tomcat 5.0 with the latest ojdbc14.jar/commons-dbcp-1.1.jar in common/lib and am trying to connect to oracle 8.1.7. org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class ' oracle.jdbc.driver.OracleDriver' for connect URL 'jdbc:oracle:[EMAIL PROTECTED] :1521:[sid]', cause: java.sql.SQLException: No suitable driver at java.sql.DriverManager.getDriver(DriverManager.java:243) at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou rce.java:743) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource .java:518) at com.sbc.hrtech.framework.utility.InitializerPlugin.init(InitializerPl ugin.java:41) at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServle t.java:1158) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473) at javax.servlet.GenericServlet.init(GenericServlet.java:256) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper. java:1044) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:88 7) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex t.java:3960) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4 283) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125) at org.apache.catalina.core.StandardHost.start(StandardHost.java:832) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:518 ) at org.apache.catalina.core.StandardService.start(StandardService.java:5 19) at org.apache.catalina.core.StandardServer.start(StandardServer.java:234 5) at org.apache.catalina.startup.Catalina.start(Catalina.java:598) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:297) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:398) Excpetion
Known problem with tomcat, jndi datasourc - PLEASE HELP
Hello All, I have been scouring the mailing list archives and lot of other places. I am seeing a problem configuring a datasource with Tomcat. I have put the following entry in my server.xml Context path=/loa docBase=C:\software\eclipse\workspace\HRTechnology\TOMCAT_ROOT reloadable=true Resource name=jdbc/loacenet auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/loacenet . . . . parameter namepassword/name valuedatabasepassword/value /parameter parameter nameurl/name valuejdbc:oracle:[EMAIL PROTECTED]:1521:[sid]/value /parameter parameter namedriverClassName/name valueoracle.jdbc.driver.OracleDriver/value /parameter parameter nameusername/name valueuser/value /parameter /ResourceParams /Context However when I try to load my plugin in the struts application, I get the following exception. I looked at everything on archives and on there people were complaining about NULL for driverClassName, in my case, it reads the drivername and url properly and still blows up. Please help. I am using Tomcat 5.0 with the latest ojdbc14.jar/commons-dbcp-1.1.jar in common/lib and am trying to connect to oracle 8.1.7. org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class ' oracle.jdbc.driver.OracleDriver' for connect URL 'jdbc:oracle:[EMAIL PROTECTED] :1521:[sid]', cause: java.sql.SQLException: No suitable driver at java.sql.DriverManager.getDriver(DriverManager.java:243) at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou rce.java:743) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource .java:518) at com.sbc.hrtech.framework.utility.InitializerPlugin.init(InitializerPl ugin.java:41) at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServle t.java:1158) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473) at javax.servlet.GenericServlet.init(GenericServlet.java:256) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper. java:1044) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:88 7) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex t.java:3960) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4 283) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125) at org.apache.catalina.core.StandardHost.start(StandardHost.java:832) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:518 ) at org.apache.catalina.core.StandardService.start(StandardService.java:5 19) at org.apache.catalina.core.StandardServer.start(StandardServer.java:234 5) at org.apache.catalina.startup.Catalina.start(Catalina.java:598) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:297) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:398) Excpetion in InitializerPlugin The java code in the plugin is as follows Context init = new InitialContext(); Context ctx = (Context) init.lookup(java:comp/env); DataSource dataSource = (DataSource) ctx.lookup(jdbc/loacenet); c = dataSource.getConnection(); -- line which blows up st = c.createStatement(); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Known problem with tomcat, jndi datasourc - PLEASE HELP
First check you logs and see if any error messages are showing up. As a just for kicks try thing, move the username up in the configuration to before the password. Crazy thing but it caused mine to not see the password. I don't think you will get back any indications in the java trace that the password is bad but the logs will show trying to connect with the proper user but no reference to password. Note: It will not list the password in the log but will say password yes or something like that. Doug www.parsonstechnical.com - Original Message - From: MARU, SOHIL (SBCSI) [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, April 08, 2004 6:56 PM Subject: Known problem with tomcat, jndi datasourc - PLEASE HELP Hello All, I have been scouring the mailing list archives and lot of other places. I am seeing a problem configuring a datasource with Tomcat. I have put the following entry in my server.xml Context path=/loa docBase=C:\software\eclipse\workspace\HRTechnology\TOMCAT_ROOT reloadable=true Resource name=jdbc/loacenet auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/loacenet . . . . parameter namepassword/name valuedatabasepassword/value /parameter parameter nameurl/name valuejdbc:oracle:[EMAIL PROTECTED]:1521:[sid]/value /parameter parameter namedriverClassName/name valueoracle.jdbc.driver.OracleDriver/value /parameter parameter nameusername/name valueuser/value /parameter /ResourceParams /Context However when I try to load my plugin in the struts application, I get the following exception. I looked at everything on archives and on there people were complaining about NULL for driverClassName, in my case, it reads the drivername and url properly and still blows up. Please help. I am using Tomcat 5.0 with the latest ojdbc14.jar/commons-dbcp-1.1.jar in common/lib and am trying to connect to oracle 8.1.7. org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class ' oracle.jdbc.driver.OracleDriver' for connect URL 'jdbc:oracle:[EMAIL PROTECTED] :1521:[sid]', cause: java.sql.SQLException: No suitable driver at java.sql.DriverManager.getDriver(DriverManager.java:243) at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou rce.java:743) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource .java:518) at com.sbc.hrtech.framework.utility.InitializerPlugin.init(InitializerPl ugin.java:41) at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServle t.java:1158) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473) at javax.servlet.GenericServlet.init(GenericServlet.java:256) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper. java:1044) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:88 7) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex t.java:3960) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4 283) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125) at org.apache.catalina.core.StandardHost.start(StandardHost.java:832) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:518 ) at org.apache.catalina.core.StandardService.start(StandardService.java:5 19) at org.apache.catalina.core.StandardServer.start(StandardServer.java:234 5) at org.apache.catalina.startup.Catalina.start(Catalina.java:598) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:297) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:398) Excpetion in InitializerPlugin The java code in the plugin is as follows Context init = new InitialContext(); Context ctx = (Context) init.lookup(java:comp/env); DataSource dataSource = (DataSource) ctx.lookup(jdbc/loacenet); c = dataSource.getConnection(); -- line which blows up st = c.createStatement(); - 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]
Tomcat JNDI
I have/had the two working together, but my only problem is this. When I blow away the webapp and its war and add a new war, my app does don't explode the war. I get a message in my tomcat log file that says: java.lang.IllegalArgumentException: Document base C:\Program Files\Apache Group\Tomcat 4.1\webapps\vp does not exist or is not a readable directory Well I know the folder is not there because it has not been exploded yet? How do I get it to explode the war before it checks or some other way? I would like to continue set my app up in a way where each time I do a load I can blow away the app folder and its war file, then add the new war file and start tomcat Anthony Smith GSP Technologies 901-263-8953 Having education and talent doesn't make you better than the world... it makes you responsible for it!
Re: Tomcat JNDI - mapping a String
I have developed a small web-based aplication. I use an ant build script to compile it and to generate a war. The application is used in several servers with different settings (it uses different databases, connects to different xml-rpc resources...) so it has to somehow read the configuration from the server environment. I have used the tomcat Web server administration tool to set Resources - a data source and several Environment Entries. The tool regenerates server.xml file in such a manner: Server ... GlobalNamingResources Environment description= name=BLAH_USER type=java.lang.String value=MrSpock/ ... /GlobalNamingResources ... /Srver Then I change my deployment descriptor get access to this environment: web-app ... resource-env-ref resource-env-ref-nameBLAh_USER/resource-env-ref-name resource-env-ref-typejava.lang.String/resource-env-ref-type /resource-env-ref ... /web-app The code, that tryes to read this environmnt looks like this: Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); String res_user = (String) envCtx.lookup(BLAH_USER); The problem is, that I get this exception: javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:146) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:301) at org.apache.naming.NamingContext.lookup(NamingContext.java:837) at org.apache.naming.NamingContext.lookup(NamingContext.java:197) at myapp.servlets.MyAppListener.contextInitialized(MyAppListener.java:123) When I try to access a mapped JDBC resource everything seems to be OK. When I list (NamingEnumeration enum = initCtx.list(java:comp/env);) the keys for mapped resources BLAH_USER appears. I have tried look this situation in the Tomcat documentation and to google it, but I haven't get any reasonable idea to solve it. I have done some other tests and I can't find the right solution. Stop me, when I become wrong: 1) Enteries in GlobalNamingResources are accesible for the whole server including all deployed applications. 2) When I include Environment element into GlobalNamingResources a new Environment variable should be accessible in all applications. It should do the same thing as adding env-entry into web.xml, that works for me. 3) The defined variable appears in the JNDI namespace of an application, when it's mapped into it by specifiing resource-env-ref in web.xml. 4) I appears as java:comp/env/VAR_NAME. 5) There should'n be no problem for Tomcat to construct instances of java.lang.String or java.lang.Integer. -- S pozdravem Ondrej Nekola [EMAIL PROTECTED] http://www.matfyz.cz/ondra ICQ# 160692888 PS: My environment - windows2k, JDK 1.4.2 and 1.5.0 beata, Tomcat 5.0.16, 5.0.18 and 4.1.27. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tomcat JNDI - mapping a String
I have developed a small web-based aplication. I use an ant build script to compile it and to generate a war. The application is used in several servers with different settings (it uses different databases, connects to different xml-rpc resources...) so it has to somehow read the configuration from the server environment. I have used the tomcat Web server administration tool to set Resources - a data source and several Environment Entries. The tool regenerates server.xml file in such a manner: Server ... GlobalNamingResources Environment description= name=BLAH_USER type=java.lang.String value=MrSpock/ ... /GlobalNamingResources ... /Srver Then I change my deployment descriptor get access to this environment: web-app ... resource-env-ref resource-env-ref-nameBLAh_USER/resource-env-ref-name resource-env-ref-typejava.lang.String/resource-env-ref-type /resource-env-ref ... /web-app The code, that tryes to read this environmnt looks like this: Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); String res_user = (String) envCtx.lookup(BLAH_USER); The problem is, that I get this exception: javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:146) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:301) at org.apache.naming.NamingContext.lookup(NamingContext.java:837) at org.apache.naming.NamingContext.lookup(NamingContext.java:197) at myapp.servlets.MyAppListener.contextInitialized(MyAppListener.java:123) When I try to access a mapped JDBC resource everything seems to be OK. When I list (NamingEnumeration enum = initCtx.list(java:comp/env);) the keys for mapped resources BLAH_USER appears. I have tried look this situation in the Tomcat documentation and to google it, but I haven't get any reasonable idea to solve it. -- S pozdravem Ondrej Nekola [EMAIL PROTECTED] http://www.matfyz.cz/ondra ICQ# 160692888 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: howto federate tomcat JNDI to another JNDI context ?
Hi mark, I solved my JNDI federation problem and maybe you are interested to know how ? JustToRememberMyProblem I want to get JMS ressources from JNDI. They're stored in a FileSystem JNDI and I need to federate it to Tomcat JNDI. /JustToRememberMyProblem I added a custom factory to tomcat (in commons/classes): import java.util.Enumeration; import java.util.Hashtable; import java.util.Properties; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.Name; import javax.naming.NameClassPair; import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.RefAddr; import javax.naming.Reference; import javax.naming.spi.ObjectFactory; public class JndiFederationFactory implements ObjectFactory { public Object getObjectInstance( Object obj, Name name, Context nameCtx, Hashtable environment) throws NamingException { Reference ref = (Reference) obj; Enumeration addrs = ref.getAll(); String lookup = null; Properties props = new Properties(); while (addrs.hasMoreElements()) { RefAddr addr = (RefAddr) addrs.nextElement(); String type = addr.getType(); String value = (String) addr.getContent(); if (type.equals(lookup)) { lookup = value; } else { props.put(type, value); } } InitialContext ctx = new InitialContext(props); if (lookup == null) { throw new NamingException(la propriété lookup doit être définie); } return ctx.lookup(lookup); } } I added IBM MQSeries/JMS client classes to commons/lib I added this conf in server.xml : Resource name=jms/QueueConnexionFactory auth=Container type=javax.jms.QueueConnexionFactory/ ResourceParams name=jms/QueueConnexionFactory parameter namefactory/name valuecom.cgey.JndiFederationFactory/value /parameter parameter namelookup/name valueurlQmgrLocal/value /parameter parameter namejava.naming.factory.initial/name valuecom.sun.jndi.fscontext.RefFSContextFactory/value /parameter parameter namejava.naming.security.authentication/name valuenone/value /parameter parameter namejava.naming.provider.url/name valuefile:///c:/MQSeries/jndi/value /parameter /ResourceParams Using this, I can lookup in local JNDI from my webapp for jms/QueueConnexionFactory and get the MQSeries QueueConnexionFactory defined in a FileSystem JNDI Context. This is a pseudo JNDI Federation, but it works fine. Nico. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
howto federate tomcat JNDI to another JNDI context ?
Hello, I would like to use tomcat JNDI to lookup JMS Queues (MQSeries) that are registered in JNDI using a File System JNDI Context (com.sun.jndi.fscontext.RefFSContextFactory) My webapp refers to a JNDI resource named jms/testQueueConnectionFactory, and I need to configure tomcat internal JNDI to federate java:com/env/jms JNDI namespace to the FileSystem JNDI context. I've not find any example in mailing-list archive about this. Can anyone tell me How to configure tomcat to do this ? Nico. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: howto federate tomcat JNDI to another JNDI context ?
Hello Nico, Yes I've been attempting to do the same thing with suns LDAP Context. Unfortunately (even for myself as an Apache Jakarta Developer, neither the tomcat user or developer lists have gotten any responses to my emails). I've done several attempts to start a discussion on this, maybe you will find my mistake path helpful: Tomcat User: http://www.mail-archive.com/[EMAIL PROTECTED]/msg114976.html http://www.mail-archive.com/[EMAIL PROTECTED]/msg114923.html Tomcat Dev: http://www.mail-archive.com/[EMAIL PROTECTED]/msg51159.html The nearest I can figure out is that you may have to write your own object factory to instantiate the objects even if one is provided by Sun. Otherwise your really going to be troubled with what ResourceParams are actually getting configured into the federated Context. I actually had to decompile the ldap factory com.sun.jndi.ldap.LdapCtxFactory to identify the fact that it sets none of these ReferenceAddrs/ResourceParams properly into the environment of the new context. If your studying all the JNDI Tutorial stuff and documentation its important to note that whats really getting set when you create Resource Params like this are Reference/ReferenceAddrs in JNDI. Resource type=com.sun.jndi.ldap.LdapCtxFactory auth=Container name=ldap/ ResourceParams name=ldap parameter namejava.naming.factory.initial/name valuecom.sun.jndi.ldap.LdapCtxFactory/value /parameter /ResourceParams equates to: Hashtable env = new Hashtable(); Reference ref = (Reference) obj; Enumeration addrs = ref.getAll(); while (addrs.hasMoreElements()) { RefAddr addr = (RefAddr) addrs.nextElement(); if(!addr.getType().equals(factory)) env.put(addr.getType(), addr.getContent().toString()); } return this.getInitialContext(env); in the factory (which all kinda sucks for anyone trying to use an existing factory that may not actually do this consistently. Unfortunately the JNDI tutorial is rather weak in substance when it comes to actually federating two namespaces. http://java.sun.com/products/jndi/tutorial/objects/factory/reference.html http://java.sun.com/products/jndi/tutorial/beyond/fed/index.html Good Luck, I'm glad to chat with someone having a similar problem. -Mark Diggory Nicolas De Loof wrote: Hello, I would like to use tomcat JNDI to lookup JMS Queues (MQSeries) that are registered in JNDI using a File System JNDI Context (com.sun.jndi.fscontext.RefFSContextFactory) My webapp refers to a JNDI resource named jms/testQueueConnectionFactory, and I need to configure tomcat internal JNDI to federate java:com/env/jms JNDI namespace to the FileSystem JNDI context. I've not find any example in mailing-list archive about this. Can anyone tell me How to configure tomcat to do this ? Nico. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Mark Diggory Software Developer Harvard MIT Data Center http://osprey.hmdc.harvard.edu - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Referencing Tomcat JNDI datasource
Hello, I am using Tomcat 4.1.18 and have setup a JNDI datasource for database connection pooling. I would like to reference this datasource from another application that is not running under Tomcat. In searching the mailing list archive and other forums I found dated information that indicated that this was not possible that I would have to use another database connection pooling utility such as DbConnectionBroker from Javaexchange.com. Is this still the case with the latest versions of Tomcat? Has anyone used DbConnectionBroker to provide database connection pooling with Tomcat and in a stand alone application? Any suggestions on other ways to use a database connection pool with Tomcat and from a stand alone application? Thanks, Don - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
help needed regarding tomcat jndi database connection pooling
Hi All, I have integrated tomcat 4.0.4 with apach 1.3.x. I have configured one of my tomcat contexts for database connection pooling and written a small jsp program to test the connection pooling by making use of jndi lookup.. The problem is when i access the context through port 8080 then I am able to make the jndi lookup and connection pooling is properly working. But when i try to call the same context through apache's port 80 I am unable to connect to the database. I am making use of mysql database.. Thanks in advance, Prashanth -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Is there a problem with tomcat JNDI resources (I don't think so)
Hi fellows. I think I'm doing something wrong, but I can't get a JNDI Datasource configured in GlobalNamingResource section. Here is my configuration: Resource name=jdbc/global type=javax.sql.DataSource auth=Container scope=Shareable/ ResourceParams name=jdbc/global parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namedriverClassName/name valueorg.postgresql.Driver/value /parameter parameter nameurl/name valuejdbc:postgresql://localhost/global/value /parameter parameter namevalidationQuery/name valueselect 1/value /parameter parameter nameusername/name valueglobal/value /parameter parameter namepassword/name valuepassword/value /parameter /ResourceParams In my context I have the following: Context docBase=s:\webapptests path=/tests reloadable=true debug=4 ResourceLink name=jdbc/global global=jdbc/global type=javax.sql.DataSource/ /Context But when I perform the lookup operations in my servlet, got the following error: javax.servlet.ServletException: Name java:comp is not bound in this Context at org.apache.naming.NamingContext.list(NamingContext.java:386) at org.apache.naming.NamingContext.list(NamingContext.java:409) at javax.naming.InitialContext.list(InitialContext.java:387) at com.isic.tests.JNDITestServlet.doGet(JNDITestServlet.java:27) My lookup line is: DataSource ds = (DataSource)ic.lookup(java:comp/env/jdbc/global); Is it correct? Sometimes I got really confused about these names. Am I missing some configuration in context or web.xml (is resource-ref necessary?). My application is running in a virtual host I created (with a SingleSignOn valve). Could it be the problem? Thanks for any help. iran -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Is there a problem with tomcat JNDI resources (I don't think so)
Hi, I've got this in my web xml for the app..Not doing global though. - resource-ref descriptionDB Connection/description res-ref-namejdbc/shiltonDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref Regards Kevin -Original Message- From: Iran Marcius [mailto:[EMAIL PROTECTED]] Sent: 20 December 2002 14:06 To: [EMAIL PROTECTED] Subject: Is there a problem with tomcat JNDI resources (I don't think so) Hi fellows. I think I'm doing something wrong, but I can't get a JNDI Datasource configured in GlobalNamingResource section. Here is my configuration: Resource name=jdbc/global type=javax.sql.DataSource auth=Container scope=Shareable/ ResourceParams name=jdbc/global parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namedriverClassName/name valueorg.postgresql.Driver/value /parameter parameter nameurl/name valuejdbc:postgresql://localhost/global/value /parameter parameter namevalidationQuery/name valueselect 1/value /parameter parameter nameusername/name valueglobal/value /parameter parameter namepassword/name valuepassword/value /parameter /ResourceParams In my context I have the following: Context docBase=s:\webapptests path=/tests reloadable=true debug=4 ResourceLink name=jdbc/global global=jdbc/global type=javax.sql.DataSource/ /Context But when I perform the lookup operations in my servlet, got the following error: javax.servlet.ServletException: Name java:comp is not bound in this Context at org.apache.naming.NamingContext.list(NamingContext.java:386) at org.apache.naming.NamingContext.list(NamingContext.java:409) at javax.naming.InitialContext.list(InitialContext.java:387) at com.isic.tests.JNDITestServlet.doGet(JNDITestServlet.java:27) My lookup line is: DataSource ds = (DataSource)ic.lookup(java:comp/env/jdbc/global); Is it correct? Sometimes I got really confused about these names. Am I missing some configuration in context or web.xml (is resource-ref necessary?). My application is running in a virtual host I created (with a SingleSignOn valve). Could it be the problem? Thanks for any help. iran -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RES: Is there a problem with tomcat JNDI resources (I don't think so)
If I'm not mistaken, I read somewhere that using GlobalNamingResource with ResourceLink (inside Context) make unnecessary to put resource-ref in web.xml. Tomcat naming examples didn't use it too. Is that correct? iran -Mensagem original- De: Kevin Passey [mailto:[EMAIL PROTECTED]] Enviada em: sexta-feira, 20 de dezembro de 2002 12:09 Para: 'Tomcat Users List' Assunto: RE: Is there a problem with tomcat JNDI resources (I don't think so) Hi, I've got this in my web xml for the app..Not doing global though. - resource-ref descriptionDB Connection/description res-ref-namejdbc/shiltonDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref Regards Kevin -Original Message- From: Iran Marcius [mailto:[EMAIL PROTECTED]] Sent: 20 December 2002 14:06 To: [EMAIL PROTECTED] Subject: Is there a problem with tomcat JNDI resources (I don't think so) Hi fellows. I think I'm doing something wrong, but I can't get a JNDI Datasource configured in GlobalNamingResource section. Here is my configuration: Resource name=jdbc/global type=javax.sql.DataSource auth=Container scope=Shareable/ ResourceParams name=jdbc/global parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namedriverClassName/name valueorg.postgresql.Driver/value /parameter parameter nameurl/name valuejdbc:postgresql://localhost/global/value /parameter parameter namevalidationQuery/name valueselect 1/value /parameter parameter nameusername/name valueglobal/value /parameter parameter namepassword/name valuepassword/value /parameter /ResourceParams In my context I have the following: Context docBase=s:\webapptests path=/tests reloadable=true debug=4 ResourceLink name=jdbc/global global=jdbc/global type=javax.sql.DataSource/ /Context But when I perform the lookup operations in my servlet, got the following error: javax.servlet.ServletException: Name java:comp is not bound in this Context at org.apache.naming.NamingContext.list(NamingContext.java:386) at org.apache.naming.NamingContext.list(NamingContext.java:409) at javax.naming.InitialContext.list(InitialContext.java:387) at com.isic.tests.JNDITestServlet.doGet(JNDITestServlet.java:27) My lookup line is: DataSource ds = (DataSource)ic.lookup(java:comp/env/jdbc/global); Is it correct? Sometimes I got really confused about these names. Am I missing some configuration in context or web.xml (is resource-ref necessary?). My application is running in a virtual host I created (with a SingleSignOn valve). Could it be the problem? Thanks for any help. iran -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
ENC: Is there a problem with tomcat JNDI resources (I don't think so)
I got my answer in this thread: Make sure you have the ResouceLink Tag inside each context that needs to use this datasource. Also, in using Global Resources, there is no need for a resource-ref tag in your web.xml config file anymore. iran -Mensagem original- De: Iran Marcius [mailto:[EMAIL PROTECTED]] Enviada em: sexta-feira, 20 de dezembro de 2002 13:52 Para: 'Tomcat Users List' Assunto: RES: Is there a problem with tomcat JNDI resources (I don't think so) If I'm not mistaken, I read somewhere that using GlobalNamingResource with ResourceLink (inside Context) make unnecessary to put resource-ref in web.xml. Tomcat naming examples didn't use it too. Is that correct? iran -Mensagem original- De: Kevin Passey [mailto:[EMAIL PROTECTED]] Enviada em: sexta-feira, 20 de dezembro de 2002 12:09 Para: 'Tomcat Users List' Assunto: RE: Is there a problem with tomcat JNDI resources (I don't think so) Hi, I've got this in my web xml for the app..Not doing global though. - resource-ref descriptionDB Connection/description res-ref-namejdbc/shiltonDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref Regards Kevin -Original Message- From: Iran Marcius [mailto:[EMAIL PROTECTED]] Sent: 20 December 2002 14:06 To: [EMAIL PROTECTED] Subject: Is there a problem with tomcat JNDI resources (I don't think so) Hi fellows. I think I'm doing something wrong, but I can't get a JNDI Datasource configured in GlobalNamingResource section. Here is my configuration: Resource name=jdbc/global type=javax.sql.DataSource auth=Container scope=Shareable/ ResourceParams name=jdbc/global parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namedriverClassName/name valueorg.postgresql.Driver/value /parameter parameter nameurl/name valuejdbc:postgresql://localhost/global/value /parameter parameter namevalidationQuery/name valueselect 1/value /parameter parameter nameusername/name valueglobal/value /parameter parameter namepassword/name valuepassword/value /parameter /ResourceParams In my context I have the following: Context docBase=s:\webapptests path=/tests reloadable=true debug=4 ResourceLink name=jdbc/global global=jdbc/global type=javax.sql.DataSource/ /Context But when I perform the lookup operations in my servlet, got the following error: javax.servlet.ServletException: Name java:comp is not bound in this Context at org.apache.naming.NamingContext.list(NamingContext.java:386) at org.apache.naming.NamingContext.list(NamingContext.java:409) at javax.naming.InitialContext.list(InitialContext.java:387) at com.isic.tests.JNDITestServlet.doGet(JNDITestServlet.java:27) My lookup line is: DataSource ds = (DataSource)ic.lookup(java:comp/env/jdbc/global); Is it correct? Sometimes I got really confused about these names. Am I missing some configuration in context or web.xml (is resource-ref necessary?). My application is running in a virtual host I created (with a SingleSignOn valve). Could it be the problem? Thanks for any help. iran -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: RES: Is there a problem with tomcat JNDI resources (I don't thinkso)
Iran Marcius wrote: If I'm not mistaken, I read somewhere that using GlobalNamingResource with ResourceLink (inside Context) make unnecessary to put resource-ref in web.xml. Tomcat naming examples didn't use it too. I may have been the perpetrator of that particular piece of information. It was while asking a question to Craig. Is that correct? His answer was; functionally it is not needed, but you should have it because it's the right thing to do to make your web application portable. Cheers, -- jon -- Jon Eaves [EMAIL PROTECTED] http://www.eaves.org/jon/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
could not cast dbcp objects created using tomcat JNDI
I retrieved an object of DataSource using Tomcat's JNDI simulation. It is an instance of BasicDataSource. I tried to cast it to BasicDataSource and got a ClassCastException. Context ctx = new InitialContext() ; Context envCtx = (Context) ctx.lookup(java:comp/env) ; DataSource ds = (DataSource) envCtx.lookup(jdbc/myoracle) ; BasicDataSource basic = (BasicDataSource) ds ; Actually, I cannot cast any DBCP objects, e.g. PoolableConnection.
tomcat + jndi
Hi, I posted earlier but unfortunately got no response. I´ve also had a look at various mailing lists but found no answer. If I have tomcat installed on a seperate box and have some classes which I want to reach via JNDI, how would my tomcat specific jndi.properties look like? Any help would be _really_ appreciated. Regards, Michael -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Tomcat + JNDI
Hi, I´m trying to access a bean via JNDI using Tomcat. Unfortunately, reading documentation and mailing-lists hasn´t helped me very much. Could someone please expalin to me what is involved in accessing a bean in tomcat via JNDI. Here´s what I´ve done so far: == WEB.XML resource-env-ref description Object factory for MyBean instances. /description resource-env-ref-name jdo/FindMe /resource-env-ref-name resource-env-ref-type com.test.osforum.services.FindMe /resource-env-ref-type /resource-env-ref MY ACTION SERVLET Context context; Context envCtx; try { context = new InitialContext(); envCtx = (Context) context.lookup(java:comp/env); FindMe findme = (FindMe) envCtx.lookup(jdo/FindMe); message = findme.getSillyMessage(); request.setAttribute(message, message); } catch (NamingException e) { System.out.println(-| CATCH NAMING EXCEPTION-: + e.toString() + |- \n\n); e.printStackTrace(); } The above results in a javax.naming.NamingException: Cannot create resource instance. Could someone please point me in the right direction. Regards, Michael -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Tomcat + JNDI
Have you defined the resource itself in server.xml? You'll need to set up the appropriate Resource and ResourceParams elements there in order to define how Tomcat is actually supposed to create the object factory for this resource. See the jndi-resources-howto.html for more information on creating object factories for your own beans. Craig On Sat, 27 Jul 2002, Michael Delamere wrote: Date: Sat, 27 Jul 2002 16:10:44 +0200 From: Michael Delamere [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Tomcat + JNDI Hi, I´m trying to access a bean via JNDI using Tomcat. Unfortunately, reading documentation and mailing-lists hasn´t helped me very much. Could someone please expalin to me what is involved in accessing a bean in tomcat via JNDI. Here´s what I´ve done so far: == WEB.XML resource-env-ref description Object factory for MyBean instances. /description resource-env-ref-name jdo/FindMe /resource-env-ref-name resource-env-ref-type com.test.osforum.services.FindMe /resource-env-ref-type /resource-env-ref MY ACTION SERVLET Context context; Context envCtx; try { context = new InitialContext(); envCtx = (Context) context.lookup(java:comp/env); FindMe findme = (FindMe) envCtx.lookup(jdo/FindMe); message = findme.getSillyMessage(); request.setAttribute(message, message); } catch (NamingException e) { System.out.println(-| CATCH NAMING EXCEPTION-: + e.toString() + |- \n\n); e.printStackTrace(); } The above results in a javax.naming.NamingException: Cannot create resource instance. Could someone please point me in the right direction. Regards, Michael -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Tomcat + JNDI
thanks Craig, that´s what I thought I read I was hoping that maybe there is an easier way then wrinting my own factory to retreive objects via JNDI. What I need is a factory which can return any JDO objects. I noticed in the particular example provided by tomcat that you have to initialize the object in the factory. So that would mean that every time I create a new JDO object, I have to add it to the factory. Or have I missed something here? Any suggestions? Thanks very much, Michael - Original Message - From: Craig R. McClanahan [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Saturday, July 27, 2002 6:09 PM Subject: Re: Tomcat + JNDI Have you defined the resource itself in server.xml? You'll need to set up the appropriate Resource and ResourceParams elements there in order to define how Tomcat is actually supposed to create the object factory for this resource. See the jndi-resources-howto.html for more information on creating object factories for your own beans. Craig On Sat, 27 Jul 2002, Michael Delamere wrote: Date: Sat, 27 Jul 2002 16:10:44 +0200 From: Michael Delamere [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Tomcat + JNDI Hi, I´m trying to access a bean via JNDI using Tomcat. Unfortunately, reading documentation and mailing-lists hasn´t helped me very much. Could someone please expalin to me what is involved in accessing a bean in tomcat via JNDI. Here´s what I´ve done so far: == WEB.XML resource-env-ref description Object factory for MyBean instances. /description resource-env-ref-name jdo/FindMe /resource-env-ref-name resource-env-ref-type com.test.osforum.services.FindMe /resource-env-ref-type /resource-env-ref MY ACTION SERVLET Context context; Context envCtx; try { context = new InitialContext(); envCtx = (Context) context.lookup(java:comp/env); FindMe findme = (FindMe) envCtx.lookup(jdo/FindMe); message = findme.getSillyMessage(); request.setAttribute(message, message); } catch (NamingException e) { System.out.println(-| CATCH NAMING EXCEPTION-: + e.toString() + |- \n\n); e.printStackTrace(); } The above results in a javax.naming.NamingException: Cannot create resource instance. Could someone please point me in the right direction. Regards, Michael -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
tomcat / jndi
Hi all, i have some questions on jndi of tomcat : 1) if i put a class in tomcat jndi, and will the class constructor be exectued ? if it will, when will it be ? Once tomcat start up ? or first client get resources ? or will not execute constructor at all ? Since I go to tomcat doc and find that most of the classes don't have constructor. So I am not clear in this. 2) If multiple client request for the same resource, is it only one copy of the class will be shared between the clients? Thanks _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Passing a Tomcat JNDI context to a jCrontab task
Apologies if this is too off topic. I am looking at using the jCrontab servlet to do some task scheduling most of which has to do with mailing reports generated from data in the application's database. Although I could do this using the Class.forName() paradigm I would like to use the same Datasource pool I have already running. In order to obtain a reference though, I need the InitialContext. There seems to be three ways to approach this problem but I am not sure which are possible much less which may be best. The first seems to be to have jCrontab make a call to a class which somehow obtains the InitialContext reference. My problem is knowing how to access the Tomcat Context from an application which does not have a implied reference to the Tomcat context such as a Bean or Servlet would have. The second seems to be to pass a reference of the Context to the application but I am not sure it is possible for jCrontab to do that? The third would be for jCrontab to somehow invoke a servlet or Bean within the Tomcat context but after studying the Tests suite and reading through the documentation I am at a loss of how to invoke a class which does not have main method. If anyone has a suggestion or even where I might find one I'd appreciate the hint. Thanks, Steven -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
tomcat, JNDI naming, and OracleDataSource
I don't know if my original message made it to the list yet. I received the following error when I tried to send a question to tomcat-user list: - The following addresses had permanent fatal errors - [EMAIL PROTECTED] (reason: 550 User unknown) I'm not sure why it redirected to namezero.com. Hope this one makes it! I'm trying to get a JNDI example of my own working - the one in the example context works fine. I originally wrote because I couldn't even get an IntialContext instantiation to work. I solved that by making sure the naming.jar file was in my application-context classpath. Actually, I hope the first message didn't make it to the list! Anyway, here's the problem. In my code, I instantiate an InitialContext and then do a lookup for a DataSource (connection factory). The lookup fails with the following exception: javax.servlet.ServletException: NamingNotFound Exception while looking up java:comp/env/jdbc/NamingDataSource: Name java:comp is not bound in this Context at NamingServlet.init(NamingServlet.java:39) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:802) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:583) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:225) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:446) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:162) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.valves.RequestDumperValve.invoke(RequestDumperValve.java:219) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879) at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:827) at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:904) at java.lang.Thread.run(Thread.java:484) I'm at home right now so I don't have the code in fron of me but it is basically as follows (with the naming exceptions caught and turned into ServletExceptions): import javax.naming.*; import javax.sql.*; public void init( ServletConfig config ) throws ServletException { super.init(config); InitialContext ic = new InitialContext(); DataSource ds = (DataSource)ic.lookup(java:comp/env/jdbc/NamingDataSource); } and here is my web.xml file: ?xml version=1.0 encoding=ISO-8859-1? !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.2//EN http://java.sun.com/j2ee/dtds/web-app_2_2.dtd; web-app display-nameNaming Test/display-name descriptionTest JNDI Naming/description servlet servlet-namenaming/servlet-name servlet-classNamingServlet/servlet-class /servlet servlet-mapping servlet-namenaming/servlet-name url-pattern/naming/url-pattern /servlet-mapping resource-ref res-ref-namejdbc/NamingDataSource/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app So the exception says: Name java:comp is not bound in this Context but isn't it enough to declare/define it in my web.xml file. I'm going to look through the ejb specification tomorrow in case it sheds any light (since the servlet spec says naming and resource references are described in the ejb spec). As an aside, what I'm actually trying to do is get an OraclePooledConnectionDataSource (I think that's the class name?) with the base class OracleDataSource in the oracle.jdbc.pool package but I thought I'd start with a simpler case. I'm also waiting to see if
Redirects when mailing to this list RE: tomcat, JNDI naming, and OracleDataSource
Kevin, and others. When you see messages like this, it means that the list tried to send email to that person (in your case [EMAIL PROTECTED]) and that email address was no good. This does NOT mean that the rest of the list didn't get your email. There is no need to post a second time. I just delete all the bounce/redirect messages that I get after sending to this list. -Original Message- From: Kevin HaleBoyes [mailto:[EMAIL PROTECTED]] Sent: Monday, May 14, 2001 3:35 PM To: [EMAIL PROTECTED] Subject: tomcat, JNDI naming, and OracleDataSource I don't know if my original message made it to the list yet. I received the following error when I tried to send a question to tomcat-user list: - The following addresses had permanent fatal errors - [EMAIL PROTECTED] (reason: 550 User unknown) I'm not sure why it redirected to namezero.com. Hope this one makes it! I'm trying to get a JNDI example of my own working - the one in the example context works fine. I originally wrote because I couldn't even get an IntialContext instantiation to work. I solved that by making sure the naming.jar file was in my application-context classpath. Actually, I hope the first message didn't make it to the list! Anyway, here's the problem. In my code, I instantiate an InitialContext and then do a lookup for a DataSource (connection factory). The lookup fails with the following exception: javax.servlet.ServletException: NamingNotFound Exception while looking up java:comp/env/jdbc/NamingDataSource: Name java:comp is not bound in this Context at NamingServlet.init(NamingServlet.java:39) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:802) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:583) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja va:231) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja va:225) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164 ) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:446) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java :162) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.valves.RequestDumperValve.invoke(RequestDumperValve.java :219) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:879) at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java: 827) at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:904) at java.lang.Thread.run(Thread.java:484) I'm at home right now so I don't have the code in fron of me but it is basically as follows (with the naming exceptions caught and turned into ServletExceptions): import javax.naming.*; import javax.sql.*; public void init( ServletConfig config ) throws ServletException { super.init(config); InitialContext ic = new InitialContext(); DataSource ds = (DataSource)ic.lookup(java:comp/env/jdbc/NamingDataSource); } and here is my web.xml file: ?xml version=1.0 encoding=ISO-8859-1? !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.2//EN http://java.sun.com/j2ee/dtds/web-app_2_2.dtd; web-app display-nameNaming Test/display-name descriptionTest JNDI Naming/description servlet servlet-namenaming/servlet-name servlet-classNamingServlet/servlet-class /servlet servlet-mapping servlet-namenaming/servlet-name url-pattern/naming/url-pattern /servlet-mapping resource-ref res-ref-namejdbc/NamingDataSource/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app
Tomcat JNDI
I am trying to tie Tomcat with JNDI to use J2EE pattern to obtain resources: Context context = new InitialContext(); dataSource = (DataSource)context.lookup("java:comp/env/jdbc/myDataSource"); (I know Tomcat team is planning to have it for Tomcat 4 eventually) I have my own little in memory JNDI implementation with support for java:comp URLs and it works fine but provides one global JNDI for all contexts defined in server.xml while it should be context specific. Basically the problem is how to make InitialContext() tomcat context aware (to be precise to make my java:comp namespace to start from different roots depending on where InitialContext was created). If AdaptiveClassLoader had some context info in it I could get it from there while creating InitialContext. Any ideas are greatly appreciated Alex
Tomcat JNDI
I am trying to tie Tomcat with JNDI to use J2EE pattern to obtain resources: Context context = new InitialContext(); dataSource = (DataSource)context.lookup("java:comp/env/jdbc/myDataSource"); (I know Tomcat team is planning to have it for Tomcat 4 eventually) I have my own little in memory JNDI implementation with support for java:comp URLs and it works fine but provides one global JNDI for all contexts defined in server.xml while it should be context specific. Basically the problem is how to make InitialContext() tomcat context aware (to be precise to make my java:comp namespace to start from different roots depending on where InitialContext was created). If AdaptiveClassLoader had some context info in it I could get it from there while creating InitialContext. Any ideas are greatly appreciated Alex
Re: Tomcat JNDI
"Roytman, Alex" wrote: I am trying to tie Tomcat with JNDI to use J2EE pattern to obtain resources: Context context = new InitialContext(); dataSource = (DataSource)context.lookup("java:comp/env/jdbc/myDataSource"); (I know Tomcat team is planning to have it for Tomcat 4 eventually) Interesting timing ... the code to do this (in Tomcat 4) was added just in the last couple of days (after milestone 4). I have my own little in memory JNDI implementation with support for java:comp URLs and it works fine but provides one global JNDI for all contexts defined in server.xml while it should be context specific. Basically the problem is how to make InitialContext() tomcat context aware (to be precise to make my java:comp namespace to start from different roots depending on where InitialContext was created). If AdaptiveClassLoader had some context info in it I could get it from there while creating InitialContext. If I recall correctly, it's actually sort of tricky to get this right. You might want to check the source for the Tomcat 4 implementation for ideas -- I believe it depends on the servlet container calling Thread.setContextClassLoader() once you know which webapp you're running in. This only works in a Java2 environment, though. Any ideas are greatly appreciated Alex Craig McClanahan