访问地址:http://192.168.1.215:7170/analysisCollect/dataCollect.action
出现错误
Unable to instantiate Action, dataCollectAction,  defined for 'dataCollect' in namespace '/'Error creating bean with name 'dataCollectAction' defined in class path resource [com/tuniu/analysis/collect/webwork/webwork-beans.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.tuniu.analysis.collect.webwork.DataCollectAction]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems: 
The type javax.servlet.http.HttpServletRequest cannot be resolved. It is indirectly referenced from required .class files
The type javax.servlet.http.HttpServletResponse cannot be resolved. It is indirectly referenced from required .class files
The method getRequest() from the type BaseAction refers to the missing type HttpServletRequest com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:318)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:399)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:198)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)root causeorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataCollectAction' defined in class path resource [com/tuniu/analysis/collect/webwork/webwork-beans.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.tuniu.analysis.collect.webwork.DataCollectAction]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems: 
The type javax.servlet.http.HttpServletRequest cannot be resolved. It is indirectly referenced from required .class files
The type javax.servlet.http.HttpServletResponse cannot be resolved. It is indirectly referenced from required .class files
The method getRequest() from the type BaseAction refers to the missing type HttpServletRequest org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:898)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:141)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:150)
com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:120)
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:299)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:399)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:198)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)root causeorg.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.tuniu.analysis.collect.webwork.DataCollectAction]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems: 
The type javax.servlet.http.HttpServletRequest cannot be resolved. It is indirectly referenced from required .class files
The type javax.servlet.http.HttpServletResponse cannot be resolved. It is indirectly referenced from required .class files
The method getRequest() from the type BaseAction refers to the missing type HttpServletRequest org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:898)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:141)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:150)
com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:120)
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:299)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:399)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:198)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
访问项目下面html可以,
struts.xml配置如下:
<struts> <constant name="struts.devMode" value="false" />
<!--<constant name="struts.action.extension" value="gif" /> -->
<package name="dataCollect" extends="struts-default">
<action name="dataCollect" class="dataCollectAction">
<result name="test" type="redirect"></result>
</action>
</package>

</struts>    
<bean id="dataCollectAction" class="com.tuniu.analysis.collect.webwork.DataCollectAction"
scope="prototype">
<property name="cacheCollectedInfoSerivce">
<ref bean="cacheCollectedInfoSerivce" />
</property>
</bean>
求大神解救啊!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!java struts

解决方案 »

  1.   

    没看到什么明显的错误,clean一下工程重新编译下试试
      

  2.   

    Unable to instantiate Action, dataCollectAction,  defined for 'dataCollect' in namespace '/'Error creating bean with name 'dataCollectAction' defined in class path resource [com/tuniu/analysis/collect/webwork/webwork-beans.xml]:意思是没法创建这个action。
    你的请求加上你的package name试一下。spring好久没用了。
    http://192.168.1.215:7170/analysisCollect/dataCollect/dataCollect.action
      

  3.   

    <result name="test" type="redirect"></result>
    应该加上你要返回的action名称吧?
      

  4.   

    Unresolved compilation problems:  
    出现这个感觉就有点不妙 是不是需要clean下
      

  5.   

    这个是集成到maven里面的  install的时候没问题可是打成的war包里面的class文件反编译了一下
    public class DataCollectAction extends IPUtil
    {    public DataCollectAction()
        {
            throw new Error("Unresolved compilation problems: \n\tThe type javax.servlet.http.HttpServletRequest cannot be resolved. It is indirectly referenced from required .class files\n\tThe type javax.servlet.http.HttpServletResponse cannot be resolved. It is indirectly referenced from required .class files\n\tThe method getRequest() from the type BaseAction refers to the missing type HttpServletRequest\n");
        }    public String execute()
        {
            throw new Error("Unresolved compilation problem: \n\tThe method getRequest() from the type BaseAction refers to the missing type HttpServletRequest\n");
        }    private boolean checkAction(String sid, String lg)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    private long base64DEncode(String str)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public CacheCollectedInfoSerivce getCacheCollectedInfoSerivce()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setCacheCollectedInfoSerivce(CacheCollectedInfoSerivce cacheCollectedInfoSerivce)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getBv()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setBv(String bv)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getBt()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setBt(String bt)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getHw()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setHw(String hw)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getCo()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setCo(String co)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getClientIp()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setClientIp(String clientIp)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public int getCe()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setCe(int ce)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getFv()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setFv(String fv)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getFu()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setFu(String fu)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public int getJe()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setJe(int je)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getLg()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setLg(String lg)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getLa()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setLa(String la)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getOs()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setOs(String os)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getSc()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setSc(String sc)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getSr()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setSr(String sr)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getTn()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setTn(String tn)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getVu()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setVu(String vu)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getSid()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setSid(String sid)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getPn()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setPn(String pn)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getClt()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setClt(String clt)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public int getEv()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setEv(int ev)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getEi()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setEi(String ei)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public int getPs()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setPs(int ps)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public int getEs()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setEs(int es)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getIn()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setIn(String in)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public String getIe()
        {
            throw new Error("Unresolved compilation problem: \n");
        }    public void setIe(String ie)
        {
            throw new Error("Unresolved compilation problem: \n");
        }    private static Log LOG;
        private static final long serialVersionUID = 0x80a4589ce3eafbf8L;
        private CacheCollectedInfoSerivce cacheCollectedInfoSerivce;
        private String bv;
        private String bt;
        private String hw;
        private String co;
        private String clientIp;
        private int ce;
        private String fv;
        private String fu;
        private int je;
        private String lg;
        private String la;
        private String os;
        private String sc;
        private String sr;
        private String tn;
        private String vu;
        private String sid;
        private String pn;
        private String clt;
        private int ev;
        private String ei;
        private int ps;
        private int es;
        private String in;
        private String ie;
    }已经引入了select-api的包
      

  6.   

    com.tuniu.analysis.collect.webwork.DataCollectAction
    实例化失败。检查一下这几个方面有没有问题:
    1. 是不是这个类没编译好?
    2. 这个类引用的 javax.servlet.http.HttpServletRequest,servlet-api-x.x.jar在你的执行环境里有没有?
    3. 你的系统装了个 jdk,而 eclipse 编译你的项目时,用的是默认版本的,使得 IDE 的 Compiler Compliance level 与 Installed JREs 版本不对应,也可能会导致这种错误。
      

  7.   

     <package name="dataCollect" extends="struts-default">       
            <action name="/dataCollect" class="dataCollectAction">             
              <result name="test" type="redirect">页面路径</result>        
            </action>     
    </package> 新手瞎讲的,不知道对不对
      

  8.   

    找到问题了  
    public HttpServletRequest getRequest()
        {
            return (HttpServletRequest)ActionContext.getContext().get("com.opensymphony.xwork2.dispatcher.HttpServletRequest");
        }
    是没有引入这个包   我是用maven引入的  这个包名叫什么呀? 
      

  9.   

    没看到错误 好久没用struts了