-2

我正在用 eclpise 开发一个 Maven 项目。首先,我制作了一个 DAO 层,然后对其进行了验证——效果很好。但是当我将 jars 添加到我的项目(对于其他层(业务))时,DAO 层无法按预期工作。

添加此 jar 时发生错误:[func_frwmwk_clt,func_frwmwk_cmn,func_frwmwk_srv, func_util, ott_utilities, soi, toplink ]但是如果我删除它,该项目将正常工作并给出真实的结果。我怎样才能解决这个问题?


主类:

package com.services;
import com.entity.Ws_security;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


 import com.services.Interface_ws_security_services;

public class App {




@SuppressWarnings("resource")
public static void main(String[] args) {


ApplicationContext ctx1 = new  ClassPathXmlApplicationContext("spring_hibernate.xml");
                                                                        Interface_ws_security_services service=(Interface_ws_security_services)ctx1.getBean("a");

    //Ws_security ess=new Ws_security();

    System.out.println("Done");
    Ws_security ess =service.findByidws("ess1");
    System.out.println(ess.getLogin());
    System.out.println(ess.getPassword());
    System.out.println(ess.getIPmax());
    System.out.println(ess.getIPmin());
    System.out.println("Done");


}

   }

错误日志:

log4j:WARN No appenders could be found for     logger(org.springframework.core.env.StandardEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
 Exception in thread "main" org.springframework.beans.factory.BeanCreationException:   Error creating bean with name 'disableServiceBoxPageController' defined in URL [jar:file:/C:/Users/sayed/Desktop/DocumentationR3_33276/Client/lib/func_frwmwk_clt.jar!/com/lhs/ccb/cfw/sgu/solutionunits/servicebox/DisableServiceBoxPageController.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.lhs.ccb.cfw.sgu.solutionunits.servicebox.DisableServiceBoxPageController]: Constructor threw exception; nested exception is java.lang.ClassCastException: com.lhs.ccb.func.ect.DefaultDictionary cannot be cast to com.lhs.ccb.cfw.wcs.errorhandling.CFWErrorDictionary
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1007)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:953)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.services.App.main(App.java:19)
  Caused by: org.springframework.beans.BeanInstantiationException: Could not   instantiate bean class [com.lhs.ccb.cfw.sgu.solutionunits.servicebox.DisableServiceBoxPageController]: Constructor threw exception; nested exception is java.lang.ClassCastException: com.lhs.ccb.func.ect.DefaultDictionary cannot be cast to com.lhs.ccb.cfw.wcs.errorhandling.CFWErrorDictionary
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1000)
... 13 more
    Caused by: java.lang.ClassCastException: com.lhs.ccb.func.ect.DefaultDictionary   cannot be cast to com.lhs.ccb.cfw.wcs.errorhandling.CFWErrorDictionary
at com.lhs.ccb.cfw.wcs.solutionunit.AbstractPageController.<init>(Unknown Source)
at com.lhs.ccb.cfwutil.ExtendedAbstractPageController.<init>(Unknown Source)
at com.lhs.ccb.cfw.sgu.solutionunits.servicebox.DisableServiceBoxPageController.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
... 15 more

但我不明白为什么调用这个 jars 并且主类没有这个列表中的任何 jar 工作

4

2 回答 2

1

DisableServiceBoxPageController的构造函数中存在错误。您正在尝试将 aDefaultDictionary转换为 a CFWErrorDictionary,这似乎是不可能的。

如果可能,搜索违规行并将对象转换为正确的类型。


编辑

如果问题与添加 JAR 本身有关,则可能是某个类存在冲突。确保您没有使用同一个 JAR 的多个版本。

于 2013-07-29T18:40:57.510 回答
0

尝试将业务层所需的那些文件放入单独的目录中。

于 2013-07-29T18:37:34.200 回答