Search code examples
javaspringjakarta-eeweblogicweblogic12c

WebLogic error: Unable to acquire JDBC Connection


I have a strange exception with WebLogic 12.2.1.3, Hibernate 5.3, Sprnig Data JPA, and Java EE.

I have a database, and a Generic JDBC Data source in weblogic, with the JNDI name of jdbc/UsersDS.

When I'm trying to list the entries in it, I get a really long exception, which I don't really want to paste in here, so I used Pastebin: Here it is. Pls let me know, if I should instead paste it here anyway.

I have the exact same setup for this artefact, then what I have for another one, which connects to the same server, but to a different database, with different user. That one works like a charm, this one doesn't. The only difference I can think of being related to this is the fact that the artefact, where I get the error from has Spring Data Redis included as a dependency alongside Spring Data JPA.

Persistence.xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns="http://xmlns.jcp.org/xml/ns/persistence"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd"
             version="2.2">
    <persistence-unit name="UsersDS" transaction-type="JTA">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <jta-data-source>jdbc/UsersDS</jta-data-source>
        <properties>
            <property name="hibernate.hbm2ddl.auto" value="update"/>
            <property name="hibernate.transaction.factory_class"
                      value="org.hibernate.transaction.JTATransactionFactory"/>
            <property name="hibernate.transaction.manager_lookup_class" value="javax.transaction.TransactionManager"/>
            <property name="hibernate.transaction.jta.platform" value="Weblogic"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL95Dialect"/>
        </properties>
    </persistence-unit>
</persistence>

Ui.: One more thing that might be related to the problem is because I have both Spring Data JPA and Redis on the classpath, I had to mark the JpaRepository interface as a @NoRepositoryBean, because I'd get a duplicate otherwise. So I have a method to produce the CDI Repository Bean:

    @Inject
    private EntityManager entityManager;

    @Produces
    @RequestScoped
    public UserRepository userRepository() {
        return createRepository(UserRepository.class);
    }

    private <T extends Repository> T createRepository(Class<T> repositoryClass) {
        RepositoryFactorySupport factory = new JpaRepositoryFactory(entityManager);
        return factory.getRepository(repositoryClass);
    }

UI2.: I also wrote some integration tests with a H2 in memory database and everything runs smoothly


Solution

  • I have the solution, and it's probably some workaround, or sg, but I have nothing else.

    So what happened, was I had (by default) in the weblogic datasource global transactions on. Switching it off solved the problem