Hi
Ich habe ein Problem mit der umstellung von Hibernate nach JNDI, bzw. das Hibernate soll erhalten bleiben nur die Connection soll über JNDI laufen.
meine hibernate.cfg.xml:
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <!-- a SessionFactory instance listed as /jndi/name -->
    <session-factory
        name="java:hibernate/SessionFactory">
        <!-- properties -->
        <property name="connection.datasource">java:/jdbc/jndiUrlaubsplaner</property>
        <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
        <property name="show_sql">false</property>
        <property name="transaction.factory_class">
            org.hibernate.transaction.JTATransactionFactory
        </property>
    </session-factory>
</hibernate-configuration>
meine SessionFactory:
Code:
private void initalizeHibernate() {
       Contract.require(!isHibernateInitialized(), "Hibernate is not initialized yet");
       try
       {
           // Konfigurationsdateien einlesen
           URL mappingURL = getClass().getClassLoader().getResource("mapping.xml");
           InputStream in = getClass().getClassLoader().getResourceAsStream("hibernate.cfg.xml");
           Properties properties = new Properties();
           properties.load(in);
           System.out.println("test3");
           // Hibernate konfigurieren
           Configuration configuration = new Configuration();
           configuration.setProperties(properties);
           configuration.addURL(mappingURL);
   System.out.println("test4");
           // SessionFactory merken! Sie erzeugt die benötigten Sessions.
           _sessionFactory = configuration.configure("hibernate.cfg.xml").buildSessionFactory();
       }
       catch (HibernateException e)
       {
           System.out.println("Probleme beim Konfigurieren von Hibernate!");
           e.printStackTrace();
       }
       catch (IOException e)
       {
           System.out.println("Probleme beim Zugriff auf die Datei hibernate.properties");
           e.printStackTrace();
       }
   
       Contract.ensure(isHibernateInitialized(), "Hibernate is successfully initialized");
   }
als Fehlermeldung bekomme ich:
Quote:
[14.07.06 08:59:30:750 CEST] 6c805553 DatasourceCon F org.hibernate.connection.DatasourceConnectionProvider Could not find datasource: java:/jdbc/jndiUrlaubsplaner
[14.07.06 08:59:30:750 CEST] 6c805553 DatasourceCon F org.hibernate.connection.DatasourceConnectionProvider TRAS0014I: Die folgende Ausnahmebedingung wurde protokolliert: javax.naming.NameNotFoundException: Name not found in context "java:".