使用 jaxb api 的 java 类在 jira 中失败:Provider com.sun.xml.bind.v2.ContextFactory not found [英] java class using jaxb api failing in jira with : Provider com.sun.xml.bind.v2.ContextFactory not found

查看:17
本文介绍了使用 jaxb api 的 java 类在 jira 中失败:Provider com.sun.xml.bind.v2.ContextFactory not found的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 Jira 编写一个涉及 XML 文档解析的插件.我正在使用 JAXB 这样做(XML 到 pojos,反之亦然)所以有一个使用 JAXB 从 pojos 生成 XML 的类.好像……

I am writing a plugin for Jira which involves parsing of XML documents. I am using JAXB to do so (XML to pojos and vice versa) So have a class which generates XML from pojos using JAXB. it looks like...

import javax.xml.bind.*;

Class Parser {
  public void m1() {
    ...
    // code which uses classes in javax.xml.bind.*
  }

  public static void main(String args[]){
   Parser p=new Parser();
   p.m1();

  } 
}

上述软件包将随 JDK 发行版 (rt.jar) 一起提供.所以我没有转播任何其他内容来运行课程.

The mentioned packages will come with JDK distribution (rt.jar). so i haven't relayed on anything else to run the class.

当我使用java"从命令行启动它时,它工作正常.但是,当我打包时将其作为 jar 并将其作为插件放入 Jira 失败并出现以下错误

when i launch it from command line using 'java' it's working properly. but, when i package it as a jar and put it as plugin in Jira it's failing with the following error

javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory not found
 - with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory]
        at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:152)
        at javax.xml.bind.ContextFinder.find(ContextFinder.java:299)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)

这是在同一台机器上.我能看到的唯一区别是与从命令行启动不同,当我在 Jira 中部署它时,它不是通过实例化调用 main() 而是调用 m1().

This is on the same machine. only difference i could see is unlike launching from command line, when i deployed it in Jira, it's not calling the main() but m1() by instantiating.

我想知道发生了什么!它在同一台机器上.我不知道 Jira 是如何启动应用程序的(因为我是从命令行启动的).

I am wondering what is happening ! it's on the same machine. i do not know how Jira launches the application (as i am launching from command line).

推荐答案

com.sun.xml.bind 包是 JAXB RI (http://jaxb.dev.java.net/),所以你的类路径中可能有它.

The com.sun.xml.bind package is part of the JAXB RI (http://jaxb.dev.java.net/), so you probably have that on your classpath somewhere.

Java6 有自己的 JAXB 版本,包含在 com.sun.xml.internal.bind 包中,因此在 Java6 中通常不需要 RI.

Java6 has it's own version of JAXB included, in the com.sun.xml.internal.bind package, so you don't usually need the RI in Java6 .

RI可以与 Java6 一起使用,但这是一场艰苦的战斗,通常会出现此类问题.

The RI can made made to work with Java6 , but it's uphill battle, and usually ends up with this sort of problem.

这篇关于使用 jaxb api 的 java 类在 jira 中失败:Provider com.sun.xml.bind.v2.ContextFactory not found的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆