How to use Field mapping for custom classes in an EJB2 CMP application in EAP6

Solution Unverified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x

Issue

  • We migrate an EJB2 application with CMP Entities to EAP6 and use the following jbosscmp-jdbc.xml mapping
  <user-type-mappings>
    <user-type-mapping>
      <java-type>custom.cmp.SimpleType</java-type>
      <mapped-type>java.lang.String</mapped-type>
      <mapper>custom.cmp.FieldMapper</mapper>
    </user-type-mapping>
  </user-type-mappings>
  • After deploy a legacy EJB2 CMP application in EAP6 we see the following Exception
ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC000001: Failed to start service jboss.deployment.unit."persistence.jar".component.LanguageCode.jdbc.store-manager.INIT: org.jboss.msc.service.StartException in service jboss.deployment.unit."persistence.jar".component.LanguageCode.jdbc.store-manager.INIT: JBAS010784: Failed to start JDBCStore
        ...
Caused by: java.lang.RuntimeException: JBAS010793: Could not create mapper: customer.cmp.FieldMapper
        ...
Caused by: java.lang.ClassNotFoundException: customer.cmp.FieldMapper from [Module "org.jboss.as.cmp:main" from local module loader @5b5ac942 (finder: local module finder @25533ae9 (roots: :\opt\jboss\jboss-eap-6.2.2\modules\system\layers\base\.overlays\layer-base-jboss-eap-6.2.2.CP,

Resolution

  • The mapper classes which implement the following interfaces JDBCParameterSetter, JDBCResultSetReader and Mapper need to change the packages for the interfaces from org.jboss.ejb.plugins.cmp.jdbc.Mapper to org.jboss.as.cmp.jdbc.Mapper.
  • Due to This content is not included.BZ 1085051
    • All the mappers must provided as a module
    • A dependency to the custom module is necesarry for the org.jboss.as.cmp module as the classes are needed at runtime
  • The user-type-mapping need to be added to the jbosscmp-jdbc.xml deployment descriptor
  • If one of the JDBC* classes need access to the DB specific driver libraries this dependency need to be also added to the org.jboss.as.cmp module

Root Cause

The Mapper interface is moved to a different package. From org.jboss.ejb.plugins.cmp.jdbc.Mapper to org.jboss.as.cmp.jdbc.Mapper.

There is a ClassLoader issue in EAP6 This content is not included.BZ924548

Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.