1 2 Previous Next 15 Replies Latest reply on May 9, 2013 6:16 PM by sfcoy

    Could not load requested class : com.mysql.jdbc.Driver

    modinodavid

      Hi,

       

      I'm using JNDI + Hibernate + JBoss EAP 6.0; and I'm getting that error when I call to the method of "Managed Bean". I've followed the code statements in my code. Until Finally I've found the line that it throws that error. It's marked in bold.

       

      private static void openSessionFactory() {

                          Configuration configuration = new Configuration();

                          configuration.configure();

                          ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();

        // Create the session factory object to connect to the DataSource using JNDI defined in the file 'hibernate-cfg.xml' 

                          sessionFactory = configuration.buildSessionFactory(serviceRegistry);

        logger.info("Creating session factory");

                }


      In the other hand, I've checked the configuration files of the JBoss server "standalone.xml"

       

      <datasources>

                      <datasource jta="true" jndi-name="java:jboss/datasources/MySQLDS" pool-name="MySQLDS" enabled="true" use-java-context="true" use-ccm="true">

                          <connection-url>jdbc:mysql://localhost:3306/test</connection-url>

                          <driver>mysql</driver>

                          <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>

                          <pool>

                              <min-pool-size>10</min-pool-size>

                              <max-pool-size>100</max-pool-size>

                              <prefill>true</prefill>

                              <use-strict-min>false</use-strict-min>

                              <flush-strategy>FailingConnectionOnly</flush-strategy>

                          </pool>

                          <security>

                              <user-name>root</user-name>

                          </security>

                          <statement>

                              <prepared-statement-cache-size>32</prepared-statement-cache-size>

                          </statement>

                      </datasource>

                      <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">

                          <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>

                          <driver>h2</driver>

                          <security>

                              <user-name>test</user-name>

                              <password>test</password>

                          </security>

                      </datasource>

                      <drivers>

                          <driver name="mysql" module="com.mysql.jdbc"/>

                          <driver name="h2" module="com.h2database.h2">

                              <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>

                          </driver>

                      </drivers>

                  </datasources>



       


        • 1. Re: Could not load requested class : com.mysql.jdbc.Driver
          nickarls

          What are you trying to do? Any special reason you don't just @Resource inject a Datasource or use JPA?

          • 2. Re: Could not load requested class : com.mysql.jdbc.Driver
            modinodavid

            Hi Nicklas,

             

             

            I'm trying to inject local Datasource and Persitence Unit file with Hibernate.

             

             

            I've noticed that I forgot to comment:

             

            persitence.xml

             

            <?xml version="1.0" encoding="UTF-8"?>

            <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_2_0.xsd" version="2.0">

                <persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">

                

             

                <!-- DATA SOURCE -->

                          <jta-data-source>java:jboss/datasources/MySQLDS</jta-data-source>

                

                <!-- PROVIDER -->

                                <provider>org.hibernate.ejb.HibernatePersistence</provider>

                    <!-- PROPERTIES -->

                    <properties>           

                        <!-- Properties for Hibernate -->

                               <property name="hibernate.hbm2ddl.auto" value="validate" />

                               <property name="hibernate.show_sql" value="false" />

                    

                    </properties>

                </persistence-unit>

            </persistence>

             

             

             

            module.xml configuration file which is located in "com.mysql.jdbc.main" package and in the same directory I've added the driver of MySql "mysql-connector-java-5.1.24-bin.jar"

             

             

            <module xmlns="urn:jboss:module:1.1" name="com.mysql.jdbc">

                <resources>

                    <resource-root path="mysql-connector-java-5.1.24-bin.jar"/>

                    <!-- Insert resources here -->

                </resources>

                <dependencies>

                    <module name="javax.api"/>

                    <module name="javax.transaction.api"/>

                </dependencies>

            </module>

             

             

            Finally, the hibernate.cfg.xml file:

             

             

            <hibernate-configuration>

                <session-factory>

                    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

                    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>

                    <property name="hibernate.connection.username">root</property>

                    <property name="hibernate.connection.password"></property>

                    <property name="hibernate.connection.pool_size">10</property>

                    <property name="show_sql">true</property>

                    <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>

                    <property name="hibernate.current_session_context_class">thread</property>

                    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>  

                  

                <property name="hbm2ddl.auto">validate</property>

                <property name="hibernate.id.new_generator_mappings">true</property>

              

                <!--the mapping resources here -->

             

            </hibernate-configuration>

             

             

             

             

            So, could tell me what I am doing wrong???

             

             

            If you need more information or something I've not talked about my code ask me please!

             

             

            Thanks in advance.

            • 3. Re: Could not load requested class : com.mysql.jdbc.Driver
              nickarls

              Deployment errors? Or is the jdbc driver class missing thing? You might have to have an explicit reference to the driver module through jboss-deployment-structure.xml or a MANIFEST dependecy. Are you targetting JPA or plain Hibernate? I think you would get @Resource Datasource injection just be having a datasource defined with a jndi name in standalone.xml.

              • 4. Re: Could not load requested class : com.mysql.jdbc.Driver
                modinodavid

                Yes, it's a doployment error. Although, It tells me that I've missed the driver class... it's not possible because, I added the driver class in the belonging folder. I'm targeting Hibernate.

                 

                 

                I've checked to replace this line of datasource, removing  jta="true", but searching in the documentation I suppose that it's an irrelevante change.

                 

                <datasource jndi-name="java:jboss/mysql/MySQLDS" pool-name="mdissphoto_pool" enabled="true" use-java-context="true" use-ccm="true">

                 

                 

                I'm following steps for this URL.

                 

                http://planet.jboss.org/post/how_to_create_and_manage_datasources_in_as7

                 

                module folder.png

                • 5. Re: Could not load requested class : com.mysql.jdbc.Driver
                  sfcoy

                  Make sure that you do not have a copy of mysql-connector-*.jar embedded in your application.

                   

                  ie. in WEB-INF/lib or ear-file.ear/lib.

                  • 6. Re: Could not load requested class : com.mysql.jdbc.Driver
                    nickarls

                    While you're at it - list all jars, you might have hibernate.jars or other EE jars bundled that should be avoided.

                    • 7. Re: Could not load requested class : com.mysql.jdbc.Driver
                      modinodavid

                      Hi Stephen,

                       

                      I'm using Maven 2, so I've all the jars in the m2 directory. Is it possible I'd forgotten to tell pom.xml where is the driver alocated??

                       

                      Thanks in advance for helping.

                      • 8. Re: Could not load requested class : com.mysql.jdbc.Driver
                        nickarls

                        List the jars that get bundled with the app. The AS doesn't know about anything else (and if you use datasource in standalone.xml it will see the driver through the module reference)

                        • 9. Re: Could not load requested class : com.mysql.jdbc.Driver
                          modinodavid

                          Hi Nicklas,

                           

                          I added the captures of jars.

                           

                          Thanks in advance for helping.

                           

                          Maven dependencies.png

                          Maven dependencies part2.png

                          Maven dependencies part3.png

                          • 10. Re: Could not load requested class : com.mysql.jdbc.Driver
                            nickarls

                            Ouch. That's a lot of jars, probably 80% dead weight but I don't see any jars related to the problem.

                             

                            Try something like https://zorq.net/b/2011/07/12/adding-a-mysql-datasource-to-jboss-as-7/ , don't deploy the driver as jar (define as module), dont't use JPA either just go for a  (from the top of my head)

                             

                            @Resource(mappedName="java:jboss/mysql/MySQLDS")

                            private Datasource datasource

                             

                            and see if you get non-null

                            • 11. Re: Could not load requested class : com.mysql.jdbc.Driver
                              sfcoy

                              Please attach your pom.xml file. The dependencies that you've listed above look quite peculiar.

                               

                              Additionally, can you use the admin console to test the datasource connection?

                              • 12. Re: Could not load requested class : com.mysql.jdbc.Driver
                                modinodavid

                                Hi Nicklas,

                                 

                                I've followed the URL, it's similar to I've implemented, but I did a few changes.

                                I've changed the jndi-name and the pool-name (I think there aren't irrelevant changes but I did it)

                                 

                                Finally, you tell me use:

                                 

                                @Resource(mappedName="java:jboss/mysql/MySQLDS")

                                private Datasource datasource

                                 

                                What dependency I have to add to use Datasource object????

                                 

                                I've added this, but it doesn't detect the import of the object!!!

                                 

                                <dependency>

                                              <groupId>springframework</groupId>

                                    <artifactId>spring-jdbc</artifactId>

                                    <version>1.2.6</version>

                                </dependency>

                                 

                                --------------------------------------------------------------------------------------------------------------------

                                 

                                Hi Stephen,

                                 

                                I've a few modules in my Maven project, so it's not going to be easy to post all of them, and obviously to follow it!

                                 

                                Anyway, I post it all of them in different blocks in order to make easier you the reading.

                                 

                                In the other hand, I've gain accessed to the Admin Console of JBoss EAP 6, How can I test the datasource connection?

                                 

                                JBoss Admin Console Capture.png

                                 

                                 

                                 

                                nbaCommunity (Main project)

                                 

                                <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                                  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

                                  <modelVersion>4.0.0</modelVersion>

                                 

                                  <groupId>org.modino.nbaCommunity</groupId>

                                  <artifactId>nbaCommunity</artifactId>

                                  <version>1.0</version>

                                  <packaging>pom</packaging>

                                 

                                  <name>nbaCommunity</name>

                                  <url>http://maven.apache.org</url>

                                 

                                  <properties>

                                    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

                                  </properties>

                                 

                                  <!-- MODULES DEFINITION --> 

                                  <modules>

                                            <module>nbaCommunity-model</module>

                                            <module>nbaCommunity-web</module>

                                            <module>nbaCommunity-utils</module>

                                            <module>nbaCommunity-notifier</module>

                                  </modules>

                                 

                                  <dependencies>

                                    <!-- JBOSS DEPENDENCY -->

                                    <dependency>

                                              <groupId>org.jboss.as.plugins</groupId>

                                              <artifactId>jboss-as-maven-plugin</artifactId>

                                              <version>7.4.Final</version>

                                              <type>maven-plugin</type>

                                    </dependency>

                                <!-- JUNIT 4 -->

                                <dependency>

                                  <groupId>junit</groupId>

                                  <artifactId>junit</artifactId>

                                  <version>4.11</version>

                                </dependency>

                                <!-- SLF4j logging -->

                                <dependency>

                                  <groupId>org.slf4j</groupId>

                                  <artifactId>slf4j-log4j12</artifactId>

                                  <version>1.7.2</version>

                                </dependency>

                                  </dependencies>

                                 

                                </project>

                                ------------------------------------------------------------------------------------------------------------------------------------

                                 

                                nbaCommunity-model

                                 

                                <?xml version="1.0"?>

                                <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"

                                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

                                  <modelVersion>4.0.0</modelVersion>

                                 

                                  <parent>

                                    <groupId>org.modino.nbaCommunity</groupId>

                                    <artifactId>nbaCommunity</artifactId>

                                    <version>1.0</version>

                                  </parent>

                                 

                                  <groupId>org.modino.nbaCommunity.model</groupId>

                                  <artifactId>nbaCommunity-model</artifactId>

                                  <version>0.0.1-SNAPSHOT</version>

                                  <packaging>jar</packaging>

                                  <name>nbaCommunity-model</name>

                                  <url>http://maven.apache.org</url>

                                 

                                  <properties>

                                    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

                                    <eclipselink.version>2.4.0</eclipselink.version>

                                    <jboss.home></jboss.home>

                                    <jboss.server.name>default</jboss.server.name>

                                    <jboss.host.name>localhost</jboss.host.name>

                                    <jboss.port></jboss.port>

                                    <deployUrlPath></deployUrlPath>

                                    <undeployUrlPath></undeployUrlPath>

                                    <fileName></fileName>

                                  </properties>

                                 

                                  <!-- ECLIPSELINK PROJECT REPOSITORY -->

                                   <repositories>

                                <repository>

                                                    <id>EclipseLink</id>

                                                    <url>http://download.eclipse.org/rt/eclipselink/maven.repo</url>

                                </repository>

                                   </repositories>

                                 

                                 

                                  <dependencies>

                                    <dependency>

                                              <groupId>javax.inject</groupId>

                                    <artifactId>javax.inject</artifactId>

                                    <version>1</version>

                                    </dependency>

                                    <dependency>

                                              <groupId>javax.enterprise</groupId>

                                    <artifactId>cdi-api</artifactId>

                                              <version>1.1-20130305</version>

                                    </dependency>

                                    <!-- SPRING TEST -->

                                <dependency>

                                                    <groupId>org.springframework</groupId>

                                  <artifactId>spring-test</artifactId>

                                                    <version>3.2.1.RELEASE</version>

                                </dependency>   

                                    <!-- HIBERNATE 4 DEPENDENCIES -->

                                    <dependency>

                                              <groupId>org.hibernate</groupId>

                                    <artifactId>hibernate-core</artifactId>

                                              <version>4.2.0.CR2</version>

                                    </dependency>

                                    <dependency>

                                              <groupId>org.hibernate</groupId>

                                              <artifactId>hibernate-validator</artifactId>

                                              <version>5.0.0.CR1</version>

                                    </dependency>

                                    <dependency>

                                                    <groupId>org.hibernate</groupId>

                                                    <artifactId>hibernate-commons-annotations</artifactId>

                                  <version>3.2.0.Final</version>

                                </dependency>

                                    <!-- SHIRO DEPENDENCIES -->

                                    <dependency>

                                                    <groupId>org.apache.shiro</groupId>

                                  <artifactId>shiro-core</artifactId>

                                  <version>1.2.1</version>

                                </dependency>

                                    <dependency>

                                                    <groupId>org.apache.shiro</groupId>

                                  <artifactId>shiro-ehcache</artifactId>

                                  <version>1.2.1</version>

                                </dependency>

                                    <dependency>

                                                    <groupId>org.apache.shiro</groupId>

                                  <artifactId>shiro-web</artifactId>

                                  <version>1.2.1</version>

                                </dependency>

                                <!-- SPRING DEPENDENCIES -->

                                    <dependency>

                                              <groupId>org.springframework</groupId>

                                    <artifactId>spring-beans</artifactId>

                                              <version>3.2.1.RELEASE</version>

                                    </dependency>

                                    <dependency>

                                              <groupId>org.springframework</groupId>

                                    <artifactId>spring-jms</artifactId>

                                              <version>3.2.1.RELEASE</version>

                                    </dependency>

                                    <dependency>

                                              <groupId>org.springframework</groupId>

                                    <artifactId>spring-web</artifactId>

                                              <version>3.2.1.RELEASE</version>

                                    </dependency>

                                    <!-- MYSQL -->

                                <dependency>

                                  <groupId>mysql</groupId>

                                                    <artifactId>mysql-connector-java</artifactId>

                                  <version>5.1.23</version>

                                </dependency>

                                  <!-- eclipselink.jar with dependencies except commonj.sdo -->

                                <dependency>

                                                    <groupId>org.eclipse.persistence</groupId>

                                  <artifactId>eclipselink</artifactId>

                                                    <version>${eclipselink.version}</version>

                                  <exclusions>

                                  <exclusion>

                                  <artifactId>commonj.sdo</artifactId>

                                                                        <groupId>commonj.sdo</groupId>

                                  </exclusion>

                                  </exclusions>

                                </dependency>

                                  </dependencies>

                                </project>


                                 

                                ------------------------------------------------------------------------------------------------------------------------------------

                                 

                                nbaCommunity-utils

                                 

                                <?xml version="1.0"?>

                                <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"

                                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

                                  <modelVersion>4.0.0</modelVersion>

                                  <parent>

                                    <groupId>org.modino.nbaCommunity</groupId>

                                    <artifactId>nbaCommunity</artifactId>

                                    <version>1.0</version>

                                  </parent>

                                 

                                  <groupId>org.modino.nbaCommunity.utils</groupId>

                                  <artifactId>nbaCommunity-utils</artifactId>

                                  <packaging>jar</packaging>

                                  <version>0.0.1-SNAPSHOT</version>

                                  <name>nbaCommunity-utils</name>

                                  <url>http://maven.apache.org</url>

                                 

                                  <!-- Ubicacion de los ficheros de propiedades para el objeto PropertiesFacade.java

                                   PATHS, GLOBAL, OAUTH, THUMBNAILS, RESOLUTIONS    -->

                                  <properties>

                                    <nbaCommunity.resources.home>${env.NBACOMMUNITY_RESOURCES_HOME}</nbaCommunity.resources.home>

                                  </properties>

                                 

                                  <dependencies>

                                    <dependency>

                                      <groupId>junit</groupId>

                                      <artifactId>junit</artifactId>

                                      <version>3.8.1</version>

                                      <scope>test</scope>

                                    </dependency>

                                  </dependencies>

                                 

                                 

                                  <build>

                                  <resources>

                                  <resource>

                                                                        <directory>src/main/resources</directory>

                                  </resource>

                                  <!-- resources for all -->

                                  <resource>

                                                                        <directory>${nbaCommunity.resources.home}</directory>

                                  </resource>

                                  </resources>

                                             

                                              <plugins>

                                  <!-- Add dependencies (libs) to jar and make executable -->

                                  <plugin>

                                                                        <artifactId>maven-assembly-plugin</artifactId>

                                  <configuration>

                                  <descriptorRefs>

                                                                                            <descriptorRef>jar-with-dependencies</descriptorRef>

                                  </descriptorRefs>

                                  </configuration>

                                  <!-- <executions>

                                                                                  <execution>

                                                                                  <id>jar-with-dependencies</id>

                                                                                  <phase>package</phase>

                                                                                  <goals>

                                                                                            <goal>single</goal>

                                                                                  </goals>

                                                                                  </execution>

                                                                        </executions> -->

                                  </plugin>

                                  </plugins>

                                </build>

                                </project>



                                ------------------------------------------------------------------------------------------------------------------------------------


                                nbaCommunity-web

                                 

                                <?xml version="1.0"?>

                                <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"

                                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

                                  <modelVersion>4.0.0</modelVersion>

                                 

                                  <parent>

                                    <groupId>org.modino.nbaCommunity</groupId>

                                    <artifactId>nbaCommunity</artifactId>

                                    <version>1.0</version>

                                  </parent>

                                 

                                  <groupId>org.modino.nbaCommunity.web</groupId>

                                  <artifactId>nbaCommunity-web</artifactId>

                                  <version>0.0.1-SNAPSHOT</version>

                                  <packaging>war</packaging>

                                  <name>nbaCommunity-web</name>

                                  <url>http://maven.apache.org</url>

                                 

                                  <properties>

                                    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

                                    <spring-security.version>3.1.3.RELEASE</spring-security.version>

                                    <spring.version>3.2.2.RELEASE</spring.version>

                                  </properties>

                                 

                                  <repositories>

                                <!-- PRIMEFACES -->

                                <repository>

                                              <id>prime-repo</id>

                                              <name>PrimeFaces Maven Repository</name>

                                              <url>http://repository.primefaces.org</url>

                                              <layout>default</layout>

                                </repository>

                                <!-- JSF 2.1 and Later -->

                                <repository>

                                            <id>jvnet-nexus-releases</id>

                                            <name>jvnet-nexus-releases</name>

                                            <url>https://maven.java.net/content/repositories/releases/</url>

                                </repository>

                                  </repositories>

                                 

                                  <dependencies>

                                <!-- PRIMEFACES 3.5 -->

                                <dependency>

                                                    <groupId>org.primefaces</groupId>

                                  <artifactId>primefaces</artifactId>

                                  <version>3.5</version>

                                </dependency>

                                <!-- PRIMEFACES MOBILE -->

                                <dependency>

                                                    <groupId>org.primefaces</groupId>

                                  <artifactId>primefaces-mobile</artifactId>

                                  <version>0.9.3</version>

                                </dependency>

                                <!-- JSF 2.1 -->

                                <dependency>

                                               <groupId>javax.faces</groupId>

                                        <artifactId>jsf-api</artifactId>

                                        <version>2.1</version>

                                    </dependency>

                                <!-- PRETTY FACES for JSF 2.x-->

                                <dependency>

                                             <groupId>com.ocpsoft</groupId>

                                             <artifactId>prettyfaces-jsf2</artifactId>

                                             <version>3.3.3</version>

                                </dependency>

                                <!-- MODULE NBACOMMUNITY-MODEL -->

                                <dependency>

                                                    <groupId>org.modino.nbaCommunity.model</groupId>

                                                      <artifactId>nbaCommunity-model</artifactId>

                                                      <version>0.0.1-SNAPSHOT</version>

                                </dependency>

                                <!-- MODULE NBACOMMUNITY-UTILS -->

                                <dependency>

                                                    <groupId>org.modino.nbaCommunity.utils</groupId>

                                                    <artifactId>nbaCommunity-utils</artifactId>

                                                    <version>0.0.1-SNAPSHOT</version>

                                </dependency>

                                <!-- MODULE NBACOMMUNITY-NOTIFIER -->

                                <dependency>

                                                    <groupId>org.modino.nbaCommunity.notifier</groupId>

                                                    <artifactId>nbaCommunity-notifier</artifactId>

                                                    <version>0.0.1-SNAPSHOT</version>

                                </dependency>

                                <!-- SPRING SECURITY DEPENDENCIES -->

                                <dependency>

                                                    <groupId>org.springframework.security</groupId>

                                                    <artifactId>spring-security-core</artifactId>

                                                    <version>${spring-security.version}</version>

                                </dependency>

                                <dependency>

                                                    <groupId>org.springframework.security</groupId>

                                                    <artifactId>spring-security-web</artifactId>

                                                    <version>${spring-security.version}</version>

                                </dependency>

                                <dependency>

                                                    <groupId>org.springframework.security</groupId>

                                                    <artifactId>spring-security-config</artifactId>

                                                    <version>${spring-security.version}</version>

                                </dependency>

                                <dependency>

                                                    <groupId>org.springframework.security</groupId>

                                                    <artifactId>spring-security-taglibs</artifactId>

                                                    <version>${spring-security.version}</version>

                                </dependency>

                                <!-- SPRING 3 DEPENDENCIES -->

                                <dependency>

                                                    <groupId>org.springframework</groupId>

                                  <artifactId>spring-core</artifactId>

                                                    <version>${spring.version}</version>

                                </dependency>

                                <dependency>

                                                    <groupId>org.springframework</groupId>

                                  <artifactId>spring-web</artifactId>

                                                    <version>${spring.version}</version>

                                </dependency>

                                <!-- HttpServletRequest & HttpServletResponse dependency -->

                                <dependency>

                                                    <groupId>javax.servlet</groupId>

                                  <artifactId>servlet-api</artifactId>

                                  <version>3.0-alpha-1</version>

                                </dependency>

                                <dependency>

                                                    <groupId>org.apache.commons</groupId>

                                  <artifactId>commons-lang3</artifactId>

                                  <version>3.1</version>

                                </dependency>

                                <!-- MYSQL -->

                                <dependency>

                                  <groupId>mysql</groupId>

                                                    <artifactId>mysql-connector-java</artifactId>

                                  <version>5.1.23</version>

                                </dependency>

                                  </dependencies>

                                 

                                  <!-- web.xml file location-->

                                <build>

                                        <plugins>

                                            <plugin>

                                                <groupId>org.apache.maven.plugins</groupId>

                                                <artifactId>maven-war-plugin</artifactId>

                                                <configuration>

                                                    <webXml>src\main\webapp\WebContent\WEB-INF\web.xml</webXml>

                                                </configuration>

                                            </plugin>

                                        </plugins>

                                    </build>

                                </project>


                                • 13. Re: Could not load requested class : com.mysql.jdbc.Driver
                                  sfcoy

                                  I've taken a little while to answer this because those maven poms are going to cause you some issues:

                                  • they include the mysql-connector-java-*.jar in your application. This is probably what's causing your CNFE. There is a classloader conflict. Using a datasource decouples your application from the type of JDBC driver that you're using.
                                  • you have added the jboss-as-maven-plugin as a dependency instead of a build plugin. This results in whole pile of irrelevent transient dependencies being sucked into your application
                                  • you have included both the eclipse-link and the hibernate JPA implementations. You likely don't need the eclipse-link stuff at all
                                  • you have dependencies that refer to parts of the JEE API. These all need to be in scope "provided" so that they are not redundantly added to your application
                                  • your "parent" pom has dependencies declared in it. Usually, these should be in a dependency management section

                                   

                                  Here's (roughly) how I would do it:

                                   

                                  {code:xml}

                                  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                                    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

                                    <modelVersion>4.0.0</modelVersion>

                                    <groupId>org.modino.nbaCommunity</groupId>

                                    <artifactId>nbaCommunity</artifactId>

                                    <version>1.0-SNAPSHOT</version>

                                    <packaging>pom</packaging>

                                   

                                    <properties>

                                      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

                                      <version.eclipselink>2.4.0</version.eclipselink>

                                      <version.slf4j>1.7.2</version.slf4j>

                                      <version.shiro>1.2.1</version.shiro>

                                      <version.springframework>3.2.2.RELEASE</version.springframework>

                                      <version.spring-security>3.1.3.RELEASE</version.spring-security>

                                    </properties>

                                   

                                    <!-- MODULES DEFINITION -->

                                    <modules>

                                      <module>nbaCommunity-model</module>

                                      <module>nbaCommunity-web</module>

                                      <module>nbaCommunity-utils</module>

                                      <module>nbaCommunity-notifier</module>

                                    </modules>

                                   

                                   

                                    <build>

                                      <pluginManagement>

                                        <plugins>

                                          <plugin>

                                            <groupId>org.apache.maven.plugins</groupId>

                                            <artifactId>maven-compiler-plugin</artifactId>

                                            <version>3.0</version>

                                            <configuration>

                                                   <!-- http://maven.apache.org/plugins/maven-compiler-plugin/ -->

                                              <source>1.6</source>

                                              <target>1.6</target>

                                            </configuration>

                                          </plugin>

                                          <plugin>

                                            <groupId>org.jboss.as.plugins</groupId>

                                            <artifactId>jboss-as-maven-plugin</artifactId>

                                            <version>7.4.Final</version>

                                            <type>maven-plugin</type>

                                          </plugin>

                                        </plugins>

                                      </pluginManagement>

                                    </build>

                                   

                                    <repositories>

                                            <!-- PRIMEFACES -->

                                      <repository>

                                        <id>prime-repo</id>

                                        <name>PrimeFaces Maven Repository</name>

                                        <url>http://repository.primefaces.org</url>

                                        <layout>default</layout>

                                      </repository>

                                      <!-- JSF 2.1 and Later -->

                                      <repository>

                                        <id>jvnet-nexus-releases</id>

                                        <name>jvnet-nexus-releases</name>

                                        <url>https://maven.java.net/content/repositories/releases/</url>

                                      </repository>

                                    </repositories>

                                   

                                   

                                    <dependencyManagement>

                                      <dependencies>

                                              <!-- dependencies provide by the runtime environment -->

                                        <dependency>

                                          <groupId>javax.inject</groupId>

                                          <artifactId>javax.inject</artifactId>

                                          <version>1</version>

                                          <scope>provided</scope>

                                        </dependency>

                                        <dependency>

                                          <groupId>javax.enterprise</groupId>

                                          <artifactId>cdi-api</artifactId>

                                          <version>1.1-20130305</version>

                                          <scope>provided</scope>

                                        </dependency>

                                        <dependency>

                                          <groupId>javax.servlet</groupId>

                                          <artifactId>servlet-api</artifactId>

                                          <version>3.0-alpha-1</version>

                                          <scope>provided</scope>

                                        </dependency>

                                        <dependency>

                                          <groupId>javax.faces</groupId>

                                          <artifactId>jsf-api</artifactId>

                                          <version>2.1</version>

                                          <scope>provided</scope>

                                        </dependency>

                                        <dependency>

                                          <groupId>org.hibernate.javax.persistence</groupId>

                                          <artifactId>hibernate-jpa-2.0-api</artifactId>

                                          <version>1.0.1.Final</version>

                                          <scope>provided</scope>

                                        </dependency>

                                   

                                   

                                        <!-- HIBERNATE 4 DEPENDENCIES -->

                                        <dependency>

                                          <groupId>org.hibernate</groupId>

                                          <artifactId>hibernate-core</artifactId>

                                          <version>4.2.0.CR2</version>

                                        </dependency>

                                        <dependency>

                                          <groupId>org.hibernate</groupId>

                                          <artifactId>hibernate-validator</artifactId>

                                          <version>5.0.0.CR1</version>

                                        </dependency>

                                        <dependency>

                                          <groupId>org.hibernate</groupId>

                                          <artifactId>hibernate-commons-annotations</artifactId>

                                          <version>3.2.0.Final</version>

                                        </dependency>

                                        <!-- SHIRO DEPENDENCIES -->

                                        <dependency>

                                          <groupId>org.apache.shiro</groupId>

                                          <artifactId>shiro-core</artifactId>

                                          <version>${version.shiro}</version>

                                        </dependency>

                                        <dependency>

                                          <groupId>org.apache.shiro</groupId>

                                          <artifactId>shiro-ehcache</artifactId>

                                          <version>${version.shiro}</version>

                                        </dependency>

                                        <dependency>

                                          <groupId>org.apache.shiro</groupId>

                                          <artifactId>shiro-web</artifactId>

                                          <version>${version.shiro}</version>

                                        </dependency>

                                        <!-- SPRING DEPENDENCIES -->

                                        <dependency>

                                          <groupId>org.springframework</groupId>

                                          <artifactId>spring-core</artifactId>

                                          <version>${version.springframework}</version>

                                        </dependency>

                                        <dependency>

                                          <groupId>org.springframework</groupId>

                                          <artifactId>spring-beans</artifactId>

                                          <version>${version.springframework}</version>

                                        </dependency>

                                        <dependency>

                                          <groupId>org.springframework</groupId>

                                          <artifactId>spring-jms</artifactId>

                                          <version>${version.springframework}</version>

                                        </dependency>

                                        <dependency>

                                          <groupId>org.springframework</groupId>

                                          <artifactId>spring-web</artifactId>

                                          <version>${version.springframework}</version>

                                        </dependency>

                                        <!-- PRIMEFACES 3.5 -->

                                        <dependency>

                                          <groupId>org.primefaces</groupId>

                                          <artifactId>primefaces</artifactId>

                                          <version>3.5</version>

                                        </dependency>

                                        <!-- PRIMEFACES MOBILE -->

                                        <dependency>

                                          <groupId>org.primefaces</groupId>

                                          <artifactId>primefaces-mobile</artifactId>

                                          <version>0.9.3</version>

                                        </dependency>

                                        <!-- PRETTY FACES for JSF 2.x -->

                                        <dependency>

                                          <groupId>com.ocpsoft</groupId>

                                          <artifactId>prettyfaces-jsf2</artifactId>

                                          <version>3.3.3</version>

                                        </dependency>

                                        <!-- MODULE NBACOMMUNITY-MODEL -->

                                        <dependency>

                                          <groupId>org.modino.nbaCommunity.model</groupId>

                                          <artifactId>nbaCommunity-model</artifactId>

                                          <version>${project.version}</version>

                                        </dependency>

                                        <!-- MODULE NBACOMMUNITY-UTILS -->

                                        <dependency>

                                          <groupId>org.modino.nbaCommunity.utils</groupId>

                                          <artifactId>nbaCommunity-utils</artifactId>

                                          <version>${project.version}</version>

                                        </dependency>

                                        <!-- MODULE NBACOMMUNITY-NOTIFIER -->

                                        <dependency>

                                          <groupId>org.modino.nbaCommunity.notifier</groupId>

                                          <artifactId>nbaCommunity-notifier</artifactId>

                                          <version>${project.version}</version>

                                        </dependency>

                                        <!-- SPRING SECURITY DEPENDENCIES -->

                                        <dependency>

                                          <groupId>org.springframework.security</groupId>

                                          <artifactId>spring-security-core</artifactId>

                                          <version>${version.spring-security}</version>

                                        </dependency>

                                        <dependency>

                                          <groupId>org.springframework.security</groupId>

                                          <artifactId>spring-security-web</artifactId>

                                          <version>${version.spring-security}</version>

                                        </dependency>

                                        <dependency>

                                          <groupId>org.springframework.security</groupId>

                                          <artifactId>spring-security-config</artifactId>

                                          <version>${version.spring-security}</version>

                                        </dependency>

                                        <dependency>

                                          <groupId>org.springframework.security</groupId>

                                          <artifactId>spring-security-taglibs</artifactId>

                                          <version>${version.spring-security}</version>

                                        </dependency>

                                   

                                   

                                        <dependency>

                                          <groupId>org.apache.commons</groupId>

                                          <artifactId>commons-lang3</artifactId>

                                          <version>3.1</version>

                                        </dependency>

                                        <dependency>

                                          <groupId>org.slf4j</groupId>

                                          <artifactId>slf4j-api</artifactId>

                                          <version>${version.slf4j}</version>

                                        </dependency>

                                        <dependency>

                                          <groupId>org.slf4j</groupId>

                                          <artifactId>slf4j-log4j12</artifactId>

                                          <version>${version.slf4j}</version>

                                          <scope>runtime</scope>

                                        </dependency>

                                   

                                        <!-- JUNIT 4 -->

                                        <dependency>

                                          <groupId>junit</groupId>

                                          <artifactId>junit</artifactId>

                                          <version>4.11</version>

                                          <scope>test</scope>

                                        </dependency>

                                        <dependency>

                                          <groupId>org.springframework</groupId>

                                          <artifactId>spring-test</artifactId>

                                          <version>${version.springframework}</version>

                                          <scope>test</scope>

                                        </dependency>

                                   

                                      </dependencies>

                                    </dependencyManagement>

                                   

                                  </project>

                                  {code}

                                   

                                   

                                  {code:xml}

                                  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                                    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

                                    <modelVersion>4.0.0</modelVersion>

                                    <parent>

                                      <groupId>org.modino.nbaCommunity</groupId>

                                      <artifactId>nbaCommunity</artifactId>

                                      <version>1.0-SNAPSHOT</version>

                                    </parent>

                                   

                                   

                                    <artifactId>nbaCommunity-model</artifactId>

                                   

                                   

                                    <dependencies>

                                      <dependency>

                                        <groupId>javax.inject</groupId>

                                        <artifactId>javax.inject</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>javax.enterprise</groupId>

                                        <artifactId>cdi-api</artifactId>

                                      </dependency>

                                            <!-- SPRING TEST -->

                                      <dependency>

                                        <groupId>org.springframework</groupId>

                                        <artifactId>spring-test</artifactId>

                                      </dependency>

                                            <!-- HIBERNATE 4 DEPENDENCIES -->

                                      <dependency>

                                        <groupId>org.hibernate</groupId>

                                        <artifactId>hibernate-core</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>org.hibernate</groupId>

                                        <artifactId>hibernate-validator</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>org.hibernate</groupId>

                                        <artifactId>hibernate-commons-annotations</artifactId>

                                      </dependency>

                                            <!-- SHIRO DEPENDENCIES -->

                                      <dependency>

                                        <groupId>org.apache.shiro</groupId>

                                        <artifactId>shiro-core</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>org.apache.shiro</groupId>

                                        <artifactId>shiro-ehcache</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>org.apache.shiro</groupId>

                                        <artifactId>shiro-web</artifactId>

                                      </dependency>

                                            <!-- SPRING DEPENDENCIES -->

                                      <dependency>

                                        <groupId>org.springframework</groupId>

                                        <artifactId>spring-beans</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>org.springframework</groupId>

                                        <artifactId>spring-jms</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>org.springframework</groupId>

                                        <artifactId>spring-web</artifactId>

                                      </dependency>

                                    </dependencies>

                                  </project>

                                  {code}

                                   

                                   

                                  {code:xml}

                                  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                                    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

                                    <modelVersion>4.0.0</modelVersion>

                                    <parent>

                                      <groupId>org.modino.nbaCommunity</groupId>

                                      <artifactId>nbaCommunity</artifactId>

                                      <version>1.0-SNAPSHOT</version>

                                    </parent>

                                   

                                    <artifactId>nbaCommunity-utils</artifactId>

                                   

                                    <!-- Ubicacion de los ficheros de propiedades para el objeto PropertiesFacade.java

                                              PATHS, GLOBAL, OAUTH, THUMBNAILS, RESOLUTIONS -->

                                    <properties>

                                      <nbaCommunity.resources.home>${env.NBACOMMUNITY_RESOURCES_HOME}</nbaCommunity.resources.home>

                                    </properties>

                                   

                                    <dependencies>

                                      <dependency>

                                        <groupId>junit</groupId>

                                        <artifactId>junit</artifactId>

                                      </dependency>

                                    </dependencies>

                                   

                                    <build>

                                      <resources>

                                        <resource>

                                          <directory>src/main/resources</directory>

                                        </resource>

                                             <!-- resources for all -->

                                        <resource>

                                          <directory>${nbaCommunity.resources.home}</directory>

                                        </resource>

                                      </resources>

                                   

                                      <plugins>

                                              <!-- Add dependencies (libs) to jar and make executable -->

                                        <plugin>

                                          <artifactId>maven-assembly-plugin</artifactId>

                                          <configuration>

                                            <descriptorRefs>

                                              <descriptorRef>jar-with-dependencies</descriptorRef>

                                            </descriptorRefs>

                                          </configuration>

                                           <!-- <executions>

                                               <execution> <id>jar-with-dependencies</id> <phase>package</phase>

                                                                                    <goals> <goal>single</goal> </goals> </execution> </executions> -->

                                        </plugin>

                                      </plugins>

                                    </build>

                                   

                                   

                                  </project>

                                  {code}

                                   

                                   

                                  {code:xml}

                                  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                                    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

                                    <modelVersion>4.0.0</modelVersion>

                                    <parent>

                                      <groupId>org.modino.nbaCommunity</groupId>

                                      <artifactId>nbaCommunity</artifactId>

                                      <version>1.0-SNAPSHOT</version>

                                    </parent>

                                   

                                   

                                    <artifactId>nbaCommunity-web</artifactId>

                                    <packaging>war</packaging>

                                   

                                   

                                    <build>

                                      <plugins>

                                        <plugin>

                                          <groupId>org.apache.maven.plugins</groupId>

                                          <artifactId>maven-war-plugin</artifactId>

                                          <configuration>

                                            <webXml>src\main\webapp\WebContent\WEB-INF\web.xml</webXml>

                                          </configuration>

                                        </plugin>

                                      </plugins>

                                    </build>

                                   

                                   

                                    <dependencies>

                                      <dependency>

                                        <groupId>javax.servlet</groupId>

                                        <artifactId>servlet-api</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>javax.faces</groupId>

                                        <artifactId>jsf-api</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>org.primefaces</groupId>

                                        <artifactId>primefaces</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>org.primefaces</groupId>

                                        <artifactId>primefaces-mobile</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>com.ocpsoft</groupId>

                                        <artifactId>prettyfaces-jsf2</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>org.modino.nbaCommunity.model</groupId>

                                        <artifactId>nbaCommunity-model</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>org.modino.nbaCommunity.utils</groupId>

                                        <artifactId>nbaCommunity-utils</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>org.modino.nbaCommunity.notifier</groupId>

                                        <artifactId>nbaCommunity-notifier</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>org.springframework.security</groupId>

                                        <artifactId>spring-security-core</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>org.springframework.security</groupId>

                                        <artifactId>spring-security-web</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>org.springframework.security</groupId>

                                        <artifactId>spring-security-config</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>org.springframework.security</groupId>

                                        <artifactId>spring-security-taglibs</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>org.springframework</groupId>

                                        <artifactId>spring-core</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>org.springframework</groupId>

                                        <artifactId>spring-web</artifactId>

                                      </dependency>

                                      <dependency>

                                        <groupId>org.apache.commons</groupId>

                                        <artifactId>commons-lang3</artifactId>

                                      </dependency>

                                    </dependencies>

                                   

                                  </project>

                                  {code}

                                  • 14. Re: Could not load requested class : com.mysql.jdbc.Driver
                                    modinodavid

                                    Hi Stephen,

                                     

                                    I've done you told me in the last comment.... and I've arrived to the same way. JBoss Server throws the same exception again:

                                     

                                    Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [com.mysql.jdbc.Driver]

                                          at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141)

                                              at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:104)

                                              ... 60 more

                                     

                                     

                                    Caused by: java.lang.ClassNotFoundException: Could not load requested class : com.mysql.jdbc.Driver

                                              at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$1.findClass(ClassLoaderServiceImpl.java:99)

                                              at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

                                              at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

                                              at java.lang.Class.forName0(Native Method)

                                              at java.lang.Class.forName(Class.java:249)

                                              at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138)

                                              ... 61 more

                                     

                                     

                                    Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Specified JDBC Driver com.mysql.jdbc.Driver class not found

                                     

                                     

                                    Thanks for helping!! I'm very desperated!!

                                     

                                    Thanks in advance!

                                    1 2 Previous Next