Postgresql Wildfly Postgres JDBC模块问题

Postgresql Wildfly Postgres JDBC模块问题,postgresql,maven,jdbc,scope,wildfly-10,Postgresql,Maven,Jdbc,Scope,Wildfly 10,我在Wildfly 10中将postgres jdbc驱动程序配置为模块。我试图做的是,在将部署到服务器上的应用程序中使用该驱动程序作为依赖项—所以在应用程序中,我将该依赖项标记为提供的(在pom.xml文件中),但它似乎不起作用 当前配置: Wildfly postgres模块添加在Wildfly-10.1.0.Final\modules\org\postgresql\main中,其中有:postgresql-9.4-1206-jdbc4.jar和module.xml,内容如下: <mo

我在Wildfly 10中将postgres jdbc驱动程序配置为模块。我试图做的是,在将部署到服务器上的应用程序中使用该驱动程序作为依赖项—所以在应用程序中,我将该依赖项标记为提供的(在pom.xml文件中),但它似乎不起作用

当前配置:

Wildfly postgres模块添加在
Wildfly-10.1.0.Final\modules\org\postgresql\main
中,其中有:
postgresql-9.4-1206-jdbc4.jar
module.xml
,内容如下:

<module xmlns="urn:jboss:module:1.1" name="org.postgresql"> 
  <resources> 
    <resource-root path="postgresql-9.4-1206-jdbc4.jar"/> 
  </resources> 
   <dependencies> 
     <module name="javax.api"/> 
     <module name="javax.transaction.api"/> 
   </dependencies> 
</module> 
情景2

当我使用默认作用域的
postgresql-9.4-1206-jdbc4.jar
时,出现以下错误:

Caused by: java.lang.ClassCastException: org.postgresql.util.PGobject cannot be cast to org.postgresql.util.PGobject
    at com.project.entity.util.converters.JSONBTypeConverter.convertToEntityAttribute(JSONBTypeConverter.java:33)
    at com.project.entity.util.converters.JSONBTypeConverter.convertToEntityAttribute(JSONBTypeConverter.java:1)
    at org.hibernate.type.descriptor.converter.AttributeConverterSqlTypeDescriptorAdapter$2.doConversion(AttributeConverterSqlTypeDescriptorAdapter.java:140)
    ... 266 more
这意味着:类加载器加载同一个jar两次,并且不能将该对象强制转换为自身

问题:为什么
提供的
依赖范围不适用于手动添加(到wildfly)的postgres驱动程序?(我想这就是我的解决方案)

您需要使用添加模块依赖项到部署中


注意:可能不需要EAR上的模块依赖性。这取决于你的耳朵是如何设置的

另一个选择是添加一个。因为您使用的是Maven,所以可以使用
Maven jar插件
(因为这似乎是EAR中的一个jar)来创建条目


org.apache.maven.plugins
maven jar插件
org.postgresql

谢谢您的回答。第二个选项对我有效,但我不得不将这个清单条目放在我的ear插件中,并将
export
添加到dependency:org.postgresql exportFirst解决方案对我有效,将其放入
webapp/WEB-INF/jboss deployment structure.xml
文件中,不必声明项目名称,如果版本或名称更改,它必须更改…如果您使用maven,您可以使用资源插件替换表达式值。请粘贴
pom.xml
编辑您的答案好吗?我和你一样被困住了,但关于选定答案的第二条建议并没有解决我的问题。恐怕我做的和你做的略有不同。提前谢谢
Caused by: java.lang.ClassCastException: org.postgresql.util.PGobject cannot be cast to org.postgresql.util.PGobject
    at com.project.entity.util.converters.JSONBTypeConverter.convertToEntityAttribute(JSONBTypeConverter.java:33)
    at com.project.entity.util.converters.JSONBTypeConverter.convertToEntityAttribute(JSONBTypeConverter.java:1)
    at org.hibernate.type.descriptor.converter.AttributeConverterSqlTypeDescriptorAdapter$2.doConversion(AttributeConverterSqlTypeDescriptorAdapter.java:140)
    ... 266 more