6 Replies Latest reply on Jul 22, 2008 3:43 PM by Peter Johnson

    JBOSS 5.0 + SQL SERVER 2005 = ClassNotFoundException: com.mi

    Fábio Szymanski Newbie

      Hi friends,

      I'm trying to use JBOSS 5.0 with MS SQLSERVER 2005, but I'm getting the following error:

      [JBossManagedConnectionPool] Throwable while attempting to get a new connection: null
      org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: com.microsoft.sqlserver.jdbc.SQLServerDriver; - nested throwable: (java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver.

      I put the lib driver in the server/default/lib folder and my datasource-ds.xml is like this

      <?xml version="1.0" encoding="UTF-8"?>
      <datasources>
       <local-tx-datasource>
       <jndi-name>MSSQLDS</jndi-name>
       <connection-url>
       jdbc:sqlserver://localhost;instanceName=SQL2005;portNumber=1433;databaseName=question;
       </connection-url>
       <driver-class>
       com.microsoft.sqlserver.jdbc.SQLServerDriver
       </driver-class>
       <user-name>xxx</user-name>
       <password>xxx</password>
       <metadata>
       <type-mapping>MS SQLSERVER</type-mapping>
       </metadata>
       </local-tx-datasource>
      </datasources>


      every time that I start the server, I get the error, what hell is going on...?
      Thanks to everyone.

        • 1. Re: JBOSS 5.0 + SQL SERVER 2005 = ClassNotFoundException: co
          Peter Johnson Master

          Which JBossAS 5.0? CR1?

          I assume that you verified that the JDBC driver JAR file you placed in server/default/lib actually contains the class com.microsoft.sqlserver.jdbc.SQLServerDriver.

          Also, avoid whitespace in XML file, much of the code that reads this stuff does not trimm leading or trailing whitespace. Change it to:

          <connection-url>jdbc:sqlserver://localhost;instanceName=SQL2005;portNumber=1433;databaseName=question;</connection-url>
           <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>



          • 2. Re: JBOSS 5.0 + SQL SERVER 2005 = ClassNotFoundException: co
            Fábio Szymanski Newbie

            Hi Peter

            Yes, I'm using CR1 and the JDBC driver JAR file was placed in server/default/lib, but don't work. I don't have idea why.

            • 3. Re: JBOSS 5.0 + SQL SERVER 2005 = may be solved
              Fábio Szymanski Newbie

              I found at https://sourceforge.net/project/shownotes.php?release_id=610469&group_id=22866
              the following bug of JBOSS * [JBAS-4911] - MSSQLValidConnectionChecker throws exception with MS SQL Server 2005 JDBC driver

              I need use MSSQL SERVER 2005 with JBoss, what can I do...?
              Anyone has some idea...?

              • 4. Re: JBOSS 5.0 + SQL SERVER 2005 = ClassNotFoundException: co
                Peter Johnson Master

                You misread the JIRA - the problem it mentions is fixed in CR1. It also does not match the error you are seeing.

                Did you make the *-ds.xml changes that I suggested?

                • 5. Re: JBOSS 5.0 + SQL SERVER 2005 = ClassNotFoundException: co
                  Fábio Szymanski Newbie

                  Hi, Peter

                  Yes, I did the changes but no success.
                  To me, in the group "Bug" is the bugs that are giving exceptions...It problem is make me crazy, because is everything right. With the JBoss 4.2.2 it works very well, but i can't make lookup of anyway, is because it I'm trying to use JBoss 5.0.
                  With JBoss 4.2.2 I try to make lookup like this:

                   context = new InitialContext();
                   PermissionDaoImpl pd = (PermissionDaoImpl)context.lookup("Question/PermissionDaoImpl/local");
                  

                  My beautiful error is it:
                  ClassCastException: Cannot cast $Proxy76 (id=306) to br.org.question.dao.PermissionDaoImpl

                  import javax.ejb.Local;
                  @Local
                  public interface PermissionDao {}


                  @Stateless
                  public class PermissionDaoImpl implements PermissionDao {
                  
                   @PersistenceContext(unitName="questionPU")
                   private EntityManager em;
                  }


                  when the JBoss 4.2.2 starts i have it:
                  15:41:58,250 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
                  15:41:58,250 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=Question.ear,jar=Question-EJB.jar,name=PermissionDaoImpl,service=EJB3 with dependencies:
                  15:41:58,250 INFO [JmxKernelAbstraction] persistence.units:ear=Question.ear,jar=Question-EJB.jar,unitName=questionPU
                  15:41:58,265 INFO [EJBContainer] STARTED EJB: br.org.question.dao.PermissionDaoImpl ejbName: PermissionDaoImpl


                  but of anyway i can make lookup.
                  Does anyone has some idea???
                  Thanks


                  • 6. Re: JBOSS 5.0 + SQL SERVER 2005 = ClassNotFoundException: co
                    Peter Johnson Master

                    What you just now posted has nothing to do with the original problem in your first post. Please focus on the initial problem and do not mention additional problems. You can start a new post about this new problem, and I suggest you do it in the JBossAS5 forum (http://www.jboss.com/index.html?module=bb&op=viewforum&f=287), but only after you have looked through that form for similar posts that might already answer that problem.

                    Getting back to the original problem. You say that after you make the changes I suggested to *-ds.xml that you are still getting the class not found exception, is that correct?

                    I do not use SQL Server, but I do use MySQL and PostgreSQL, and 5.0CR1 did not have any problems finding the drivers for those databases. So there must be some simple configuration error you are doing.

                    Here is what I would do. First I would list the classes in the JDBC driver JAR file using "jar -tf xxx.jar" and verify that the class name is correct.

                    Next I would determine if the SQLServerDriver class requires other classes (sometimes the problem is with a referenced class, and not the class reported in the class not found exception).

                    Finally, in the working 4.2.2 version, I would set the -verbose:class JVM option and determine where the SQLServerDriver class is being loaded. I would then add -verbose:class to 5.0CR1.

                    One of those things usually helps me to pinpoint the issue.