3 Replies Latest reply on Aug 7, 2017 2:35 PM by gir489

    Need help porting JBoss 4 module -> Wildfly 10

    gir489

      I'm currently tasked with getting our Java program out of the past and in to the future. It's currently running pseudo-compiled Java 6 (with a target of 1.3 in ANT), and using a lot of hacks to do "cutting" edge things at the time, like using com.sun.apt. I've since gutted all that garbage, and the program runs in full native Java 8 now. However, when I went to run the program in JBoss 4, at first everything was fine, until I tried MKYong's forEach example in one of our actions, the loadClass call coming from a Tomcat lib was crashing on the action that contained the J8 bytecode. I did some googling, and found that the ONLY version of "JBoss" that even supports Java 8 is Wildfly 8, the version that was created after JBoss switched its name to Wildfly. Right now I'm trying to setup some JNDI's for the server that JBoss 4 used to use, and this is how it's currently setup in standalone.xml:

              <datasource jta="true" jndi-name="java:/jdbc/oraclePool" pool-name="oraclePool" enabled="true" use-java-context="true" use-ccm="true">
                <connection-url>jdbc:sqlserver://DatabaseDNS:1433;DatabaseName=testdb;SelectMethod=cursor</connection-url>
                <driver>sqlserver2008</driver>
                <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
                <pool>
                  <min-pool-size>0</min-pool-size>
                  <max-pool-size>50</max-pool-size>
                  <prefill>false</prefill>
                  <use-strict-min>false</use-strict-min>
                  <flush-strategy>FailingConnectionOnly</flush-strategy>
                </pool>
                <security>
                  <user-name>test</user-name>
                  <password>test</password>
                </security>
                <validation>
                  <check-valid-connection-sql>select * from sysobjects</check-valid-connection-sql>
                </validation>
                <statement>
                  <prepared-statement-cache-size>300</prepared-statement-cache-size>
                  <share-prepared-statements></share-prepared-statements>
                </statement>
              </datasource>
           <drivers>
                <driver name="sqlserver2008" module="com.microsoft">
                <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
                </driver>
           </drivers>
      

       

      The driver is coming from here: https://developer.jboss.org/wiki/HowToSetADatasourceConnectionToMSSQLServer

       

       

      Subsequently my module.xml looks like this:

      <?xml version="1.0" encoding="UTF-8"?>
      <!-- JDBC Drivers module.xml file to configure your JDBC drivers-->
      <module xmlns="urn:jboss:module:1.3" name="com.microsoft">
        <resources>
          <resource-root path="sqljdbc4.jar"/>
        </resources>
        <dependencies>
          <module name="javax.api"/>
          <module name="javax.transaction.api"/>
        </dependencies>
      </module>
      

      And the directory for the module is:

               Directory: X:\WildflyTestBed\modules\com\microsoft\main
          Mode                LastWriteTime         Length Name
          ----                -------------         ------ ----
          -a----         8/3/2017  11:05 AM            377 module.xml
          -a----         8/3/2017  10:51 AM         584207 sqljdbc4.jar
      

       

      But I'm STILL getting a module error in the Wildfly console:

          11:10:57,485 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 33) WFLYCTL0013: Operation ("add") failed - address: ([
          ("subsystem" => "datasources"),
          ("jdbc-driver" => "sqlserver2008")
          ]) - failure description: "WFLYJCA0041: Failed to load module for driver [com.microsoft]"
      

       

      Any help anyone could provide would be amazing, as I've been stuck on this problem for 2 days now...

        • 1. Re: Need help porting JBoss 4 module -> Wildfly 10
          ptyagi_redhat.com

          Can you try with following driver and check:

                    <drivers>

                         <driver name="sqlserver2008" module="com.microsoft"> 

                            <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>

                            </driver> 

                     </drivers>

          • 2. Re: Need help porting JBoss 4 module -> Wildfly 10
            gir489

            I get the same error:

             

            12:38:57,129 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 33) WFLYCTL0013: Operation ("add") failed - address: ([
                ("subsystem" => "datasources"),
                ("jdbc-driver" => "sqlserver2008")
            ]) - failure description: "WFLYJCA0041: Failed to load module for driver [com.microsoft]"
            

             

            I talked to a colleague from a previous job where we were on JBoss 7.1.3 and he had recently ported it to Wildfly, he said they don't use the <drivers> attribute, and instead declare the JAR as the <driver> attribute for the JNDI, and put the JDBC driver in the deployments folder.

             

            This got rid of that specific error, but now it seems I'm having another module-related issue.

             

            12:25:56,924 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.subunit."gsx.ear"."Public_Jsp.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."gsx.ear"."Public_Jsp.war".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment "Public_Jsp.war" of deployment "gsx.ear"
                    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
            Caused by: java.lang.NoClassDefFoundError: Failed to link idapta/trading/internal/DirectoryServlet (Module "deployment.gsx.ear:main" from Service Module Loader): io/undertow/servlet/handlers/DefaultServlet
            

             

            Originally it was complaining about org.apache.catalina.servlets.DefaultServlet, and I figured this was from how we were using jbossweb.jar, so I removed that dependency from the ANT build, and replaced it with undertow-servlet-1.3.15.Final.jar. But now it's complaining it can't find undertow which makes no sense... So I think there's a greater issue at hand here, of Wildfly not loading modules for me properly, and I'm not sure why...

            • 3. Re: Need help porting JBoss 4 module -> Wildfly 10
              gir489

              I figured it out. After days of circling and being pissed off, the problem was the article I grabbed the module.xml from had a NO-BREAK SPACE character between module and xmlns, resource-root and path, and the module and names. I figured it out when comparing the h2 module.xml and Microsoft module.xml. The syntax highlighting for name was blue on my module.xml. Also, Wildfly uses modules\system\layers\base\com\microsoft\jdbc\main instead.

               

              So here's how I have it setup now for reference: https://pastebin.com/raw/m3uAt11Q

               

               Directory of X:\WildflyTestBed\modules\system\layers\base\com\microsoft\jdbc\main
              08/07/2017  01:07 PM    <DIR>          .
              08/07/2017  01:07 PM    <DIR>          ..
              08/07/2017  02:22 PM               379 module.xml
              05/15/2017  03:45 PM           584,207 sqljdbc4.jar
                             2 File(s)        584,586 bytes
                             2 Dir(s)  449,575,698,432 bytes free
              

               

              I guess whoever made that article wanted to play the Greek question mark prank on people. What a complete prick...