0

We developing web services with Axis2 framework (legacy system). With jdbc it working fine, but I need to use it with hibernate. I tried 2 approaches:

  1. (Outside aar) I put hibernate*.jars to EARContent/lib and hibernate.cfg.xml to WEB-ING/classes
  2. (inside aar) I put hibernate.cfg.xml to aar/META-INF/ and added to service.xml parameter <parameter name="ServiceTCCL">composite</parameter>

In first case I couldn’t reach hibernate.cfg.xml java.lang.RuntimeException: java.lang.RuntimeException: org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml

in 2nd case I lost access to JNDII seem to lose the container wide (jboss) jndi context.
java.lang.RuntimeException: javax.naming.NameNotFoundException: UserTransaction not bound

Thanks

Vik Gamov
  • 5,446
  • 1
  • 26
  • 46

1 Answers1

0

Actually, I fixed this issue with following code from my hibernate SessionFactoryUtils

 // Create the initial SessionFactory from the default configuration files
        log.debug("Initializing Hibernate");

        AxisService axisService = MessageContext.getCurrentMessageContext().getAxisService();
        ClassLoader serviceClassLoader = axisService.getClassLoader();

        URL configURL = serviceClassLoader.getResource("hibernate.cfg.xml");
        configuration = new AnnotationConfiguration();
        // Use annotations: configuration = new AnnotationConfiguration();

        // Read hibernate.cfg.xml (has to be present)
        configuration.configure(configURL);

        // Build and store (either in JNDI or static variable)
        rebuildSessionFactory(configuration);

So, I'm staing with hibernate.cfg.xml in my WebContent/WEB-INF/classes and with all libs in EAR.

Vik Gamov
  • 5,446
  • 1
  • 26
  • 46