[jboss-user] [JBoss Tools (users)] - How to configure Hibernate Console in a Maven project ?

chawax do-not-reply at jboss.com
Thu Apr 3 09:38:52 EDT 2008


Hi,

I work on a Maven project with JPA Hibernate implementation for persistence. I would like to make Hibernate console work with this project, but I encounter problems.

My project has EJB3 entity classes (with JPA annotations) and this persistence.xml file (all in build path and so in classpath)  :

<?xml version="1.0" encoding="UTF-8"?>
  | <persistence 
  |     xmlns="http://java.sun.com/xml/ns/persistence"
  |     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  |     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
  |                         http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
  |     version="1.0">
  |     <persistence-unit name="t4Seam">
  |         <provider>org.hibernate.ejb.HibernatePersistence</provider>
  |         <jta-data-source>java:/jdbc/t4Seam</jta-data-source>
  |         <properties>
  |             <property name="hibernate.hbm2ddl.auto" value="update"/>
  |             <property name="hibernate.show_sql" value="false"/>
  |             <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
  |         </properties>
  |     </persistence-unit>
  | </persistence>

At runtime, database connection is configured with a datasource, so I added a hibernate.properties file to configure database connection for Hibernate console.

hibernate.connection.datasource=java:/jdbc/t4Seam
  | hibernate.connection.driver_class=com.mysql.jdbc.Driver
  | hibernate.connection.url=jdbc:mysql://localhost:3306/t4Seam
  | hibernate.connection.username=T4
  | hibernate.connection.password=T4
  | hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect

I then created my Hibernate Console configuration with "JPA" type, selected my hibernate.properties file, configured the persistence unit as "t4Seam" and added MySQL drivers in the classpath.

For what I understood, this is all I need to do since it looks for required files (EJB3 entities, persistence.xml) in the classpath. But when I jump to the Hibernate configuration view and double click on my configuration, I have the following stack trace :

Can't find mapping file
  | java.io.FileNotFoundException: Mapping for org.hibernate.cfg.AnnotationConfiguration at a9ae3e not found.
  | 
  | java.io.FileNotFoundException: Mapping for org.hibernate.cfg.AnnotationConfiguration at a9ae3e not found.
  | 	at org.hibernate.eclipse.console.actions.OpenMappingAction.run(OpenMappingAction.java:142)
  | 	at org.hibernate.eclipse.console.actions.OpenMappingAction.run(OpenMappingAction.java:92)
  | 	at org.hibernate.eclipse.console.views.KnownConfigurationsView$3.run(KnownConfigurationsView.java:165)
  | 	at org.hibernate.eclipse.console.views.KnownConfigurationsView$1.doubleClick(KnownConfigurationsView.java:100)
  | 	at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:799)
  | 	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
  | 	at org.eclipse.core.runtime.Platform.run(Platform.java:857)
  | 	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:46)
  | 	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:199)
  | 	at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:797)
  | 	at org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java:1387)
  | 	at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1173)
  | 	at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:237)
  | 	at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:234)
  | 	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:295)
  | 	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
  | 	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
  | 	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
  | 	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
  | 	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
  | 	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
  | 	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
  | 	at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
  | 	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
  | 	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
  | 	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
  | 	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
  | 	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
  | 	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
  | 	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
  | 	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
  | 	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
  | 	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.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
  | 	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
  | 	at org.eclipse.equinox.launcher.Main.run(Main.java:1173)

Which mapping file is it talking about ? It is JPA, so it doesn't need mapping files, doesn't it ? Is there something special to do to make it work with JPA ?

Thanks in advance for your help ;)

Olivier

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4141337#4141337

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4141337



More information about the jboss-user mailing list