Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver

Ramesh Udari1 January 21, 2015

Hi,

 

We have upgraded our JIRA version from 5.0.2 to 6.3.8 successfully and part of this upgrade proces we have also upgraded supported tomcat version to  apache-tomcat-7.0.55. But in this tomcat version we do not have common/lib folder and lib folder directly present in tomcat home directory only. We have custom code which connects to SQL server and we are trying to load driver "com.microsoft.sqlserver.jdbc.SQLServerDriver" from code, but in JIRA version 6.3.8 version it is giving class not found exception even we placed required sql jar "sqljdbc4.jar" in lib folder of tomcat. But it is working fine with tomcat 5 of JIRA 5.0.2 version. Please help us, do we need to configure anything else in tomcat 7.

 

One observation is that same code is working as standalone java program from eclipse but not in JIRA.

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 21, 2015

If you copy "sqljdbc4.jar" to your JIRA webapp's WEB-INF/lib directory will it help?

Ramesh Udari1 January 21, 2015

Hi Sash, We already tried same, but did not get any help on it. We are having this code in plug-in type 2(osgi). We observed one thing in log file under java system java properties still we seeing Catalina-home reference, is it correct or it should be replaced with that variable value? ___ Java System Properties ________________ atlassian.plugins.enable.wait : 300 awt.toolkit : sun.awt.windows.WToolkit catalina.base : C:\GL\Work\JIRA638\apache-tomcat-7.0.55 catalina.home : C:\GL\Work\JIRA638\apache-tomcat-7.0.55 catalina.useNaming : true common.loader : ${catalina.base}/lib, ${catalina.base}/lib/*.jar, ${catalina.home}/lib, ${catalina.home}/lib/*.jar file.encoding : Cp1252

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 21, 2015

Do you have ${catalina.home} and ${catalina.base} set ?

Ramesh Udari1 January 21, 2015

Yes we have both set that is why ${catalina.home} and ${catalina.base} showing their values.

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 21, 2015

you have mentioned that you use it in OSGI (as plugin), so it looks like a classloading issue Have you tried to bundle it with your plugin and how exactly do you get the connection (load the driver) in your plugin?

Ramesh Udari1 January 21, 2015

Below is the code using for connection: public java.sql.Connection getConnection( String userName, String password) throws ClassNotFoundException, SQLException { final String driverClassName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; String url = "jdbc:sqlserver://1.1.1.1:1433;databaseName=abc" Driver driver = null; try { driver = (Driver)Class.forName(driverClassName, true,Thread.currentThread().getContextClassLoader()).newInstance(); } catch (InstantiationException e) { logger.error("Unable to create instance of "+ driverClassName , e.getCause()); } catch (IllegalAccessException e) { logger.error("Unable to access the class "+ driverClassName , e.getCause()); } final Properties prop = new Properties(); prop.put("user",userName); prop.put("password",password); return driver.connect(url, prop); }

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2015

Class.forName will not work when used in OSGI, in a plugin... Try to use: com.opensymphony.util.ClassLoaderUtil instead. This is what XWorkModuleDescriptor class uses when you plugin is loaded.

Ramesh Udari1 February 1, 2015

Hi Sash, How it is working in tomcat 5.0.29 version with JIRA 5.0.2 version in OSGI plugin. Is there any changes between JIRA versions ?

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 2, 2015

well, it seems it did... you have updated both, tomcat and JIRA, and there is a big difference even in major version numbers, so I would expect that it has been changed. Take a look at this page, quite large and complex, but worth reading... https://developer.atlassian.com/docs/getting-started/working-with-the-pom/managing-dependencies {quote} In the past, you could add a JAR file to the WEB-INF/lib directory and make it available to all plugins, as well as the product itself. This no longer works, as the plugin system doesn't know about any code in the product beyond what it's been told to use; placing random JARs in WEB-INF/lib or class files in WEB-INF/classes will not make them available in the system bundle. {quote}

Ramesh Udari1 February 4, 2015

Hi Sash, It worked. Thanks for your help. Its really helped me a lot!!!.

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 4, 2015

Glad it is solved!

TAGS
AUG Leaders

Atlassian Community Events