0 Replies Latest reply on Mar 25, 2013 9:28 PM by klind

    Classloading in ear file with war file...

    klind Newbie

      Hi, I have a maven project with an EJB module and a WAR module...

       

      The WAR module consist of a web app that uses hibernate.. at the moment is uses this to get a session..

       

       

      final String url = String.format("jdbc:postgresql://%s:%s/%s", host, port, dbname);
      final Configuration configuration = new Configuration();
      configuration.setProperty("hibernate.connection.url", url);
      configuration.setProperty("hibernate.connection.username", username);
      configuration.setProperty("hibernate.connection.password", password);
      configuration.setProperty("hibernate.connection.drive_class", "org.postgresql.Driver");
      configuration.setProperty("hibernate.connection.pool_size", "2");
      configuration.setProperty("hibernate.current_session_context_class", "thread");
      configuration.setProperty("hibernate.hbm2ddl.auto", "update");
      configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect");
      SessionFactory sessionFactory = configuration.buildSessionFactory();
      
      

       

      This will later be changed to use the datasource in JBoss, but I need to this to work for now.

       

      The problem is that I get a :

       

      18:03:21,113 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] (http--127.0.0.1-8080-1) HHH000299: Could not complete schema update: java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/jsi3-test

       

      I have the postgresql-9.2-1002.jdbc4.jar in the ear/lib, and

      <ear-subdeployments-isolated>false</ear-subdeployments-isolated>

      in the jboss-deployment-structure.xml, so the war file has the driver in the classpath. ( There are other jar files in the ear/lib that the war needs )

       

      If I then try to deploy the war alone, and of cause add all the jar files in the war/lib, including the postgresql-9.2-1002.jdbc4.jar, I don't get that error anymore...

      And I can see the hbm2dll is creating the tables.