1

我正在使用 Struts 2 类型转换将字符串转换为日期,反之亦然。

我创建了一个转换器

package gov.nrhm.fmis.infra;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.sql.Date;
import java.util.Map;  

import org.apache.struts2.util.StrutsTypeConverter;

import com.opensymphony.xwork2.conversion.TypeConversionException;

public class DateConverter extends StrutsTypeConverter {

    @Override
    public Object convertFromString(Map arg0, String[] arg1, Class arg2) {
        // TODO Auto-generated method stub    

        System.out.println("DateConverter converting string to date...");

        String dateStrInput = arg1[0];

        SimpleDateFormat formatter = new SimpleDateFormat("dd/mm/yyyy"); 

        try {
          java.util.Date parsedDate = formatter.parse(dateStrInput); 

          return new Date(parsedDate.getTime());    
        }
        catch(ParseException e) { 
          e.printStackTrace(); 
          throw new TypeConversionException("Invalid format...");  
        }

    }

    @Override
    public String convertToString(Map arg0, Object arg1) {
        // TODO Auto-generated method stub       

        System.out.println("DateConverter converting date to string...");

        Date date = (Date)arg1;       

        SimpleDateFormat formatter = new SimpleDateFormat("dd/mm/yyyy"); 

        String dateStrOutput = formatter.format(date);

        return dateStrOutput;     
    }

}

我的操作包含一个必须由 Struts 2 转换的 bean infraBean。下面给出了 Bean:package gov.nrhm.fmis.pojo;

import gov.nrhm.fmis.common.util.MISConstants;
import gov.nrhm.fmis.common.util.WorkflowStatus;

import java.io.Serializable;
import java.sql.Date;                             
import java.sql.Types;    

import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;  
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

@Entity
@Table(name = "tt_infra_maintenance", schema = MISConstants.MIS_DB_SCHEMA_NAME) 
public class InfraMaintenanceBean implements Serializable {   


    @Id         
    @GeneratedValue(generator = "seq_tt_infra_id", strategy = GenerationType.AUTO)
    @SequenceGenerator(name = "seq_tt_infra_id", sequenceName = "nrhm_fmis.seq_infra_id")
    private Long infraId;     

    @Column(name="order_num")
    private String orderNum;  

    @Column(name="receipt_amount") 
    private Double receiptAmount;   

    @Column(name="receipt_date") 
    private Date receiptDate;

    @Column(name="exp_amount")
    private Double expAmount;


    private Date expDate;

    @Column(name="certificate_amount")
    private Double certAmount;  


    @ManyToOne(targetEntity = AgencyBean.class, fetch = FetchType.LAZY)
    @JoinColumn(name = "agency_id", insertable = true, updatable = false) 
    private AgencyBean agency; 

    @ManyToOne(targetEntity = QuarterBean.class, fetch = FetchType.LAZY)
    @JoinColumn(name = "quarter", insertable = true, updatable = false)
    private QuarterBean quarter;  

    @ManyToOne(targetEntity = FinancialYearBean.class, fetch = FetchType.LAZY)
    @JoinColumn(name = "fin_year_id", insertable = true, updatable = false)
    private FinancialYearBean finYear;             


    @Type(type = "org.hibernate.type.EnumType", parameters = {
            @Parameter(name = "enumClass", value = "gov.nrhm.fmis.common.util.WorkflowStatus"),
            @Parameter(name = "type", value = "" + Types.VARCHAR) })
    private WorkflowStatus workflowStatus = WorkflowStatus.MKR_WIP;  


    @Embedded    
    private Remarks remarks; 


    //I have not entered the getter and setter  
}

现在我创建了 xwork-conversion.properties 文件。内容如下: java.sql.Date=gov.nrhm.fmis.infra.DateConverter

现在,当我启动 tomcat 时,它给出了 ClassNotFoundException,即 Struts 2 无法找到 DateConverter。我已经检查了 10 次正确的路径,没有问题。

StackTrace 信息如下:

[2012-04-09 14:14:26,023] main INFO  config.BeanSelectionProvider - Choosing bean (struts) for interface com.opensymphony.xwork2.ActionProxyFactory
[2012-04-09 14:14:26,023] main INFO  config.BeanSelectionProvider - Choosing bean (struts) for interface com.opensymphony.xwork2.conversion.ObjectTypeDeterminer
[2012-04-09 14:14:26,023] main INFO  config.BeanSelectionProvider - Choosing bean (struts) for interface org.apache.struts2.dispatcher.mapper.ActionMapper
[2012-04-09 14:14:26,023] main INFO  config.BeanSelectionProvider - Choosing bean (jakarta) for interface org.apache.struts2.dispatcher.multipart.MultiPartRequest
[2012-04-09 14:14:26,023] main INFO  config.BeanSelectionProvider - Choosing bean (struts) for class org.apache.struts2.views.freemarker.FreemarkerManager
[2012-04-09 14:14:26,023] main DEBUG config.BeanSelectionProvider - Choosing bean (struts) for class org.apache.struts2.views.velocity.VelocityManager to be loaded from the ObjectFactory
[2012-04-09 14:14:26,023] main INFO  config.BeanSelectionProvider - Choosing bean (struts) for interface org.apache.struts2.components.UrlRenderer
[2012-04-09 14:14:26,023] main INFO  config.BeanSelectionProvider - Choosing bean (struts) for interface com.opensymphony.xwork2.validator.ActionValidatorManager
[2012-04-09 14:14:26,023] main INFO  config.BeanSelectionProvider - Choosing bean (struts) for interface com.opensymphony.xwork2.util.ValueStackFactory
[2012-04-09 14:14:26,023] main INFO  config.BeanSelectionProvider - Choosing bean (struts) for interface com.opensymphony.xwork2.util.reflection.ReflectionProvider
[2012-04-09 14:14:26,023] main INFO  config.BeanSelectionProvider - Choosing bean (struts) for interface com.opensymphony.xwork2.util.reflection.ReflectionContextFactory
[2012-04-09 14:14:26,023] main INFO  config.BeanSelectionProvider - Choosing bean (struts) for interface com.opensymphony.xwork2.util.PatternMatcher
[2012-04-09 14:14:26,023] main INFO  config.BeanSelectionProvider - Choosing bean (struts) for interface org.apache.struts2.dispatcher.StaticContentLoader
[2012-04-09 14:14:26,023] main INFO  config.BeanSelectionProvider - Choosing bean (struts) for interface com.opensymphony.xwork2.UnknownHandlerManager
[2012-04-09 14:14:26,023] main DEBUG util.LocalizedTextUtil - Added default resource bundle 'org/apache/struts2/struts-messages' to default resource bundles = [org/apache/struts2/struts-messages, com/opensymphony/xwork2/xwork-messages]
[2012-04-09 14:14:26,023] main INFO  config.BeanSelectionProvider - Loading global messages from messages
[2012-04-09 14:14:26,033] main DEBUG util.LocalizedTextUtil - Added default resource bundle 'messages' to default resource bundles = [messages, org/apache/struts2/struts-messages, com/opensymphony/xwork2/xwork-messages]
[2012-04-09 14:14:26,053] main DEBUG impl.XWorkConverter - processing conversion file [xwork-conversion.properties]
[2012-04-09 14:14:26,053] main ERROR impl.XWorkConverter - Conversion registration error
java.lang.ClassNotFoundException: gov.nrhm.fmis.infra.DateConverter                                      
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:363)
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:325)
    at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:146)
    at com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:96)
    at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:149)
    at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:139)
    at com.opensymphony.xwork2.conversion.impl.XWorkConverter.createTypeConverter(XWorkConverter.java:738)
    at com.opensymphony.xwork2.conversion.impl.XWorkConverter.loadConversionProperties(XWorkConverter.java:771)
    at com.opensymphony.xwork2.conversion.impl.XWorkConverter.loadConversionProperties(XWorkConverter.java:751)
    at com.opensymphony.xwork2.conversion.impl.XWorkConverter.setObjectFactory(XWorkConverter.java:184)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:293)
    at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:431)
    at com.opensymphony.xwork2.inject.ContainerBuilder$5.create(ContainerBuilder.java:207)
    at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51)
    at com.opensymphony.xwork2.inject.ContainerImpl$ParameterInjector.inject(ContainerImpl.java:462)
    at com.opensymphony.xwork2.inject.ContainerImpl.getParameters(ContainerImpl.java:477)
    at com.opensymphony.xwork2.inject.ContainerImpl.access$000(ContainerImpl.java:34)
    at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:293)
    at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:431)
    at com.opensymphony.xwork2.inject.ContainerBuilder$5.create(ContainerBuilder.java:207)
    at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51)
    at com.opensymphony.xwork2.inject.ContainerImpl$ParameterInjector.inject(ContainerImpl.java:462)
    at com.opensymphony.xwork2.inject.ContainerImpl.getParameters(ContainerImpl.java:477)
    at com.opensymphony.xwork2.inject.ContainerImpl.access$000(ContainerImpl.java:34)
    at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:293)
    at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:431)
    at com.opensymphony.xwork2.inject.ContainerBuilder$5.create(ContainerBuilder.java:207)
    at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51)
    at com.opensymphony.xwork2.inject.ContainerImpl$ParameterInjector.inject(ContainerImpl.java:462)
    at com.opensymphony.xwork2.inject.ContainerImpl.getParameters(ContainerImpl.java:477)
    at com.opensymphony.xwork2.inject.ContainerImpl.access$000(ContainerImpl.java:34)
    at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:293)
    at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:431)
    at com.opensymphony.xwork2.inject.ContainerBuilder$5.create(ContainerBuilder.java:207)
    at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51)
    at com.opensymphony.xwork2.inject.ContainerBuilder$3.create(ContainerBuilder.java:93)
    at com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuilder.java:487)
    at com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuilder.java:484)
    at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:574)
    at com.opensymphony.xwork2.inject.ContainerBuilder.create(ContainerBuilder.java:484)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.createBootstrapContainer(DefaultConfiguration.java:241)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:182)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:374)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:418)
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
    at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:99)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:570)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:139)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1191)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:481)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:434)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:147)
    at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:120)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:147)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
    at org.mortbay.jetty.Server.doStart(Server.java:210)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
    at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:134)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:332)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:277)
    at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:195)
    at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:183)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
[2012-04-09 14:14:26,093] main INFO  spring.StrutsSpringObjectFactory - Initializing Struts-Spring integration...
[2012-04-09 14:14:26,093] main INFO  spring.SpringObjectFactory - Setting autowire strategy to name
[2012-04-09 14:14:26,093] main INFO  spring.StrutsSpringObjectFactory - ... initialized Struts-Spring integration successfully
[2012-04-09 14:14:26,093] main DEBUG impl.XWorkConverter - processing conversion file [xwork-conversion.properties]
[2012-04-09 14:14:26,093] main ERROR impl.XWorkConverter - Conversion registration error
java.lang.ClassNotFoundException: gov.nrhm.fmis.infra.DateConverter                                      
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:363)
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:325)
    at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:146)
    at com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:96)
    at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:212)
    at com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:132)
    at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:139)
    at com.opensymphony.xwork2.conversion.impl.XWorkConverter.createTypeConverter(XWorkConverter.java:738)
    at com.opensymphony.xwork2.conversion.impl.XWorkConverter.loadConversionProperties(XWorkConverter.java:771)
    at com.opensymphony.xwork2.conversion.impl.XWorkConverter.loadConversionProperties(XWorkConverter.java:751)
    at com.opensymphony.xwork2.conversion.impl.XWorkConverter.setObjectFactory(XWorkConverter.java:184)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:293)
    at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:431)
    at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:492)
    at com.opensymphony.xwork2.inject.ContainerImpl$7.call(ContainerImpl.java:532)
    at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:581)
    at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:530)
    at com.opensymphony.xwork2.config.impl.LocatableFactory.create(LocatableFactory.java:32)
    at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:130)
    at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51)
    at com.opensymphony.xwork2.inject.ContainerImpl$ParameterInjector.inject(ContainerImpl.java:462)
    at com.opensymphony.xwork2.inject.ContainerImpl.getParameters(ContainerImpl.java:477)
    at com.opensymphony.xwork2.inject.ContainerImpl.access$000(ContainerImpl.java:34)
    at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:293)
    at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:431)
    at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:492)
    at com.opensymphony.xwork2.inject.ContainerImpl$7.call(ContainerImpl.java:532)
    at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:581)
    at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:530)
    at com.opensymphony.xwork2.config.impl.LocatableFactory.create(LocatableFactory.java:32)
    at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:130)
    at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51)
    at com.opensymphony.xwork2.inject.ContainerImpl$ParameterInjector.inject(ContainerImpl.java:462)
    at com.opensymphony.xwork2.inject.ContainerImpl.getParameters(ContainerImpl.java:477)
    at com.opensymphony.xwork2.inject.ContainerImpl.access$000(ContainerImpl.java:34)
    at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:293)
    at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:431)
    at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:492)
    at com.opensymphony.xwork2.inject.ContainerImpl$7.call(ContainerImpl.java:532)
    at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:581)
    at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:530)
    at com.opensymphony.xwork2.config.impl.LocatableFactory.create(LocatableFactory.java:32)
    at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:130)
    at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51)
    at com.opensymphony.xwork2.inject.ContainerImpl$ParameterInjector.inject(ContainerImpl.java:462)
    at com.opensymphony.xwork2.inject.ContainerImpl.getParameters(ContainerImpl.java:477)
    at com.opensymphony.xwork2.inject.ContainerImpl.access$000(ContainerImpl.java:34)
    at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:293)
    at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:431)
    at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:492)
    at com.opensymphony.xwork2.inject.ContainerImpl$7.call(ContainerImpl.java:532)
    at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:581)
    at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:530)
    at com.opensymphony.xwork2.config.impl.LocatableFactory.create(LocatableFactory.java:32)
    at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:130)
    at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51)
    at com.opensymphony.xwork2.inject.ContainerImpl.getInstance(ContainerImpl.java:507)
    at com.opensymphony.xwork2.inject.ContainerImpl.getInstance(ContainerImpl.java:517)
    at com.opensymphony.xwork2.inject.ContainerImpl$9.call(ContainerImpl.java:548)
    at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:574)
    at com.opensymphony.xwork2.inject.ContainerImpl.getInstance(ContainerImpl.java:546)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:186)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:374)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:418)
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
    at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:99)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:570)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:139)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1191)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:481)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:434)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:147)
    at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:120)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:147)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
    at org.mortbay.jetty.Server.doStart(Server.java:210)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
    at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:134)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:332)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:277)
    at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:195)
    at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:183)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
[2012-04-09 14:14:26,103] main DEBUG providers.XmlConfigurationProvider - Loaded [BUILDER] {PackageConfig Name:struts-default namespace: parents:[]}
[2012-04-09 14:14:26,223] main DEBUG validator.DefaultValidatorFactory - Loading validator definitions.
[2012-04-09 14:14:26,373] main DEBUG interceptor.I18nInterceptor - new I18nInterceptor()
[2012-04-09 14:14:26,383] main DEBUG interceptor.I18nInterceptor - new I18nInterceptor()
[2012-04-09 14:14:26,393] main DEBUG interceptor.I18nInterceptor - new I18nInterceptor()
[2012-04-09 14:14:26,413] main DEBUG providers.XmlConfigurationProvider - Loaded [BUILDER] {PackageConfig Name:convention-default namespace: parents:[{PackageConfig Name:struts-default namespace: parents:[]}]}
[2012-04-09 14:14:26,413] main DEBUG providers.XmlConfigurationProvider - Loaded [BUILDER] {PackageConfig Name:spring-default namespace: parents:[]}
[2012-04-09 14:14:26,413] main DEBUG providers.XmlConfigurationProvider - Loaded [BUILDER] {PackageConfig Name:tiles-default namespace: parents:[{PackageConfig Name:struts-default namespace: parents:[]}]}

如果有人能解决这个问题,我将不胜感激,因为我必须赶上最后期限。

(而且由于某些限制,我也不能使用注释)

4

1 回答 1

2

在 xwork-conversion.properties 文件中查找尾随空格。

我遇到了同样的问题ClassNotFoundException。我需要做的就是消除尾随空格。所以请检查您是否可能无意中写了:

'java.sql.Date=gov.nrhm.fmis.infra.DateConverter '

不敢相信它会有所作为,但确实如此!:-)

于 2012-07-14T18:35:53.043 回答