tags:

views:

44

answers:

1

ok log4j and servlett bugs have been fixed. next up is this one :(

[QUOTE]Cannot find class [org.springframework.jdbc.datasource.DriverManagerDataSourc[/QUOTE]

my current web.xml looks like this:

[QUOTE]<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.4" 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"&gt;




 <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener>



 <!--
  <listener>
  <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
 </listener>
  -->

 <!-- Register and setup my servlet xml files here -->

 <servlet>
  <servlet-name>appStore</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <init-param>
   <param-name>contextConfigLocation</param-name>
   <param-value></param-value>
  </init-param>
 </servlet>



 <servlet-mapping>
  <servlet-name>appStore</servlet-name>
  <url-pattern>*.htm</url-pattern>
 </servlet-mapping>



 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>
   /WEB-INF/zang-file-service.xml
  </param-value>
 </context-param>

[/QUOTE]

And the zang-file-service.xml is below:

<beans xmlns="ht..p://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
 xsi:schemaLocation="h..p://www.springframework.org/schema/beans
       h..p://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       h..p://www.springframework.org/schema/jee
       h..p://www.springframework.org/schema/jee/spring-jee-2.0.xsd">

 <!-- h..p://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd -->

 <!-- Config properties files -->



 <!-- Hibernate database stuff -->




 <bean id="propertyConfigurer"
  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="locations">
   <list>
    <value>properties/jdbc.properties</value>
   </list>
  </property>
 </bean>


 <bean id="dataSource1"
  class="org.springframework.jdbc.datasource.DriverManagerDataSourc">
  <property name="driverClassName" value="${database.driver}" />
  <property name="url" value="${database.url}" />
  <property name="username" value="${database.user}" />
  <property name="password" value="${database.password}" />
  <property name="maxActive" value="${database.maxConnections}" />
 </bean>


 <!-- LocalSessionFactoryBean u need to put the hbm files in the WEB-INF/classes 
  root director -->

 <bean id="sessionFactory"
  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="dataSource" ref="dataSource1"></property>
  <property name="mappingResources">
   <list>
    <value>FileObject.hbm.xml</value>
   </list>
  </property>
  <property name="hibernateProperties">
   <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.hbm2ddl.auto">create</prop>
   </props>
  </property>
 </bean>


 <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
  <property name="sessionsFactory" ref="sessionFactory"></property>
 </bean>

 <bean id="fileDownload" class="com.kc.models.FileManipulator">
  <property name="dbTemplate" ref="hibernateTemplate"></property>
 </bean>

</beans>

edit: here is my jdbc/properties file

[CODE]

# DB properties file

database.url=jdbc:mysql://localhost:3306/zangshop
database.driver=com.mysql.jdbc.Driver
database.user=XXXX
database.password=XXXX
database.maxConnections=25

[/CODE]

EDIT: Full error from tomcat

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.jdbc.datasource.DriverManagerDataSourc] for bean with name 'dataSource1' defined in ServletContext resource [/WEB-INF/zang-file-service.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.jdbc.datasource.DriverManagerDataSourc
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1141)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:524)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1177)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:758)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:422)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4323)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4771)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:785)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:763)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:558)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:987)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:540)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1390)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:355)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:312)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:292)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:998)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:772)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:990)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:275)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:424)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:648)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:576)
    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.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)
Caused by: java.lang.ClassNotFoundException: org.springframework.jdbc.datasource.DriverManagerDataSourc
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1664)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1509)
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:211)
    at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:385)
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1138)
    ... 41 more
+3  A: 

You have missed the last letter in the class name. It should be:

class="org.springframework.jdbc.datasource.DriverManagerDataSource"

In order to get some compile-time validation for spring configuration you can try the SpringSource Tool Suite (STS)

Bozho
doh!! thanks! its hard to write xml as their is no syntax errors or anything unlike when you write something in POJO, say if you type Strin it will complain imediatly of a typo
jonney
@jonney if an answer solves your problem, you are expected to mark it as accepted (tick below the vote counter)
Bozho