javax.naming.NoInitialContextException:无法实例化类:org.apache.naming.java.javaURLContextFactory

时间:2015-04-08 07:20:14

标签: jira hsqldb jira-plugin atlassian-plugin-sdk

我尝试使用以下java代码连接到jira的默认数据库(HSQL):

InitialContext initalContext = new InitialContext();            
Context context = (Context) initalContext.lookup("java:comp/env");          
dataSource = (DataSource) context.lookup("jdbc/JiraDS");

我已根据堆栈溢出中给出的答案添加了catalina.jarnaming-factory.jarnaming-java.jartomcat-juli.jar

但是,我仍然收到错误:

javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.naming.java.javaURLContextFactory [Root exception is java.lang.ClassNotFoundException: org.apache.naming.java.javaURLContextFactory]
  at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
  at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
  at javax.naming.InitialContext.init(Unknown Source)
  at javax.naming.InitialContext.<init>(Unknown Source)
  at in.componence.jira.plugin.util.JiraDataSourceUtil.getConnectionToJiraDB(JiraDataSourceUtil.java:40)

请帮帮我。

1 个答案:

答案 0 :(得分:0)

Classloader没有看到org.apache.naming.java.javaURLContextFactory。哪个jar文件包含该类的二进制文件?它必须在类路径上。可能有多个类加载器出现在呻吟声中,一个不是您关注的那个?