我有耳朵和战争分开部署。在两个包中,我都将(EJB)接口作为jar附加。 JNDI正在查找端点,但我在方法调用期间遇到了类转换异常。是因为EJB返回的ObjectA附加到jar中的ear和war? ObjectA被认为是一个不同的类,因为正在被两个不同的类加载器读取?服务器是tomee,ear是部署在app(在tomee.xml)文件夹中还是在webapps中进行战争?我应该从两个包中删除带有(ObjectA)的jar并将它放在tomee的lib文件夹中 - 这是唯一的选择吗? 此致,Dawid。
stacktrace
07-Nov-2017 07:43:17.754 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class org.oscm.ui.common.LoggerInitListener
java.lang.ClassCastException: org.oscm.internal.vo.VOConfigurationSetting cannot be cast to org.oscm.internal.vo.VOConfigurationSetting
at com.sun.proxy.$Proxy232.getVOConfigurationSetting(Unknown Source)
at org.oscm.ui.common.LoggerInitListener.contextInitialized(LoggerInitListener.java:42)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5189)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:952)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1823)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
电话:
public class LoggerInitListener implements ServletContextListener {
...
@Override
public void contextDestroyed(ServletContextEvent sce) {
...
}
@Override
public void contextInitialized(ServletContextEvent sce) {
ConfigurationService service = getConfigurationService();
filePath = service.getVOConfigurationSetting(
ConfigurationKey.LOG_FILE_PATH, Configuration.GLOBAL_CONTEXT)
.getValue();
...
}
ConfigurationService getConfigurationService() {
return new ServiceLocator().findService(ConfigurationService.class);
}
后端:
@Singleton
@Startup
@Local(ConfigurationServiceLocal.class)
@Remote(ConfigurationService.class)
@Interceptors({ ExceptionMapper.class })
@ConcurrencyManagement(ConcurrencyManagementType.CONTAINER)
@Lock(LockType.READ)
public class ConfigurationServiceBean
implements ConfigurationService, ConfigurationServiceLocal {
...
@Override
public VOConfigurationSetting getVOConfigurationSetting(
ConfigurationKey informationId, String contextId) {
ConfigurationSetting setting = getConfigurationSetting(informationId,
contextId);
return ConfigurationSettingAssembler.toValueObject(setting);
}
...
}
接口:
@Remote
public interface ConfigurationService {
VOConfigurationSetting getVOConfigurationSetting(ConfigurationKey var1, String var2);
void setConfigurationSetting(String var1, String var2);
boolean isServiceProvider();
boolean isPaymentInfoAvailable();
}