创建 JAXB 上下文时出现 JAXBException [英] JAXBException on creating JAXB Context

查看:23
本文介绍了创建 JAXB 上下文时出现 JAXBException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将应用程序作为独立的 Java 程序运行时,它运行良好.当我将它作为小程序运行时,它会抛出带有以下堆栈跟踪的 JAXBException.

When I run application as standalone Java program, it works well. When I run it as an applet, it throws JAXBException with following stacktrace.

javax.xml.bind.JAXBException: jaxb.properties in package com/test/package does not contain the javax.xml.bind.context.factory property.
    at javax.xml.bind.ContextFinder.find(Unknown Source)
    at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
    at javax.xml.bind.JAXBContext.newInstance(Unknown Source)

当我添加 jaxb.properties 时,出现以下错误 -

When I add a jaxb.properties, i get the below error -

javax.xml.bind.JAXBException
 - with linked exception:
[java.lang.NoSuchMethodException: com.sun.xml.internal.ws.developer.JAXBContextFactory.createContext([Ljava.lang.Class;, java.util.Map)]
    at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
    at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
    at javax.xml.bind.ContextFinder.find(Unknown Source)
    at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
    at javax.xml.bind.JAXBContext.newInstance(Unknown Source)

我在类路径中添加了以下 jars -

I added following jars to classpath -

  • jaxws-rt-2.2.1
  • jsr311-api-1.1.1
  • jersey-core-1.2
  • jersey-client-1.2

导致此错误的原因.我是否缺少任何依赖项.

What causes this error. Am I missing any dependencies.

我在浏览器和开发环境中都使用 Java 7 u 59.

I am using Java 7 u 59 on both browser and development environment.

推荐答案

第二个例外:检查从哪个 jar 引用的类并替换具有 createjaxbcontext 方法的正确 jar 文件.

Second Exception: Check the class getting referred from which jar and replace the proper jar file which has createjaxbcontext method.

在类路径中使用正确版本的 jar(jaxws-rt).

Use the proper version of jar in the classpath(jaxws-rt).

这篇关于创建 JAXB 上下文时出现 JAXBException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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