java类使用jaxb api失败在jira与:提供程序com.sun.xml.bind.v2.ContextFactory未找到 [英] java class using jaxb api failing in jira with : Provider com.sun.xml.bind.v2.ContextFactory not found

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

问题描述

我正在为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();

  } 
}

分布(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在 com.sun.xml.internal.bind 包中包含自己的JAXB版本,所以你通常不需要在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.

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

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