Reputation: 23
We have a java web app that I am having some JDBC issues with. Last year, while on Java 7, we had no problem connecting to a SQL database on another server on the same network using sqljdbc4.jar. We upgraded our application to Java 8 this year and this is when problems arose. We updated the JDBC version to 4.2 (sqljdbc42.jar). The .jar file is included in our build path and this worked a year ago. We are using JBOSS 7.0 in the Eclipse-Luna IDE.
Now when we try to use the JDBC, we get a java.lang.ClassNotFoundException.
Connection conn = null;
String db_hostname = "test.fake.com";
String db_portNumber = "1433";
String db_name = "db";
String db_userid = "user";
String db_password = "password";
String db_final_string = "jdbc:sqlserver://" + db_hostname + ":" + db_portNumber + ";databaseName=" + db_name;
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
conn = DriverManager.getConnection(_db_final_string, _db_userid, _db_password);
This is the error we get due to Class.forName():
15:30:12,919 ERROR [stderr] (http--0.0.0.0-9091-5) java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver from [Module "deployment.irw-ear.ear:main" from Service Module Loader]
15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)
15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)
15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)
15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)
15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)
15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at java.lang.Class.forName0(Native Method)
15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at java.lang.Class.forName(Unknown Source)
15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.irw.delegate.IAContentDelegate.getIADataFromClient(IAContentDelegate.java:1776)
15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.irw.delegate.IAContentDelegate.getIAData(IAContentDelegate.java:1751)
15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.irw.ejb.IAContentBean.getIAData(IAContentBean.java:188)
15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
15:30:12,920 ERROR [stderr] (http--0.0.0.0-9091-5) at java.lang.reflect.Method.invoke(Unknown Source)
15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:370)
15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.irw.ejb.BaseBean.intercept(BaseBean.java:27)
15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at java.lang.reflect.Method.invoke(Unknown Source)
15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptor.java:67)
15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:370)
15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.irw.ejb.BaseBean.intercept(BaseBean.java:27)
15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
15:30:12,921 ERROR [stderr] (http--0.0.0.0-9091-5) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at java.lang.reflect.Method.invoke(Unknown Source)
15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptor.java:67)
15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:45)
15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:44)
15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
15:30:12,922 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ee.component.ViewDescription$ComponentDispatcherInterceptor.processInvocation(ViewDescription.java:202)
15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:50)
15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor$CustomSessionInvocationContext.proceed(SessionInvocationContextInterceptor.java:126)
15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:211)
15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:284)
15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:182)
15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor.processInvocation(SessionInvocationContextInterceptor.java:71)
15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
15:30:12,923 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:146)
15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:76)
15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.ithos.irw.api.IIAContent$$$view10.getIAData(Unknown Source)
15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.ithos.irw.IAContentView.getIADataDubois(IAContentView.java:123)
15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.ithos.irw.IAContentView.insertExternalData(IAContentView.java:98)
15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.ithos.irw.IAContentView.doPost(IAContentView.java:62)
15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
15:30:12,924 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
15:30:12,925 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.ithos.irw.filter.IRWFilter.filterRequest(IRWFilter.java:176)
15:30:12,925 ERROR [stderr] (http--0.0.0.0-9091-5) at com.softified.ithos.irw.filter.IRWFilter.doFilter(IRWFilter.java:97)
15:30:12,925 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
15:30:12,925 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
15:30:12,925 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
15:30:12,925 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
15:30:12,925 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139)
15:30:12,925 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57)
15:30:12,925 ERROR [stderr] (http--0.0.0.0-9091-5) at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49)
15:30:12,926 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154)
15:30:12,926 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
15:30:12,926 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:567)
15:30:12,926 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
15:30:12,926 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
15:30:12,926 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
15:30:12,926 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667)
15:30:12,926 ERROR [stderr] (http--0.0.0.0-9091-5) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952)
15:30:12,926 ERROR [stderr] (http--0.0.0.0-9091-5) at java.lang.Thread.run(Unknown Source)
If anyone can offer any insight on how to get this correctly configured that would be most helpful because we have tried several combinations of tweaks already.
Upvotes: 1
Views: 1376
Reputation: 23
I figured it out. I needed to make the jdbc driver a JBoss Module and include it in the standalone.xml as a global module.
Upvotes: 0
Reputation: 42020
JBoss AS 7 is not compatible* with Java 8. You need to update to WildFly 8/9.
Notes
* See more in AS 7 on Java 8.
Upvotes: 2
Reputation: 262
You have to download compatible Microsoft JDBC Driver for SQL Server
driver. You can find it inside msdn drivers.
https://msdn.microsoft.com/en-us/sqlserver/aa937724.aspx
this url should work.
Upvotes: 0