gpt4 book ai didi

java - @XmlElementRef 问题 : Invalid XmlElementRef on property {property}, 引用的元素未声明

转载 作者:行者123 更新时间:2023-11-30 11:12:39 30 4
gpt4 key购买 nike

当我尝试在 SpringToolSuite 中进行调试时。它有时会引发异常

Invalid XmlElementRef on property expression on class org.opengeoportal.ogc.wmc.jaxb.UpperBoundaryType. Referenced Element not declared.

异常。但有趣的是,其他时候调试效果很好。我在网上四处张望,有些人认为这可能是图书馆冲突。那可能吗?如果是,我应该如何追踪问题?

错误信息:

2014-11-05 14:48:31 Jaxb2Marshaller [INFO] Creating JAXBContext with classes to be bound [class org.opengeoportal.ogc.wmc.jaxb.ViewContextType]
2014-11-05 14:48:31 ThreadPoolTaskExecutor [INFO] Shutting down ExecutorService
2014-11-05 14:48:31 ContextLoader [ERROR] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'marshaller': Invocation of init method failed; nested exception is org.springframework.oxm.UncategorizedMappingException: Unknown JAXB exception; nested exception is javax.xml.bind.JAXBException:
Exception Description: Invalid XmlElementRef on property expression on class org.opengeoportal.ogc.wmc.jaxb.UpperBoundaryType. Referenced Element not declared.
- with linked exception:
[Exception [EclipseLink-50006] (Eclipse Persistence Services - 2.5.2.v20131113-a7346c6): org.eclipse.persistence.exceptions.JAXBException
Exception Description: Invalid XmlElementRef on property expression on class org.opengeoportal.ogc.wmc.jaxb.UpperBoundaryType. Referenced Element not declared.]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:656)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1635)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)

我在 UpperBoundaryType.java 中的 @XmlElementRef公共(public)类 UpperBoundaryType {

@XmlElementRef(name = "expression", namespace = "http://www.opengis.net/ogc", type = JAXBElement.class)
protected JAXBElement<?> expression;

/**
* Gets the value of the expression property.
*
* @return
* possible object is
* {@link JAXBElement }{@code <}{@link PropertyNameType }{@code >}
* {@link JAXBElement }{@code <}{@link LiteralType }{@code >}
* {@link JAXBElement }{@code <}{@link BinaryOperatorType }{@code >}
* {@link JAXBElement }{@code <}{@link BinaryOperatorType }{@code >}
* {@link JAXBElement }{@code <}{@link BinaryOperatorType }{@code >}
* {@link JAXBElement }{@code <}{@link ExpressionType }{@code >}
* {@link JAXBElement }{@code <}{@link BinaryOperatorType }{@code >}
* {@link JAXBElement }{@code <}{@link FunctionType }{@code >}
*
*/
public JAXBElement<?> getExpression() {
return expression;
}

/**
* Sets the value of the expression property.
*
* @param value
* allowed object is
* {@link JAXBElement }{@code <}{@link PropertyNameType }{@code >}
* {@link JAXBElement }{@code <}{@link LiteralType }{@code >}
* {@link JAXBElement }{@code <}{@link BinaryOperatorType }{@code >}
* {@link JAXBElement }{@code <}{@link BinaryOperatorType }{@code >}
* {@link JAXBElement }{@code <}{@link BinaryOperatorType }{@code >}
* {@link JAXBElement }{@code <}{@link ExpressionType }{@code >}
* {@link JAXBElement }{@code <}{@link BinaryOperatorType }{@code >}
* {@link JAXBElement }{@code <}{@link FunctionType }{@code >}
*
*/
public void setExpression(JAXBElement<?> value) {
this.expression = ((JAXBElement<?> ) value);
}}

我的 ObjectFactory 文件定义了表达式

@XmlElementDecl(namespace = "http://www.opengis.net/ogc", name = "expression")
public JAXBElement<ExpressionType> createExpression(ExpressionType value) {
return new JAXBElement<ExpressionType>(_Expression_QNAME, ExpressionType.class, null, value);
}

在@XmlRegistry注解的类中

环境:STS 3.6.2JavaSE 1.7

原始答案:输入问题后立即发现!这可能是由于不兼容的 JDK 版本:@XMLElementRef 文件是使用 JDK 6 中的 vJAXB 2.1.10 创建的,但我项目的 Java 编译器是 7。将编译器更改为 6,它可以工作!

我曾经以为我找到了解决方案:JDK 版本不兼容。但它实际上不是......在我将JDK更改为1.6之后构建通过了几次但是之后调试仍然失败......

最佳答案

找出解决方案!

根据 this post : 删除 Java Servlet 中的 work/和 temp/目录就可以了。但我还是不明白为什么……有什么想法吗?

编辑:上述解决方案可能只是一个临时的解决方案。该错误实际上是我以前忽略的 bean 定义文件中的语法错误......修复后,一切正常!

2015 年 5 月 7 日更新

这原来是一个依赖于 IDE 的问题。此问题仅发生在 Eclipse/SST 中。当我使用 IntelliJ(完整版)时,这个问题就消失了。

艾伦

关于java - @XmlElementRef 问题 : Invalid XmlElementRef on property {property}, 引用的元素未声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26767334/

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