我有两个不同的网络应用程序,每个装置同一类别A,有不同的班轮。 当我对本届会议作一番发言,然后从其他网站浏览时,有人投掷了
例如,在网上申请A中,Istor a
,然后在网上申请B中,我从本届会议获得<代码>a,并将其投到A,ClassCastException
。
是否有办法解决这一问题?
我有两个不同的网络应用程序,每个装置同一类别A,有不同的班轮。 当我对本届会议作一番发言,然后从其他网站浏览时,有人投掷了
例如,在网上申请A中,Istor a
,然后在网上申请B中,我从本届会议获得<代码>a,并将其投到A,ClassCastException
。
是否有办法解决这一问题?
是否有办法解决这一问题?
基本上没有。
就联合后勤系统而言,这些类型是不同的,因此,联合后勤系统不允许你以其他方式行事。 例如,could各年级有不同的代码和不同的物体布局。 如果你将联合选举机制trick成对同类类型的处理,那么你就能够冲破联合选举机制。 这种做法是不健康的。
解决办法是,确保你没有两台不同班级的装载机。 就Tomcat而言,这意味着,如果两个或两个以上的网络应用程序需要分享一个类别,那么这一类别必须用一个对两个类别都很常见的班轮来界定;例如,将JAR文档列入$CATALINA_HOME/lib
或>$CATALINA_HOME/common
。
如果存在技术原因,“ ”改为“ ”,由不同班轮装载(可能是因为这些班级确实不同),那么,你可以围绕这一问题开展工作,确定两个班级的接口,然后向接口而不是执行班级进行方案规划。 当然,接口需要由共用舱载体装载......或者你再次遇到同样的问题。
You should avoid this situation, basically - either put both bits of functionality in the same webapp, or move the library containing class A into an appropriate location such that only one classloader will be used. Two classes loaded by different classloaders are entirely distinct in the JVM - you simply won t be able to cast between them.
见。 Tomcat同级载荷文件,以便更详细地了解使用的各类载荷。 它希望你将这一共同的阶级带进共同的班轮。 如文件所示,这很不寻常,但如果你really想要在两个网络申请之间(即 也称不寻常)分享一个标语,则可能最容易取得进展。
你们能够这样做。 由不同班轮载荷装载的两门班不同。
也许你可以把共有物体序列化?
我不一定提倡这种做法,但后来又一次说,序列化基本上是做的——你从某些证书或低年级(X)上编印,并将它装入(代谢)另一个证书/ClassLoader。
即便这些班级有相同的组合名称和签名,你也可以从不同班子中选取两个物体,但你只能使用一个pache bean utils图书馆,BeanUtils.copyProperties(o1, o2);
。
This is possible with a workaround.
确实,你可以从A类舱载重到A类同级载荷B类(如果用同一名称的舱位在不同的舱载荷下载荷,如
例如,在Jetty,使用WebAppContext.addSystemClass()
,描述为。
Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...
Check this, List<String> list = new ArrayList<String>(); for (int i = 0; i < 10000; i++) { String value = (""+UUID.randomUUID().getLeastSignificantBits()).substring(3, ...
I am in the middle of solving a problem where I think it s best suited for a decorator and a state pattern. The high level setting is something like a sandwich maker and dispenser, where I have a set ...
I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I ...
I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...
If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...
I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....
I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...