facebook

HQL Editor Error: Could not find datasource

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #282583 Reply

    icon911
    Member

    Hi,

    I decided to try out HQL editor, for the first time, on my hibernate project.
    When I try to run a query I get the following:

    Error Building Session Factory
    A session factory for this cofiguration could not be built, dynamic query transaction will be unavailable.
    Queries cannot be executed.
    Reason:
    Could not find datasource

    I use JNDI for my connection and it is specified in my hibernate.cfg.xml file
    The JNDI Resource is defined in my context.xml (Tomcat5). If I run my project, hibernate sees the datasource no problem, however, running queries in HQL Editor produces error above. What am I missing?

    Thank you, Oleg

    #282620 Reply

    Thomas Heiss
    Member

    Hi,

    This is how we do it:

    Split your spring-hibernate.xml configuration into
    spring-hibernate.xml, spring-datasource-jndi.xml and myeclipse-spring-datasource.xml.

    You just have to load both spring-hibernate.xml and myeclipse-spring-datasource.xml in your MyEclipse project hibernate configuration.

    In myeclipse-spring-datasource.xml use this:

    
    <bean id="ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> 
            <property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
            <property name="url"><value>jdbc:mysql://localhost:3306/db</value></property>
            <property name="username"><value>user</value></property>
            <property name="password"><value>pwd</value></property>
        </bean>
    

    Please do note that you can not use Spring org.springframework.jdbc.datasource.SingleConnectionDataSource as it is not supported in MyEclipse Hibernate configuration and will definitly throw an error.

    In your Webapplication project web.xml you can use this configuration:

    
    <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                classpath*:/spring-beans/spring-*.xml
              </param-value>
        </context-param>
    

    Or even more specific:

    
    <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                classpath*:/spring-beans/spring-hibernate.xml,
                classpath*:/spring-beans/spring-datasource-jndi.xml
              </param-value>
        </context-param>
    

    Good luck.

    Thomas

    #282624 Reply

    Loyal Water
    Member

    Oleg,
    Can you create a new web project, add hibernate capabilities to it and try working with the HQL Editor again. Do you still get the same error message ?

    Can you paste your installation details here for me as well (MyEclipse > Installation Summary > Installation Details) ?

    #282631 Reply

    icon911
    Member

    Thanks for getting back to me. I did create a new project and added hibernate capabilities but still get same error. Here are my installation details:

    *** Date:
    Friday, March 7, 2008 9:46:21 AM PST

    ** System properties:
    OS=Linux
    OS version=2.6.22-14-generic
    Java version=1.6.0_03

    *** MyEclipse details:
    MyEclipse Enterprise Workbench
    Version: 6.0.1 GA
    Build id: 6.0.1-GA-200710

    *** Eclipse details:
    Eclipse SDK

    Version: 3.3.1.1
    Build id: M20071023-1652

    Eclipse Platform

    Version: 3.3.2.R33x_v20071022-_19UEksF-G8Yc6bUv3Dz
    Build id: M20071023-1652

    Eclipse RCP

    Version: 3.3.2.R33x_r20071022-8y8eE9CEV3FspP8HJrY1M2dS
    Build id: I20070625-1500

    Eclipse Java Development Tools

    Version: 3.3.1.r331_v20070629-7o7jE72EDlXAbqAcnbmyg1rf8RIL
    Build id: I20070625-1500

    Eclipse Project SDK

    Version: 3.3.2.R33x_r20071022-7M7J7C_Mu2gop0b_GAwplOBhyuKO
    Build id: M20071023-1652

    Eclipse Plug-in Development Environment

    Version: 3.3.2.R33x_r20071022-7N7M4CYWLBCz-yHkMIuHN
    Build id: M20071023-1652

    Eclipse Graphical Editing Framework

    Version: 3.3.1.v20070814
    Build id: 20070814-1555

    Eclipse startup command=-os
    linux
    -ws
    gtk
    -arch
    x86
    -showsplash
    /home/olegtim/Programs/eclipse//plugins/org.eclipse.platform_3.3.2.R33x_v20071022/splash.bmp
    -launcher
    /home/olegtim/Programs/eclipse/eclipse
    -name
    Eclipse
    –launcher.library
    /home/olegtim/Programs/eclipse/plugins/org.eclipse.equinox.launcher.gtk.linux.x86_1.0.2.R331_v20071019/eclipse_1021.so
    -startup
    /home/olegtim/Programs/eclipse/plugins/org.eclipse.equinox.launcher_1.0.1.R33x_v20070828.jar
    -vm
    /usr/lib/jvm/java-6-sun-1.6.0.03/jre/bin/../lib/i386/client/libjvm.so

    #282759 Reply

    icon911
    Member

    I tried using HQL on my XP machine using same Tomcat/JNDI/Hibernate setup, and got same error. Here are Installation details for this machine:

    *** Date:
    Monday, March 10, 2008 6:32:22 PM PDT

    ** System properties:
    OS=WindowsXP
    OS version=5.1
    Java version=1.6.0_04

    *** MyEclipse details:
    MyEclipse Enterprise Workbench
    Version: 6.0.1 GA
    Build id: 6.0.1-GA-200710

    *** Eclipse details:
    MyEclipse Enterprise Workbench

    Version: 6.0.1 GA
    Build id: 6.0.1-GA-200710

    Eclipse Platform

    Version: 3.3.3.r33x_r20080129-_19UEl7Ezk_gXF1kouft
    Build id: M20080221-1800

    Eclipse RCP

    Version: 3.3.3.r33x_r20080129-8y8eE9UEUWI6qujeED0xT7bc
    Build id: M20080221-1800

    Eclipse Java Development Tools

    Version: 3.3.2.r33x_r20080129-7o7jE7_EDhYDiyVEnjb1pFd7ZGD7
    Build id: M20080221-1800

    Eclipse Project SDK

    Version: 3.3.3.r33x_r20080129-7M7J7LB-u3aphGW6o3_VmiVfGXWO
    Build id: M20080221-1800

    Eclipse Plug-in Development Environment

    Version: 3.3.3.r33x_r20080129-7N7M5DQVIA_6oJsEFkEL
    Build id: M20080221-1800

    Eclipse Graphical Editing Framework

    Version: 3.3.1.v20070814
    Build id: 20070814-1555

    Eclipse startup command=-os
    win32
    -ws
    win32
    -arch
    x86
    -showsplash
    -launcher
    C:\eclipse\eclipse.exe
    -name
    Eclipse
    –launcher.library
    C:\eclipse\plugins\org.eclipse.equinox.launcher.win32.win32.x86_1.0.3.R33x_v20080118\eclipse_1023.dll
    -startup
    C:\eclipse\plugins\org.eclipse.equinox.launcher_1.0.1.R33x_v20080118.jar
    -product
    com.genuitec.myeclipse.product.ide
    -vm
    D:\Java\jre1.6.0_04\bin\client\jvm.dll

    #282778 Reply

    Riyad Kalla
    Member

    icon911,
    Can you PM me your hibernate.cfg.xml file? (you can use the PM button under my post to do so).

    #282858 Reply

    Riyad Kalla
    Member

    This message has not been recovered.

    Attachments:
    You must be logged in to view attached files.
    #282896 Reply

    icon911
    Member

    This message has not been recovered.

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: HQL Editor Error: Could not find datasource

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