gpt4 book ai didi

enums - OSGi 依赖 hell : ClassNotFoundException: org. eclipse.persistence.internal.jaxb.WrappedValue

转载 作者:行者123 更新时间:2023-12-01 09:37:19 25 4
gpt4 key购买 nike

我有 Equinox、Jersey 和 MOXy 的工作环境。 Jersey 使用 MOXy 解析 JSON 并绑定(bind)到 bean 对象。将某些 @XmlRootElement 类的一个字段类型更改为枚举后,我得到:

java.lang.NoClassDefFoundError: org/eclipse/persistence/internal/jaxb/WrappedValue
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.lang.ClassLoader.defineClass(ClassLoader.java:642)
at org.eclipse.persistence.internal.jaxb.JaxbClassLoader.generateClass(JaxbClassLoader.java:124)
at org.eclipse.persistence.jaxb.compiler.MappingsGenerator.generateWrapperClass(MappingsGenerator.java:3232)
...

MOXy 包似乎没问题:

osgi> lb -l
...
50|Active | 4|initial@reference:file:plugins/org.eclipse.persistence.moxy_2.6.0.v20150309-bf26070.jar
...

jar 里有类

$ jar tf plugins/org.eclipse.persistence.moxy_2.6.0.v20150309-bf26070.jar | grep Wrapped
org/eclipse/persistence/internal/jaxb/WrappedValue.class

然后包被导出

osgi> bundle 50
...
Exported packages
org.eclipse.persistence.internal.jaxb; version="2.6.0"[exported]
...

那么为什么我得到 ClassNotFoundException?

编辑:德国联邦:

0|Active     |    0|System Bundle
1|Active | 4|initial@reference:file:plugins/org.mongodb.morphia_0.110.0.jar
2|Active | 4|initial@reference:file:plugins/javax.validation.api_1.1.0.Final.jar
3|Active | 4|initial@reference:file:plugins/classmate_1.0.0.jar
4|Active | 4|initial@reference:file:plugins/org.hibernate.validator_5.1.3.Final.jar
5|Active | 4|initial@reference:file:plugins/commons-logging_1.1.1.jar
6|Active | 4|initial@reference:file:plugins/org.eclipse.jetty.server_8.1.16.v20140903.jar
7|Active | 4|initial@reference:file:plugins/com.thoughtworks.proxytoys_1.0.0.jar
8|Active | 4|initial@reference:file:plugins/org.eclipse.jetty.http_8.1.16.v20140903.jar
9|Active | 4|initial@reference:file:plugins/org.eclipse.equinox.http.jetty_3.0.200.v20131021-1843.jar
10|Active | 4|initial@reference:file:../../../../edu.zut.aci.nsg.restapi/
11|Active | 4|initial@reference:file:plugins/org.mongodb.morphia.util_0.110.0.jar
12|Active | 4|initial@reference:file:plugins/org.eclipse.osgi.services_3.4.0.v20140312-2051.jar
13|Active | 4|initial@reference:file:plugins/org.eclipse.equinox.http.servlet_1.1.500.v20140318-1755.jar
14|Active | 4|initial@reference:file:plugins/org.glassfish.javax.json_1.0.4.jar
15|Active | 4|initial@reference:file:plugins/org.glassfish.jersey.ext.jersey-bean-validation_2.17.0.jar
16|Active | 4|initial@reference:file:plugins/org.glassfish.jersey.media.jersey-media-jaxb_2.17.0.jar
17|Active | 4|initial@reference:file:plugins/org.glassfish.hk2.utils_2.4.0.b10.jar
18|Active | 4|initial@reference:file:plugins/org.glassfish.jersey.containers.jersey-container-servlet_2.17.0.jar
19|Active | 4|initial@reference:file:plugins/org.glassfish.jersey.core.jersey-client_2.17.0.jar
20|Active | 4|initial@reference:file:plugins/org.eclipse.persistence.core_2.6.0.v20150309-bf26070.jar
21|Active | 4|initial@reference:file:plugins/javassist_3.18.1.GA.jar
22|Active | 4|initial@reference:file:plugins/org.eclipse.jetty.security_8.1.16.v20140903.jar
23|Active | 4|initial@reference:file:plugins/org.glassfish.hk2.external.javax.inject_2.4.0.b10.jar
24|Active | 4|initial@reference:file:plugins/com.eclipsesource.jaxrs.publisher_4.3.0.201503290743.jar
25|Active | 4|initial@reference:file:plugins/org.mongodb.mongo-java-driver_2.13.0.RELEASE.jar
26|Active | 4|initial@reference:file:plugins/org.eclipse.persistence.asm_5.0.1.v201405080102.jar
27|Active | 4|initial@reference:file:plugins/com.google.gson_2.3.1.jar
28|Active | 4|initial@reference:file:plugins/org.eclipse.jetty.util_8.1.16.v20140903.jar
29|Active | 4|initial@reference:file:plugins/org.eclipse.jetty.servlet_8.1.16.v20140903.jar
30|Active | 4|initial@reference:file:plugins/org.eclipse.jetty.io_8.1.16.v20140903.jar
31|Active | 1|initial@reference:file:plugins/org.eclipse.equinox.ds_1.4.200.v20131126-2331.jar
32|Active | 4|initial@reference:file:plugins/org.glassfish.hk2.api_2.4.0.b10.jar
33|Active | 4|initial@reference:file:plugins/org.apache.felix.gogo.runtime_0.10.0.v201209301036.jar
34|Active | 4|initial@reference:file:plugins/org.eclipse.jetty.continuation_8.1.16.v20140903.jar
35|Active | 4|initial@reference:file:plugins/org.eclipse.equinox.console_1.1.0.v20140131-1639.jar
36|Active | 4|initial@reference:file:plugins/com.eclipsesource.jaxrs.provider.security_2.1.0.201503290743.jar
37|Active | 4|initial@reference:file:plugins/javax.el_2.2.0.v201303151357.jar
38|Active | 4|initial@reference:file:plugins/javax.ws.rs-api_2.0.1.jar
39|Active | 4|initial@reference:file:plugins/org.glassfish.hk2.osgi-resource-locator_1.0.1.jar
40|Active | 4|initial@reference:file:plugins/org.glassfish.jersey.bundles.repackaged.jersey-guava_2.17.0.jar
41|Active | 4|initial@reference:file:plugins/org.jboss.logging.jboss-logging_3.1.3.GA.jar
42|Active | 4|initial@reference:file:plugins/org.eclipse.equinox.util_1.0.500.v20130404-1337.jar
43|Active | 4|initial@reference:file:plugins/org.glassfish.hk2.external.aopalliance-repackaged_2.4.0.b10.jar
44|Active | 4|initial@reference:file:plugins/javax.servlet-api_3.0.1.jar
45|Active | 4|initial@reference:file:plugins/org.apache.felix.gogo.shell_0.10.0.v201212101605.jar
46|Active | 4|initial@reference:file:plugins/org.glassfish.jersey.core.jersey-common_2.17.0.jar
47|Active | 4|initial@reference:file:plugins/org.glassfish.hk2.locator_2.4.0.b10.jar
48|Active | 4|initial@reference:file:plugins/javax.annotation-api_1.2.0.jar
49|Active | 4|initial@reference:file:plugins/org.apache.commons.configuration_1.10.0.jar
50|Active | 4|initial@reference:file:plugins/org.eclipse.persistence.moxy_2.6.0.v20150309-bf26070.jar
51|Active | 4|initial@reference:file:plugins/org.scala-lang.scala-library_2.11.6.v20150224-172222-092690e7bf.jar
52|Active | 4|initial@reference:file:plugins/org.apache.commons.lang_2.6.0.jar
53|Active | 4|initial@reference:file:plugins/org.glassfish.web.javax.el_2.2.4.jar
54|Active | 4|initial@reference:file:plugins/org.slf4j.api_1.7.2.v20121108-1250.jar
55|Active | 4|initial@reference:file:plugins/org.glassfish.jersey.containers.jersey-container-servlet-core_2.17.0.jar
56|Active | 4|initial@reference:file:plugins/org.apache.felix.gogo.command_0.10.0.v201209301215.jar
57|Active | 4|initial@reference:file:plugins/org.glassfish.jersey.core.jersey-server_2.17.0.jar

导致问题的数据模型更改:

来自:

@XmlRootElement
public class Role implements Serializable {

public static final String COMMON = "common";
public static final String REGISTRANT = "registrant";
...

到:

@XmlEnum(String.class)
public enum Role {

@XmlEnumValue("common") COMMON ("common"),
@XmlEnumValue("registrant") REGISTRANT ("registrant"),
@XmlEnumValue("laborant") LABORANT ("laborant"),
...

用法如下:

@XmlRootElement
public class User implements Principal, Serializable {
private static final long serialVersionUID = 1L;
...
private List<Role> roles = new ArrayList<Role>();
...

@PUT @Path("/{name}")
@Consumes({MediaType.APPLICATION_JSON, MediaType.TEXT_XML})
public Response register(@PathParam("name") String name, @Valid User user) {
...

最佳答案

我认为这可能是由于使用 JAXB 的包中的 Import-Package list header 中缺少条目引起的。我有一个类似的堆栈跟踪,当我添加 org.eclipse.persistence.jaxb 时它起作用了。

比照。 Maven Bundle 插件的以下代码段:

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Import-Package>
org.eclipse.persistence.jaxb,
*
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

关于enums - OSGi 依赖 hell : ClassNotFoundException: org. eclipse.persistence.internal.jaxb.WrappedValue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29429956/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com