Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Struts - A MVC web framework
Tomcat - JSP/Servlet container
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
JSP - A mailing list about Java Server Pages specification and reference
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
JNDI, DataSource, and ClassCastException

JNDI, DataSource, and ClassCastException

2003-12-04       - By Marc Dugger

 Back
Reply:     1     2  

I have a situation where I am attempting to downcast a DataSource resource
into the exact class that getClass().getName() reports the object is, but
it's causing a ClassCastException.

--> server.xml:

<GlobalNamingResources>
      <Resource name="LoanAuditorDB" auth="Container"
type="org.enhydra.jdbc.pool.StandardXAPoolDataSource"/>
      <ResourceParams name="LoanAuditorDB">
...more
  </ResourceParams>
</GlobalNamingResources>
...more
<Context path="/workbench"
docBase="C:\Code\loanauditor\src\webapp\workbench"

workDir="C:\Code\loanauditor\src\webapp\workbench\WEB-INF\work"
reloadable="true" debug="0">
           <ResourceLink name="jdbc/loanauditor"
                         global="LoanAuditorDB"

type="org.enhydra.jdbc.pool.StandardXAPoolDataSource"/>
           <ResourceLink name="jta/loanauditor"
                         global="UserTransaction"
                         type="javax.transaction.UserTransaction Source code of javax.transaction.UserTransaction"/>
       </Context>


--> web.xml

<resource-ref>
       <description>DB Connection</description>
       <res-ref-name>jdbc/loanauditor</res-ref-name>
       <res-type>org.enhydra.jdbc.pool.StandardXAPoolDataSource</res-type>
       <res-auth>Container</res-auth>
   </resource-ref>

--> constructor from abstract class, AbstractDAO.java:

protected AbstractDAO() {
       try {
           Context ctx = new InitialContext();
           Object o = ctx.lookup("java:comp/env/jdbc/loanauditor");
           log.debug("loanauditor from JNDI: " + o.getClass().getName());
           ds = (org.enhydra.jdbc.pool.StandardXAPoolDataSource) o;
           ds.setJdbcTestStmt("SELECT 1");
       } catch (NamingException ne) {
           log.fatal(ne.getMessage(), ne);
           throw new RuntimeException(ne);
       }
   }

--> logging:

2003-12-04 05:25:39,157 [main] DEBUG
com.socotech.loanauditor.dao.AbstractDAO - loanauditor from JNDI:
org.enhydra.jdbc.pool.StandardXAPoolDataSource

--> stacktrace:

java.lang.ClassCastException Source code of java.lang.ClassCastException
  at com.socotech.loanauditor.dao.AbstractDAO.<init>(AbstractDAO.java:31)
  at
com.socotech.loanauditor.dao.TorqueDomainTypeDAO.<init>(TorqueDomainTypeDAO.
java:34)
  at
com.socotech.loanauditor.dao.TorqueDomainTypeDAO.getInstance(TorqueDomainTyp
eDAO.java:29)
  at
com.socotech.loanauditor.dao.DAOFactory.getDomainTypeDAO(DAOFactory.java:79)
  at
com.socotech.loanauditor.web.listener.DomainTypeLoader.contextInitialized(Do
mainTypeLoader.java:32)
  at
org.apache.catalina.core.StandardContext Source code of org.apache.catalina.core.StandardContext(StandardContext.java:
3271)
  at
org.apache.catalina.core.StandardContext Source code of org.apache.catalina.core.StandardContext(StandardContext.java:3613)
  at org.apache.catalina.core.ContainerBase Source code of org.apache.catalina.core.ContainerBase(ContainerBase.java:1188)
  at org.apache.catalina.core.StandardHost Source code of org.apache.catalina.core.StandardHost(StandardHost.java:754)
  at org.apache.catalina.core.ContainerBase Source code of org.apache.catalina.core.ContainerBase(ContainerBase.java:1188)
  at org.apache.catalina.core.StandardEngine Source code of org.apache.catalina.core.StandardEngine(StandardEngine.java:363)
  at org.apache.catalina.core.StandardService Source code of org.apache.catalina.core.StandardService(StandardService.java:497)
  at org.apache.catalina.core.StandardServer Source code of org.apache.catalina.core.StandardServer(StandardServer.java:2190)
  at org.apache.catalina.startup.Catalina Source code of org.apache.catalina.startup.Catalina(Catalina.java:512)
  at org.apache.catalina.startup.Catalina Source code of org.apache.catalina.startup.Catalina(Catalina.java:400)
  at org.apache.catalina.startup.Catalina Source code of org.apache.catalina.startup.Catalina(Catalina.java:180)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
  at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
  at java.lang.reflect.Method Source code of java.lang.reflect.Method(Method.java:324)
  at org.apache.catalina.startup.Bootstrap Source code of org.apache.catalina.startup.Bootstrap(Bootstrap.java:203)


Thanks in advance for any insight.



-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)




©2008 junlu.com - Jax Systems, LLC, U.S.A.