facebook

Criteria Editor Error

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

    javajohn
    Member

    When I open the Criteria editor I get an error stating that I can’t execute queries in the Criteria editor because the datasource couldn’t be found. It looks like the editor cant find the datasource listed in the hibernate hbm file. The datasource is a JBoss 6.0.0-Final datasource. I have tried opening the editor with and without the server running. (Server is running on same machine as Eclipse)

    My hibernate app has 5 hbm files because I am connecting to 5 different databases.

    Can the Criteria editor work with datasources? Is there some configuration I need to do? Will having 5 hbm files in the hibernate appp cause a problem with the editor?

    Any help is greatly appreciated!!

    Here is the stack trace I get when I open the criteria editor:

    2011-11-16 16:47:58,925 FATAL ModalContext org.hibernate.connection.DatasourceConnectionProvider – Could not find datasource: CamelotOneDS
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
    at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
    at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
    at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:414)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
    at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
    at org.hibernate.console.ConsoleConfiguration$3.execute(ConsoleConfiguration.java:395)
    at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:64)
    at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:95)
    at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:390)
    at com.genuitec.eclipse.hibernate.wizards.MEConsoleConfiguration.buildSessionFactory(MEConsoleConfiguration.java:225)
    at com.genuitec.eclipse.hibernate.action.MERefreshCCAction.buildSessionFactory(MERefreshCCAction.java:121)
    at com.genuitec.eclipse.hibernate.action.MERefreshCCAction$1.run(MERefreshCCAction.java:103)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)

    #321170 Reply

    support-tony
    Keymaster

    John,

    Just to be clear, are you saying that you have 5 configuration files? hbm files are mapping files, which don’t specify database connection parameters.

    How are you trying to ensure that the session used for your criteria is built using the configuration file you want?

    Can you provide your hibernate configuration file, or just the session-factory element contents, which defines the datasource?

    Could you provide your installation details (MyEclipse->Installation Summary->Installation Details), and mention the operation system and version, as well as the version of Hibernate that you’re using?

    #321185 Reply

    javajohn
    Member

    @support-tony wrote:

    John,

    Just to be clear, are you saying that you have 5 configuration files? hbm files are mapping files, which don’t specify database connection parameters.

    Sorry, I meant that I have 5 hibernate.cfg.xml files. They all contain a reference to a datasource and some of the database tables in the database that the datasource points to.
    Example:
    hibernate.cfg.xml <- default cfg file. contains datasource1 that points to db1.
    hibernateFile2.cfg.xml <- cfg file. contains datasource2 that points to db2.
    hibernateFile3.cfg.xml <- default cfg file. contains datasource3 that points to db3.
    hibernateFile4.cfg.xml <- default cfg file. contains datasource4 that points to db4.
    hibernateFile5.cfg.xml <- default cfg file. contains datasource5 that points to db5.

    Each cfg file has its own session object that is created and destroyed as needed in the hibernate app.
    Example:

    HibernateUtil.java:

    SessionFactory sessionFactory;
    ThreadLocal session = new ThreadLocal();
    SessionFactory sessionFactory2;
    ThreadLocal session2 = new ThreadLocal();
    SessionFactory sessionFactory3;
    ThreadLocal session3 = new ThreadLocal();
    SessionFactory sessionFactory4;
    ThreadLocal session4 = new ThreadLocal();
    SessionFactory sessionFactory5;
    ThreadLocal session5 = new ThreadLocal();

    sessionFactory = new Configuration().configure().buildSessionFactory();
    sessionFactory2 = new Configuration().configure(“hibernateFile2.cfg.xml”).buildSessionFactory();
    sessionFactory3 = new Configuration().configure(“hibernateFile3.cfg.xml”).buildSessionFactory();
    sessionFactory4 = new Configuration().configure(“hibernateFile4.cfg.xml”).buildSessionFactory();
    sessionFactory5 = new Configuration().configure(“hibernateFile5.cfg.xml”).buildSessionFactory();

    createSession()
    closeSession()
    ….
    ….

    @support-tony wrote:

    How are you trying to ensure that the session used for your criteria is built using the configuration file you want?

    I haven’t gotten far enough in the criteria editor to worry about building a session. It get an error message as soon as I open the criteria editor. I was wondering if there
    is a config file for the editor that will allow me to tell the criteria editor which hibernate.cfg.xml file to use?

    @support-tony wrote:

    Can you provide your hibernate configuration file, or just the session-factory element contents, which defines the datasource?

    hibernate.cfg.xml file:

    <?xml version=’1.0′ encoding=’UTF-8′?>
    <!DOCTYPE hibernate-configuration PUBLIC
    “-//Hibernate/Hibernate Configuration DTD 3.0//EN”
    http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd”&gt;

    <!– Generated by MyEclipse Hibernate Tools. –>
    <hibernate-configuration>

    <session-factory>

    <property name=”hibernate.connection.datasource”>MyDatasource</property>
    <property name=”dialect”>org.hibernate.dialect.Oracle10gDialect</property>
    <property name=”show_sql”>true</property>

    <mapping resource=”hibernate/config/FirstDBTableConfigFile.hbm.xml” />
    <mapping resource=”hibernate/config/SecondDBTableConfigFile.hbm.xml” />
    <mapping resource=”hibernate/config/ThirdDBTableConfigFile.hbm.xml” />
    <mapping resource=”hibernate/config/FourthDBTableConfigFile.hbm.xml” />

    </session-factory>

    </hibernate-configuration>

    @support-tony wrote:

    Could you provide your installation details (MyEclipse->Installation Summary->Installation Details), and mention the operation system and version, as well as the version of Hibernate that you’re using?

    *** Date:
    Thursday, November 17, 2011 10:44:03 AM CST

    ** System properties:
    OS=WindowsXP
    OS version=5.1.0
    Java version=1.6.0_13

    *** MyEclipse details:
    MyEclipse Enterprise Workbench
    Version: 9.1
    Build id: 9.1-20110701

    *** Eclipse details:
    MyEclipse Enterprise Workbench

    Version: 9.1
    Build id: 9.1-20110701

    Eclipse startup command=-os
    win32
    -ws
    win32
    -arch
    x86
    -showsplash
    -launcher
    C:\app\MyEclipse\MyEclipse 9\myeclipse.exe
    -name
    Myeclipse
    –launcher.library
    C:\app\MyEclipse\MyEclipse 9\../Common/plugins/org.eclipse.equinox.launcher.i18n.win32.win32.x86_3.2.0.v201103301700\eclipse_3215.dll
    -startup
    C:\app\MyEclipse\MyEclipse 9\../Common/plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
    -install
    C:\app\MyEclipse\MyEclipse 9
    -configuration
    C:\app\MyEclipse\MyEclipse 9\configuration
    -vm
    C:\app\MyEclipse\Common\binary\com.sun.java.jdk.win32.x86_1.6.0.013\jre\bin\client\jvm.dll

    Stacktrace generated when Criteria Editor open:

    !ENTRY org.hibernate.eclipse.console 4 4 2011-11-17 10:56:58.997 !MESSAGE Could not find datasource !SUBENTRY 1 org.hibernate.eclipse.console 4 150 2011-11-17 10:56:58.997
    !MESSAGE org.hibernate.HibernateException: Could not find datasource
    !STACK 0
    org.hibernate.HibernateException: Could not find datasource at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:56) at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124) at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56) at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:414) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292) at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915) at org.hibernate.console.ConsoleConfiguration$3.execute(ConsoleConfiguration.java:395) at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:64) at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:95) at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:390) at com.genuitec.eclipse.hibernate.wizards.MEConsoleConfiguration.buildSessionFactory(MEConsoleConfiguration.java:225) at com.genuitec.eclipse.hibernate.action.MERefreshCCAction.buildSessionFactory(MERefreshCCAction.java:121) at com.genuitec.eclipse.hibernate.action.MERefreshCCAction$1.run(MERefreshCCAction.java:103) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
    Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325) at javax.naming.InitialContext.lookup(InitialContext.java:392) at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52) … 15 more
    !SUBENTRY 2 org.hibernate.eclipse.console 4 150 2011-11-17 10:56:59.029 !MESSAGE org.hibernate.HibernateException: Could not find datasource
    !STACK 0 org.hibernate.HibernateException: Could not find datasource at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:56) at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124) at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56) at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:414) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292) at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915) at org.hibernate.console.ConsoleConfiguration$3.execute(ConsoleConfiguration.java:395) at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:64) at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:95) at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:390) at com.genuitec.eclipse.hibernate.wizards.MEConsoleConfiguration.buildSessionFactory(MEConsoleConfiguration.java:225) at com.genuitec.eclipse.hibernate.action.MERefreshCCAction.buildSessionFactory(MERefreshCCAction.java:121) at com.genuitec.eclipse.hibernate.action.MERefreshCCAction$1.run(MERefreshCCAction.java:103) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
    Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325) at javax.naming.InitialContext.lookup(InitialContext.java:392) at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52) … 15 more
    !SUBENTRY 2 org.hibernate.eclipse.console 4 150 2011-11-17 10:56:59.029
    !MESSAGE javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    !STACK 0
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325) at javax.naming.InitialContext.lookup(InitialContext.java:392) at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52) at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124) at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56) at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:414) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292) at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915) at org.hibernate.console.ConsoleConfiguration$3.execute(ConsoleConfiguration.java:395) at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:64) at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:95) at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:390) at com.genuitec.eclipse.hibernate.wizards.MEConsoleConfiguration.buildSessionFactory(MEConsoleConfiguration.java:225) at com.genuitec.eclipse.hibernate.action.MERefreshCCAction.buildSessionFactory(MERefreshCCAction.java:121) at com.genuitec.eclipse.hibernate.action.MERefreshCCAction$1.run(MERefreshCCAction.java:103) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
    !ENTRY org.hibernate.eclipse.console 1 0 2011-11-17 10:56:59.029
    !MESSAGE Could not refresh Hibernate project context com.genuitec.eclipse.hibernate.action.MERefreshCCAction$InProgressException

    #321186 Reply

    javajohn
    Member

    I tried replacing the datasources in my cfg.xml files with connect strings that point to my databases. The editor now opens without error but when I try to execute any Criteria code I get an error. I get the error everytime I press the execute button in the criteria editor. The button to refresh the session does nothing. Here is the error:

    !ENTRY org.eclipse.ui 4 0 2011-11-17 11:50:56.188
    !MESSAGE Unhandled event loop exception
    !STACK 0
    java.lang.IllegalArgumentException: The validated expression is false
    at org.apache.commons.lang.Validate.isTrue(Validate.java:179)
    at com.mousefeed.client.collector.ActionDesc.setLabel(ActionDesc.java:64)
    at com.mousefeed.eclipse.ActionActionDescGenerator.generate(ActionActionDescGenerator.java:99)
    at com.mousefeed.eclipse.GlobalSelectionListener.processContributionItem(GlobalSelectionListener.java:111)
    at com.mousefeed.eclipse.GlobalSelectionListener.handleEvent(GlobalSelectionListener.java:94)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1253)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    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.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1407)

    #321210 Reply

    support-tony
    Keymaster

    John,

    I’m not sure that JBoss datasources can be used outside of JBoss (e.g. in a web application running on JBoss). You’d have to check the JBoss documentation for that but I think I’ve seen that mentioned somewhere in there.

    I can’t replicate your problem with JDBC. Can you post the new config file here, and the code you’re trying to execute in the criteria editor? Have you tried a new criteria editor? If possible, could you try with a fresh workspace? I’d also suggest trying the HQL editor to see if the same problem occurs there.

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Criteria Editor Error

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