facebook

Struts-Probs implementing "DataSource". ClassNot F

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #263681 Reply

    sntechnik
    Member

    Hi everybody,

    i added a Datasource to my struts-config and used it under MyEclipse. Then i copied the resulting war to another tomcat and now i get a classNotFoundException?

    What i am wondering about is, that i added the concerning library(jdbc-mysql.jar) to the project, so it is deployed to the new tomcat together with the project?

    Here’s my config:

      <data-sources >
          <data-source key="org.apache.struts.action.DATA_SOURCE" type="org.apache.tomcat.dbcp.dbcp.BasicDataSource">
          <set-property property="password" value="********" />
          <set-property property="minCount" value="" />
          <set-property property="maxCount" value="" />
          <set-property property="user" value="mal" />
          <set-property property="driverClass" value="com.mysql.jdbc.Driver" />
          <set-property property="description" value="" />
          <set-property property="url" value="jdbc:mysql://xxx.xxx.xxx.xxx/logging" />
          <set-property property="readOnly" value="false" />
          <set-property property="autoCommit" value="false" />
          <set-property property="loginTimeout" value="" />
        </data-source>
    

    And the error is:

    Dec 20, 2006 4:55:22 PM org.apache.struts.action.ActionServlet initModuleDataSources
    SEVERE: Initializing application data source org.apache.struts.action.DATA_SOURCE
    java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp.BasicDataSource
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1340)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
        at org.apache.struts.util.RequestUtils.applicationClass(RequestUtils.java:117)
        at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:143)
        at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:805)
        at org.apache.struts.action.ActionServlet.init(ActionServlet.java:335)
        at javax.servlet.GenericServlet.init(GenericServlet.java:211)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1029)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4013)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4357)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
        at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:277)
        at org.apache.catalina.core.StandardHost.install(StandardHost.java:832)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:687)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:432)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:968)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
        at org.apache.catalina.core.StandardService.start(StandardService.java:480)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
        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:585)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)

    The aim is, to be completely independend from the installed libraries on the target-tomcat. So what do i need to add how to solve this, if i just want to put my jar on any tomcat?

    Kind regards, Florian

    #263772 Reply

    Riyad Kalla
    Member

    org.apache.tomcat.dbcp.dbcp.BasicDataSource

    It looks like you are missing a core Tomcat class, not necessarily a MySQL Connector/J class… are the two Tomcat installs identical?

    #265177 Reply

    sntechnik
    Member

    Well, i am very unsure about this “BasicDataSource”-thing 😉

    Depending on the documentation i am googling, i get different ways, to name the interface. This one, i am using, is from a Java2-Book.

    Another variant i found was “org.apache.commons.dbcp.BasicDataSource”.
    Both are not working remote, the second even either not on my devel-machine…

    I think, there are some probs between the relation (JRE 1.4.2 ^1.5.0) & (Tomcat 5.x ^ 5.5) & eventually the struts-version i am using….

    All in all i am very confused and would be very glad, if someone could guide me through this struggle…

    Kind regards, Florian

    #265182 Reply

    Riyad Kalla
    Member

    Florian,
    Here is a formula that works like a charm:

    0) Install Sun JDK 1.5.0_10 (don’t use JDK 6 just yet)
    1) MyEclipse 5.1.0 All-in-One Installer
    2) Create a Web Project with Struts 1.1 or 1.2 Capabilities added to it
    3) Download Tomcat 5.5 (latest, I think 5.5.24) from Tomcat’s website in ZIP form. Unzip it to some location, like C:\dev\ (it will create apache-tomcat-5.5.24 subdir)
    4) Go to the MyEclipse Tomcat 5 connector (Window > Prefs > MyEclipse > App Servers > Tomcat 5, and setup the home dir), then go down a level into the JDK settings and click “Add” then setup the 1.5.0_10 JDK you just installed in step 0 and hit OK.
    5) Deploy your project to “Tomcat 5” and hit run, you are good to go!

    #265867 Reply

    sntechnik
    Member

    I think, i did it this way (“I think”, because i’ll have to get an already developed project running, not a new one), but no success.
    Here’s what i did:
    1. prooved installation of JDK 1.5.10, yes, the system-vm is definetely set to this
    2. deinstalled (My)eclipse
    3. Reinstalled the actual version
    4. deleted all tomcat
    5. installed tomcat 5.5
    6. deployed tomcat 5.5 in eclipse as container
    7. started tomcat, yes, it uses Java-1.5.10
    8. deployed the web/struts-project.
    9. following error in the log:

    
    INFO: Deploying web application archive wl.war
    09.02.2007 16:49:35 org.apache.struts.action.ActionServlet initModuleDataSources
    SCHWERWIEGEND: Initializing application data source org.apache.struts.action.DATA_SOURCE
    java.lang.reflect.InvocationTargetException
        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:585)
        at org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:1773)
        at org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:1759)
        at org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1648)
        at org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:1677)
        at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1022)
        at org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)
        at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298)
        at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:807)
        at org.apache.struts.action.ActionServlet.init(ActionServlet.java:335)
        at javax.servlet.GenericServlet.init(GenericServlet.java:211)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3951)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4225)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:809)
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:698)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
        at org.apache.catalina.core.StandardService.start(StandardService.java:450)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
        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:585)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
    Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'jdbc:mysql://xxx.xx.xx.xxx/logging'
        at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)
        at org.apache.commons.dbcp.BasicDataSource.setLoginTimeout(BasicDataSource.java:586)
        ... 40 more
    Caused by: java.sql.SQLException: No suitable driver
        at java.sql.DriverManager.getDriver(DriverManager.java:243)
        at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:773)
        ... 41 more
    09.02.2007 16:49:36 org.apache.catalina.core.ApplicationContext log
    INFO: Marking servlet action as unavailable
    09.02.2007 16:49:36 org.apache.catalina.core.StandardContext loadOnStartup
    SCHWERWIEGEND: Servlet /wl threw load() exception
    javax.servlet.UnavailableException: Initializing application data source org.apache.struts.action.DATA_SOURCE
        at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:812)
        at org.apache.struts.action.ActionServlet.init(ActionServlet.java:335)
        at javax.servlet.GenericServlet.init(GenericServlet.java:211)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3951)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4225)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:809)
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:698)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
        at org.apache.catalina.core.StandardService.start(StandardService.java:450)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
        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:585)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
    
    #265873 Reply

    Riyad Kalla
    Member

    Looks like a JDBC driver issue. Did you copy the JDBC driver you need to your Tomcat/common/lib directory so Tomcat can load it when connecting to the data source?

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Struts-Probs implementing "DataSource". ClassNot F

You must be logged in to post in the forum log in