- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我知道这是一个非常的远景,但我已经花了大约两周的时间试图解决这个问题,所以任何指向正确方向的想法都是无价的。
所以,我有一个使用 XmlBeans 的非常古老的应用程序。我的任务是从 Tomcat 7.0.67 迁移到 Tomcat 8.5.11,引入 Spring Sessions 和 Spring Security 而不是基于领域的身份验证。在迁移之前,在本地(MacOS、Oracle JDK 8)和 Heroku(Ubuntu、OpenJDK 8)上,一切都运行良好,但在迁移之后,一切都在我的本地环境中运行,但在 Heroku 上,有时,当应用程序试图解析一个字符串到适当的 XmlBean,发生此 ClassCastException:
java.lang.ClassCastException: foo.bar.2.impl.PreferencesDocumentImpl cannot be cast to foo.bar.1.PreferencesDocument
at foo.bar.1.PreferencesDocument$Factory.parse(Unknown Source)
我有两个由 XmlBeans 类自动生成的类,它们是从两个没有任何命名空间集的 xsd-schemas 生成的。类同名,但位于不同的包中(发生异常的parse方法位于Factory内部类中,其他方法省略):
/*
* An XML document type.
* Localname: Preferences
* Namespace:
* Java type: foo.bar.1.PreferencesDocument
*
* Automatically generated - do not modify.
*/
package foo.bar.1;
public interface PreferencesDocument extends org.apache.xmlbeans.XmlObject {
public static final org.apache.xmlbeans.SchemaType type = (org.apache.xmlbeans.SchemaType)
org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(PreferencesDocument.class.getClassLoader(), "schemaorg_apache_xmlbeans.system.s2D5798E4F4AFDA8394735C8512CDCBC7").resolveHandle("preferencesa8bfdoctype");
public static final class Factory {
public static foo.bar.1.PreferencesDocument parse(java.lang.String xmlAsString) throws org.apache.xmlbeans.XmlException {
return (foo.bar.PreferencesDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xmlAsString, type, null );
}
}
}
/*
* An XML document type.
* Localname: Preferences
* Namespace:
* Java type: foo.bar.1.PreferencesDocument
*
* Automatically generated - do not modify.
*/
package foo.bar.1.impl;
public class PreferencesDocumentImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements foo.bar.1.PreferencesDocument {
public PreferencesDocumentImpl(org.apache.xmlbeans.SchemaType sType) {
super(sType);
}
private static final javax.xml.namespace.QName PREFERENCES$0 = new javax.xml.namespace.QName("", "Preferences");
}
/*
* An XML document type.
* Localname: Preferences
* Namespace:
* Java type: foo.bar.2.PreferencesDocument
*
* Automatically generated - do not modify.
*/
package foo.bar.2;
public interface PreferencesDocument extends org.apache.xmlbeans.XmlObject {
public static final org.apache.xmlbeans.SchemaType type = (org.apache.xmlbeans.SchemaType)
org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(PreferencesDocument.class.getClassLoader(), "schemaorg_apache_xmlbeans.system.sC8953008EC716AA258D3951B84AB1CB7").resolveHandle("preferencesa8bfdoctype");
public static final class Factory {
public static foo.bar.2.PreferencesDocument parse(java.lang.String xmlAsString) throws org.apache.xmlbeans.XmlException {
return (foo.bar.2.PreferencesDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xmlAsString, type, null ); }
}
}
/*
* An XML document type.
* Localname: Preferences
* Namespace:
* Java type: foo.bar.2.PreferencesDocument
*
* Automatically generated - do not modify.
*/
package foo.bar.2.impl;
public class PreferencesDocumentImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements foo.bar.2.PreferencesDocument {
public PreferencesDocumentImpl(org.apache.xmlbeans.SchemaType sType) {
super(sType);
}
private static final javax.xml.namespace.QName PREFERENCES$0 =
new javax.xml.namespace.QName("", "Preferences");
}
}
有时,当部署到 Heroku 的应用程序重新启动时,问题消失了,但在再次重新启动后它又回来了。
根据 this ,根本原因是命名空间的缺失导致了冲突。但由于我们的要求,我无法添加或更改 xsds 的命名空间。那么您知道为什么它在本地与 Tomcat 7 一起工作,在本地与 Tomcat 8 一起工作,在 Heroku 上与 Tomcat 7 一起工作,但在 Heroku 上与 Tomcat 8 不工作吗?
提前致谢。
最佳答案
对于以下类别的错误,此答案也出现在顶部,因此我在此处添加我的答案:
class org.apache.xmlbeans.impl.values.XmlComplexContentImpl cannot be cast to class <class you generated a schema from>
这是一个非常奇怪的错误,毕竟为什么会发生这种转换呢?无论如何,这是因为我正在使用 maven-shade-plugin minimizeJar
功能并且它正在删除一些东西(我还不知道是什么),如果我弄清楚我到底需要什么明确地重新添加我会更新这个答案,但现在我只是禁用了 minimizeJar。
它似乎正在删除模式生成代码的 impl
部分。
更新:如果您想继续使用 minimizeJar,请将其添加到阴影插件的过滤器部分:
<filter>
<artifact>org.apache.xmlbeans:xmlbeans</artifact>
<includes>
<include>**</include>
</includes>
</filter>
更新 2:似乎上面的方法并不总是有效,我对这里的新问题很困惑,但重点仍然是 minimizeJar
是非常不稳定的 w.r.t 依赖项
关于java - XmlBeans.Factory 解析方法的 ClassCastException 不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43376800/
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: Recreating a Dictionary from an IEnumerable 在 Dictiona
是否可以使用命令行版本的 ImageMagick 修剪图像(比如带有 alpha 的 PNG),使输出图像的宽度和高度都是偶数(不是奇数)? 准确地说,应该先修剪输出图像,然后用透明像素填充。我需要这
我有一个订单的Map,可以由许多不同的线程访问。我想控制访问,所以考虑以下简单的数据结构+包装器。 public interface OrderContainer { boolean cont
我有以下代码,现在只是 div 中的一个 Logo ,但我正在尝试添加一些导航单元格,稍后我将对其进行样式设置。问题是,我似乎无法让它们与(除此之外) Logo “一致”,它们总是下降到下一行。我做错
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 9 年前。 Improve this qu
有没有办法将种子值传递给 d3-cloud 或其他基于 javascript 的标签云,以使其在页面加载之间保持一致? 我们的客户希望使用标签云作为导航/发现辅助工具,但由于 d3-cloud 会在每
我有一条由用户使用 D3.js 绘制的路径。 我想在我的用户绘制路径上定义一个破折号数组,但是,随着它改变其形状和长度,破折号的行为不一致并且间隙在移动并变得越来越小。 这是一个代码笔: https:
只是为了研究UINavigationBar和UIStatusBar的UI,我把Navigation Bar Style改成了Black,并且取消勾选Bar visibility,即Shows Navi
我最近在我的家用机器 (OSX 10.9) 和我的远程服务器 (Ubuntu 12.04 64 位) 上安装了 unison。 我在这两个地方都安装了 2.40.102 版本。我在我的 Mac 上使用
我正在使用 migrate 创建 SQL 数据库模式并用初始数据填充它。后来使用 SQLAlchemy 来处理这个数据库。 我如何测试我的 SQLAlchemy 模型是否与 migrate 生成的真实
道歉对这一切来说还是新鲜事。我正在创建一个网页,并在两个单独的 div 中将图像和文本并排放置。我已经设法将它们放在页面上我想要的位置,但是当我调整页面大小时,文本会调整大小,但图像不会。我希望文本底
在翻阅Cassandra和HBase的阅读资料时,我发现Cassandra并不一致,但HBase是一致的。没有找到任何合适的阅读 Material 。 有人可以提供有关此主题的任何博客/文章吗? 最佳
我需要计算 MacOS 中文件夹的大小。该尺寸值必须与 Finder 一致。我尝试了几种方法来做到这一点。但结果总是与Finder不同。 以下方法是我尝试过的。 typedef struct{
问:我可以使用 C++ 中的任何编译时机制来自动验证模板类方法集是否从类特化到特化相匹配? 示例:假设我想要一个类接口(interface),它根据模板值专门化具有非常不同的行为: // forwar
我想使用 SelectKBest 选择前 K 个特征并运行 GaussianNB: selection = SelectKBest(mutual_info_classif, k=300) data_t
我想要一个位于页面中央的 div,其中包含一行(两个单词)的 h1 文本,并且该文本与 div 的长度对齐;意思是,字母留出空间(同时保持它们的大小)以占据 div 的整个宽度,并且不要超出 div。
我试图更新我的服务器,所以我通过 ssh 运行以下命令: sudo do-release-upgrade 我收到以下错误: Errors were encountered while processi
我想验证单应矩阵会给出好的结果,而这个 this answer 有答案 - 但是,我不知道如何实现答案。 那么谁能推荐我如何使用 OpenCV 计算 SVD 并验证第一个奇异值与最后一个奇异值的比率是
我最近更新到 cocoapods 0.36 并对内部规范做了一些更改,现在 podspec 不再有效。我用 0.35 验证了此规范的先前版本 (0.3.8),但使用 0.36 失败。很明显 cocoa
我有两个并排设置的 TableView ,我需要它们同时滚动。因此,当您滚动一个时,另一个也会同时滚动。 我进行了一些搜索,但找不到任何信息,但我认为这一定是有可能的。 我的 TableView 都连
我是一名优秀的程序员,十分优秀!