DataSource PostgreSQL Widlfly

1

I'm trying to set a DataSource with PostgreSQL , but it's throwing this Exception

23:36:46,381 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 2) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "meuprojeto")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.meuprojeto#meuprojeto-dev" => "java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
    Caused by: java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory"}}
23:36:46,382 ERROR [org.jboss.as.server] (management-handler-thread - 2) WFLYSRV0021: Deploy of deployment "meuprojeto.war" was rolled back with the following failure message: 
{"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.meuprojeto#meuprojeto-dev" => "java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
    Caused by: java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory"}}
23:36:46,387 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 66) WFLYJPA0011: Stopping Persistence Unit (phase 1 of 2) Service 'meuprojeto#meuprojeto-dev'
23:36:46,535 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0028: Stopped deployment meuprojeto (runtime-name: meuprojeto.war) in 152ms
[2017-10-24 11:36:46,614] Artifact meuprojeto:war exploded: Error during artifact deployment. See server log for details.
[2017-10-24 11:36:46,614] Artifact meuprojeto:war exploded: java.lang.Exception: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.meuprojeto#meuprojeto-dev" => "java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
    Caused by: java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory"}}

DataSource in

asked by anonymous 25.10.2017 / 04:48

1 answer

2

The problem occurs because WildFly already has the hibernate libs on the server itself in different versions than the application's classpath.

When marking lib as provided in Maven you define that you will use the server library instead of your local classpath Ex:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>5.0.7.Final</version>
    <scope>provided</scope>
</dependency>

To use the libraries that exist in your application without provided you need to set them up in MANIFEST.MF, Ex:

Manifest-Version: 1.0
...
Dependencies: org.hibernate

See Widlfly Documentation

    
25.10.2017 / 21:13