Hi All,
I have written a plugin which read data from external mysql database.
I have copied the "mysql-connector-java-5.1.10-bin.jar" jar to 'jira\webapp\WEB-INF\lib' folde on my plugin enevironmet directory.
But while executoing the plugin i am getting ClassNotFoundException exception for com.mysql.jdbc.Driver.
Please find the stack trace below,
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:772)
at org.apache.felix.framework.ModuleImpl.access$200(ModuleImpl.java:73)
at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1690)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.microchip.jira.plugins.versionManagement.dao.DatabaseValuesViewHelper.<init>(DatabaseValuesViewHelper.java:43)
at com.microchip.jira.plugins.versionManagement.restservice.VersionManagementResource.updateLineageData(VersionManagementResource.java:725)
at com.microchip.jira.plugins.versionManagement.restservice.VersionManagementResource.createIpVersion(VersionManagementResource.java:651)
at com.microchip.jira.plugins.versionManagement.action.AddIpProject.doExecute(AddIpProject.java:506)
at webwork.action.ActionSupport.execute(ActionSupport.java:165)
at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:76)
at webwork.interceptor.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:39)
Could any let me know what should i do to fix it?
Is that i sould set it to classpath explicitly? Is not this jar will be accessible from 'jira\webapp\WEB-INF\lib' folder?
Thanks,
Vinutha
Community moderators have prevented the ability to post new answers.
Hi,
JIRA comes with JDBC drivers located in <insatllation-dir>/lib. IIRC due to licensing requirements, SDK does not include this libraries (that's why you are putting them to WEB-INF/lib). But that two different locations wrt classloaders.
How we handle it in JIRA Importers Plugin:
...
import com.atlassian.core.util.ClassLoaderUtils;
...
private Driver loadDriver(final String driverName) throws SQLException {
try {
final Class clazz = ClassLoaderUtils.loadClass(driverName, JdbcConnection.class);
return (Driver) clazz.newInstance();
} catch (ClassNotFoundException e) {
throw new SQLException("JDBC driver class not found: " + driverName, e);
} catch (Exception e) {
throw new SQLException("Cannot instantiate JDBC driver class " + driverName + ": " + e.getMessage(), e);
}
}
...
Then to streamline dev process we have a special test profile in our pom.xml (not used when releasing a plugin):
...
<profiles>
<profile>
<id>test</id>
<activation>
<property>
<name>environment</name>
<value>test</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.13</version>
<scope>runtime</scope>
</dependency>
</dependencies>
...
</profile>
I hope it helps.
Cheers,
Wojtek
Hi Wojciech,
Yes, It sovled my problem. Thank you.
Cheers,
Vinutha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.