3

我有以下问题:我有一个 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 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)
4

1 回答 1

1

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

于 2013-10-24T14:25:08.573 回答