tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 47832] New: Custom resource factory placement
Date Mon, 14 Sep 2009 08:48:18 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=47832

           Summary: Custom resource factory placement
           Product: Tomcat 6
           Version: 6.0.20
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: kvasiliev@gmail.com


In the documentation about custom resource factories
(http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html) I read
following: You will need to compile this class against a class path that
includes all of the JAR files in the $CATALINA_HOME/lib directory. When you are
through, place the factory class (and the corresponding bean class) unpacked
under $CATALINA_HOME/lib, or in a JAR file inside $CATALINA_HOME/lib. In this
way, the required class files are visible to both Catalina internal resources
and your web application.

Does it mean that I must ALWAYS put it in common, or I must put it in common if
I want it to be visible to Tomcat? Can I put custom factory to WEB-INF/lib of
my application if I don't want it to be visible to Tomcat?

Actually we have a custom factory that derive from org.apache.tomcat.dbcp.dbcp.
BasicDataSourceFactory. We have it inside our war, we're plug it in inside
application's context.xml as

<Resource name="jdbc/db" auth="Container"
         type="javax.sql.DataSource"
         dsProps="properties.file"
         removeAbandoned="true"
         username="user"
         password="pass"
         driverClassName="com.mysql.jdbc.Driver"
         url="jdbc:mysql://url"
         factory="our.package.FactoryClass" />

Factory just searching for properties.file and if it is found, it's props will
be used to create datasource, otherwise props from context.xml will be used.
When we're trying to get jdbc/db by calling 
DataSource dataSource   = ( DataSource )( new InitialContext () ).lookup(
"java:/comp/env/jdbc/db" );
our FactoryClass is actually called instead. So it is works this way, but I
still don't understand is it proper way or not.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message