title: Using a external jar. No suitable driver found for jdbc:sqlserver
body: <p>Hy guys,</p>
  
  <p>I'm facing a very "commom" problem with the sql driver. But don´t know how to solve. alredy tried almost all solutions out of there.</p>
  
  <p><strong>the ambient is:</strong></p>
  
  <p>-Principal JAR: This contains all the login and DB access via Hibernate</p>
  
  <p>-WebService WAR: This has 2 lines of code and only call the Principal JAR</p>
  
  <p>-Jboss: running the WebService on Jboss AS 7.1</p>
  
  <p><strong>my problem is:</strong></p>
  
  <p>After starting the server, when I call it´s method I recive the following error:</p>
  
  <pre><code>20:39:20,948 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-localhost-127.0.0.1-8080-1) SQL Error: 0, SQLState: 08001
  20:39:20,949 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-localhost-127.0.0.1-8080-1) No suitable driver found for jdbc:sqlserver://localhost;databaseName=SIPAAM;
  </code></pre>
  
  <p>My JAR also has a test class and if I execute that class ALL works fine. It access the DB and obtain all data withought problems. But when I reference it on my WebService it gives that error.
  Also my Persistence xml (is located on the .JAR project)</p>
  
  <p><img src="https://i.stack.imgur.com/daQ31.png" alt="enter image description here"></p>
  
  <hr>
  
  <p><strong>Additional info:</strong></p>
  
  <p><strong>My WebService code:</strong></p>
  
  <pre><code>@WebMethod
      public List&lt;DadosPreProcessamento&gt; getDadosPreProcessamento()
      {
          DadosPreProcessamentoController dadosPreProcessamentoController = DadosPreProcessamentoController.getInstance();
          return dadosPreProcessamentoController.getLista_dadosPreProcessamento();
      }
  </code></pre>
  
  <p><strong>My Hibernate Query (JAR internal):</strong></p>
  
  <pre><code>Query listQuery = em.createQuery("select object(c) from "
                      + entityClassName + " as c");
  return listQuery.getResultList();
  </code></pre>
  
  <p>The error occurs on the getResultList() method.</p>
  
  <hr>
  
  <p>I have alredy tried to add the sqljdbc4 library on my WS project as you can see on the pic bellow:</p>
  
  <p><img src="https://i.stack.imgur.com/OAQFp.png" alt="WS Libs Config"></p>
  
  <p><img src="https://i.stack.imgur.com/ElF01.png" alt="WS Deploy config"></p>