方法<init>()在创建类</init>的对象时找不到V.

时间:2013-05-30 10:24:41

标签: java spring tomcat

我有一个类NotifyBuilderUtil,我正在尝试创建另一个类CustomEmailNotification的对象。但是,在创建对象时,我收到错误:

java.lang.NoSuchMethodError: net.mail.CustomEmailNotification: method <init>()V not found
package org.module.definition.notify;
...
import net.mail.CustomEmailNotification;
...
public class NotifyBuilderUtil implements InitializingBean {
  private static NotifyBuilderUtil instance;
  public NotifyBuilderUtil() {
  if(instance != null) throw new SingletonViolationException(NotifyBuilderUtil.class);
  instance = this;
  }
...
...
public static void buildElements(DefinableEntity entity, Element item, Notify notifyDef,     Writer writer, NotifyVisitor.WriterType writerType, Map params, boolean processItem) {
...
  String flagElementPath = "./notify";
  Element flagElem = (Element) nextItem.selectSingleNode(flagElementPath);
  Map oArgs = DefinitionUtils.getOptionalArgs(flagElem);
  NotifyVisitor visitor = new NotifyVisitor(entity, notifyDef, customItem, writer, writerType, params);
  CustomEmailNotification cen = new CustomEmailNotification();
  cen.constructInternalWriter(entity, visitor, flagElem, oArgs);
  ...
  }
}

CustomEmailNotification:

public class CustomEmailNotification {
  private static Map timeFieldMap = null;
  public static Writer internalWriter = null;
  public static Writer externalWriter = null;
  Writer writer;
  public CustomEmailNotification() {
  timeFieldMap = new HashMap();
  }
  ...
  public static void constructInternalWriter(DefinableEntity entity, NotifyVisitor visitor, Element flagElement, Map oArgs) {
  ...

  ...
  }
}

错误消息是:

ERROR [http-8086-1] [org.kablink.teaming.spring.web.portlet.DispatcherPortlet] - Could not complete request
javax.portlet.PortletException: Error occured during request processing: net.mail.CustomEmailNotification: method <init>()V not found
at org.springframework.web.portlet.DispatcherPortlet.doActionService(DispatcherPortlet.java:662)
at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:519)
at org.springframework.web.portlet.FrameworkPortlet.processAction(FrameworkPortlet.java:460)
at org.kablink.teaming.portletadapter.servlet.PortletAdapterController.handleRequestInternal(PortletAdapterController.java:105)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at org.kablink.teaming.portletadapter.servlet.PortletAdapterServlet.service(PortletAdapterServlet.java:74)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.kablink.teaming.web.servlet.filter.LoginFilter.doFilter(LoginFilter.java:155)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.kablink.teaming.web.servlet.filter.DefaultCharacterEncodingFilter.doFilter(DefaultCharacterEncodingFilter.java:60)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
at org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
at org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.SessionFixationProtectionFilter.doFilterHttp(SessionFixationProtectionFilter.java:67)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.providers.anonymous.AnonymousProcessingFilter.doFilterHttp(AnonymousProcessingFilter.java:105)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter.doFilterHttp(SecurityContextHolderAwareRequestFilter.java:91)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:278)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.basicauth.BasicProcessingFilter.doFilterHttp(BasicProcessingFilter.java:174)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.kablink.teaming.spring.security.LogoutFilter.doFilterHttp(LogoutFilter.java:73)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.kablink.teaming.asmodule.servlet.filter.ResponseHeaderFilter.doFilter(ResponseHeaderFilter.java:127)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.kablink.teaming.tomcat.valve.ZoneContextValve.invoke(ZoneContextValve.java:69)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:647)
at org.apache.catalina.valves.RequestFilterValve.process(RequestFilterValve.java:316)
at org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.java:81)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:722)


Caused by: java.lang.NoSuchMethodError: net.mail.CustomEmailNotification: method <init>()V not found
at org.kablink.teaming.module.definition.notify.NotifyBuilderUtil.buildElements(NotifyBuilderUtil.java:203)
at org.kablink.teaming.module.definition.notify.NotifyBuilderUtil.buildElements(NotifyBuilderUtil.java:175)
at org.kablink.teaming.module.mail.impl.DefaultEmailFormatter.buildMessage(DefaultEmailFormatter.java:821)
at org.kablink.teaming.module.mail.MimeNotifyPreparator.prepare(MimeNotifyPreparator.java:334)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:352)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:344)
at org.kablink.teaming.module.mail.impl.MailModuleImpl.sendMail(MailModuleImpl.java:1139)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.kablink.teaming.module.interceptor.EventListenerManagerInterceptor.invoke(EventListenerManagerInterceptor.java:64)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.kablink.teaming.util.aopalliance.InvocationStatisticsInterceptor.invoke(InvocationStatisticsInterceptor.java:49)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy13.sendMail(Unknown Source)
at org.kablink.teaming.module.admin.impl.AbstractAdminModule.sendMail(AbstractAdminModule.java:1174)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.kablink.teaming.search.interceptor.IndexSynchronizationManagerInterceptor.invoke(IndexSynchronizationManagerInterceptor.java:67)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.kablink.teaming.module.interceptor.EventListenerManagerInterceptor.invoke(EventListenerManagerInterceptor.java:64)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.kablink.teaming.util.aopalliance.InvocationStatisticsInterceptor.invoke(InvocationStatisticsInterceptor.java:49)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy16.sendMail(Unknown Source)
at org.kablink.teaming.web.util.BinderHelper.sendMailOnEntryCreate(BinderHelper.java:3171)
at org.kablink.teaming.portlet.forum.ModifyEntryController.handleActionRequestAfterValidation(ModifyEntryController.java:202)
at org.kablink.teaming.web.portlet.SAbstractController.handleActionRequestInternal(SAbstractController.java:257)
at org.springframework.web.portlet.mvc.AbstractController.handleActionRequest(AbstractController.java:199)
at org.springframework.web.portlet.mvc.SimpleControllerHandlerAdapter.handleAction(SimpleControllerHandlerAdapter.java:64)
at org.springframework.web.portlet.DispatcherPortlet.doActionService(DispatcherPortlet.java:641)
... 70 more

我无法找到发生这种情况的原因。任何人都可以帮我指出我哪里错了吗?
我正在使用Apache Tomcat / 6.0.35
JVM版本:1.7.0_21-b11

2 个答案:

答案 0 :(得分:0)

(在评论中回答。转换为社区wiki答案。见Question with no answers, but issue solved in the comments (or extended in chat)

OP写道:

  

现在问题已解决。该错误是由于SVN分支造成的。在单独的分支中,EmailHelper.java所在的同一文件夹中有另一个java类CustomEmailNotification.java。所以当我从那个分支切换到我当前的分支时,我没有检查那个分支,因为我不需要EmailHelper.java,因此错误。刚刚创建了一个仅包含CustomEmailNotification.java的单独文件夹,错误消失了。感谢所有人花时间研究这个

答案 1 :(得分:0)

哦..这有点像一个糟糕的会话,这是我的事,解决方案是创建一个新的类并使用不同的名称,然后将所有代码从“错误的类文件”复制到一个新的类中,然后更改所有导入路径到新的...,或者您可以重命名该类。重命名并转到新班都对我有用