问题实例化bean - 验证错误

时间:2013-10-08 12:15:06

标签: java spring initialization javabeans verifyerror

我有以下问题:我有一个bean(名为ImageStorageService),我想使用以下代码在servlet中实例化该bean

WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(httpSession
            .getServletContext());
IImageStorageService dataService = (IImageStorageService) context
            .getBean("ImageStorageService");

显然bean类实现了IImageStorageService。

问题是当执行这些行时,会抛出以下错误:

java.lang.VerifyError: (class: myproject/myclass/ImageStorageService, method: writePdfFile signature: (Ljava/lang/String;Ljava/lang/String;Lmyproject/myobjects/IObject;)Ljava/io/File;) Call to wrong initialization method

有谁知道哪个是问题?非常感谢

编辑

Bean声明

<bean id="ImageStorageService" scope="session"
    destroy-method="clean"
    class="myproject.myclass.ImageStorageService">
    <property name="objectService" ref="SuperUserObjectService" />
    <property name="dataDictionaryService" ref="DataDictionaryService" />
    <property name="runQueryService" ref="RunQueryService" />
    <property name="status" ref="ImagesUploadStatus" />
</bean>

[...]
package myproject.myclass;
[...]
public class ImageStorageService implements IImageStorageService {
private IRunQueryService    runQueryService;
private IObjectService                              objectService;
private IDataDictionaryService                      dataDictionaryService;
private ImagesUploadStatus                          status;

[...]
public File writePdfFile(String idPlico, String userId) throws Exception {
    return writePdfFile(idPlico, userId, false, 0, 0, 0.0, null);
}

@Override
public File writePdfFile(String idFascicolo, String userId, boolean discardBlankPages, int verticalOffset,
        int horizontalOffset, double threshold, IObject fileInfo) throws Exception {
    File pdfFile;
    [...]
    //pdfFile Elaboration
    [...]
    return pdfFile;
    }
    [...]
}

完整堆栈跟踪

java.lang.VerifyError: (class: myproject/myclass/ImageStorageService, method: writePdfFile signature: (Ljava/lang/String;Ljava/lang/String;Lmyproject/myobjects/IObject;)Ljava/io/File;) Call to wrong initialization method
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.getDeclaredConstructor(Class.java:1985)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:67)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:990)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:943)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:332)
at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43)
at org.springframework.web.context.request.SessionScope.get(SessionScope.java:92)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:328)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:332)
at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:328)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1093)
at myproject.myfilters.myFilter.doFilter(myFilter.java:76)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

1 个答案:

答案 0 :(得分:1)

显然不是长期解决方案,但您可以通过在命令行中添加-noverify来绕过类验证。您可能还想尝试进行干净的构建。