3 Replies Latest reply on Nov 30, 2015 4:48 AM by a b

    postgesql trouble

    a b Newbie

      I try this

      try {



      Inside a service pojo being called from a @ManagedBean java-class being called from an xhtml-page.


      I get this:

      java.lang.ClassNotFoundException: org.postgresql.Driver from [Module "deployment.moap.war:main" from Service Module Loader]


      The driver has been added in standalone.xml and also I can see driver being registered when starting up the server:


      11:26:42,840 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) WFLYJCA0005: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 9.4)

      11:26:42,841 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) WFLYJCA0018: Started Driver service with driver-name = postgres


      Any idea what more configuration is needed to be able to do Class.forName on the driver  ?

        • 1. Re: postgesql trouble
          Wolf-Dieter Fink Master

          If you add the driver, that only mean the server has it.

          If you use a datasource config that will work.


          If you use it from your application you need to add a dependency in your application.

          This can be done by manifest.mf or jboss-deployment-structure.xml


          See here Class Loading in AS7

          • 2. Re: postgesql trouble
            Jay SenSharma Master

            Suppose if you have created postgres module with name "org.postgresql" then try adding the following kind of "moap.war/WEB-INF/jboss-deployment-structure.xml" inside the


            <?xml version="1.0" encoding="UTF-8"?>
                        <module name="org.postgresql" />



            Try adding the following line of entry in your "moap.war/META-INF/MANIFEST.MF"


            Dependencies: org.postgresql

            Then try accessing your application.  Any of the above approach will ensure that the the JARs/classes present in your postgres module are accessible to the application.  Hence your call  Class.forName("org.postgresql.Driver");  should be successful now.   

            If you just declare the driver at the standalone.xml  driver section then it wont be available for the applications directly.


            Also if you do not want to make any changes at the application level (like adding "moap.war/WEB-INF/jboss-deployment-structure.xml"  or  alternatively adding "moap.war/META-INF/MANIFEST.MF") then you have the following additional options. Like declaring "global-modules"


            cd wildfly-8.2.1.Final/bin
            $ ./jboss-cli.sh -c
            [standalone@localhost:9990 /] /subsystem=ee:write-attribute(name="global-modules",value=[{"name" => "org.postgresql","slot" => "main"}])
            {"outcome" => "success"}
            [standalone@localhost:9990 /] :reload
                "outcome" => "success",
                "result" => undefined



            Running above cli command will generate the following entry in your "standalone.xml" which will cause the classes present in module to be accessible globally. (means all the deployed applications can use it now)


                    <subsystem xmlns="urn:jboss:domain:ee:2.0">
                            <module name="org.postgresql" slot="main"/>
            • 3. Re: postgesql trouble
              a b Newbie

              Hello and thanks for the reply.


              Neither method works.


              Method 1, adding module org.postgresql as jboss-deployment-structure.xml give this exception:


              [2015-11-30 10:44:19,638] Artifact moap-webapp:war: Artifact is being deployed, please wait...

              10:44:19,773 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0027: Starting deployment of "moap.war" (runtime-name: "moap.war")

              10:44:20,818 INFO  [org.jboss.as.jpa] (MSC service thread 1-7) WFLYJPA0002: Read persistence.xml for primary

              10:44:20,899 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC000001: Failed to start service jboss.module.service."deployment.moap.war".main: org.jboss.msc.service.StartException in service jboss.module.service."deployment.moap.war".main: WFLYSRV0179: Failed to load module: deployment.moap.war:main

                at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:91)

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

                at java.lang.Thread.run(Thread.java:745)

              Caused by: org.jboss.modules.ModuleNotFoundException: org.postgresql:main

                at org.jboss.modules.Module.addPaths(Module.java:1042)

                at org.jboss.modules.Module.link(Module.java:1398)




              Method 2, adding module org.postgresql as subsystem in standalone.xml give this exception:


              10:47:28,185 INFO  [org.jboss.as] (MSC service thread 1-6) WFLYSRV0049: WildFly Full 10.0.0.CR2 (WildFly Core 2.0.0.CR5) starting

              10:47:29,141 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 22) WFLYCTL0013: Operation ("add") failed - address: ([("subsystem" => "ee")]) - failure description: "WFLYCTL0212: Duplicate resource [(\"subsystem\" => \"ee\")]"

              10:47:29,143 INFO  [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 27) WFLYCTL0028: Attribute 'enabled' in the resource at address '/subsystem=datasources/data-source=ExampleDS' is deprecated, and may be removed in future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.

              10:47:29,357 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) "WFLYCTL0193: Failed executing subsystem ee boot operations"

              10:47:29,359 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("parallel-subsystem-boot") failed - address: ([]) - failure description: "\"WFLYCTL0193: Failed executing subsystem ee boot operations\""

              10:47:29,367 FATAL [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0056: Server boot has failed in an unrecoverable manner; exiting. See previous messages for details.

              10:47:29,372 INFO  [org.jboss.as.server] (Thread-2) WFLYSRV0220: Server shutdown has been requested.

              10:47:29,388 INFO  [org.jboss.as] (MSC service thread 1-4) WFLYSRV0050: WildFly Full 10.0.0.CR2 (WildFly Core 2.0.0.CR5) stopped in 12ms

              Disconnected from the target VM, address: '', transport: 'socket'

              Disconnected from server