Oi pessoal!
Fiz o backup do meu projeto, formatei a máquina, reinstalei td, Eclipse Helios e Tomcat 7, fui restaurar o projeto pra workspace e tenho este erro na classe News:
Apaguei os imports, importei td de novo e não sai disso. Cliquei em “fix project” e não vi nada pra corrigir, alguém dá um help?
Abraço!!
Recortei o projeto da workspace e colei de novo, o erro acima sumiu, mas agora recebo o erro na stacktrace:
23:43:53,157 INFO [ThreadPoolTaskScheduler] Shutting down ExecutorService
26/10/2010 23:43:53 org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter vraptor
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myFirstApplicationTask' defined in file [/home/bruno/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Imobiliaria/WEB-INF/classes/br/com/imobiliaria/component/MyFirstApplicationTask.class]: Unsatisfied dependency expressed through constructor argument with index 1 of type [br.com.imobiliaria.tasks.News]: : Error creating bean with name 'news' defined in file [/home/bruno/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Imobiliaria/WEB-INF/classes/br/com/imobiliaria/tasks/News.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [br.com.imobiliaria.component.ParameterLoader]: : Error creating bean with name 'parameterLoader': Scope 'request' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'parameterLoader': Scope 'request' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'news' defined in file [/home/bruno/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Imobiliaria/WEB-INF/classes/br/com/imobiliaria/tasks/News.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [br.com.imobiliaria.component.ParameterLoader]: : Error creating bean with name 'parameterLoader': Scope 'request' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'parameterLoader': Scope 'request' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'news' defined in file [/home/bruno/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Imobiliaria/WEB-INF/classes/br/com/imobiliaria/tasks/News.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [br.com.imobiliaria.component.ParameterLoader]: : Error creating bean with name 'parameterLoader': Scope 'request' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'parameterLoader': Scope 'request' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:718)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:194)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:993)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:897)
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.doGetBean(AbstractBeanFactory.java:310)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:838)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:780)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:697)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:784)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:711)
... 40 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'parameterLoader': Scope 'request' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:339)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:838)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:780)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:697)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:784)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:711)
... 52 more
Caused by: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
at org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:123)
at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:40)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:325)
... 58 more
26/10/2010 23:43:53 org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
26/10/2010 23:43:53 org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/imobiliaria] startup failed due to previous errors
26/10/2010 23:43:53 org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Está dando erro na sequinte situação:
Tenho a classe MyFirstApplicationTask:
@Component
@ApplicationScoped
public class MyFirstApplicationTask implements ApplicationTask {
private News news;
public MyFirstApplicationTask(TaskScheduler scheduler, News news) {
this.schedule(scheduler);
this.news = news;
}
public void schedule(TaskScheduler scheduler) {
//scheduler.schedule(this, new CronTrigger("0 0/2 * * * ?"));
scheduler.schedule(this, new CronTrigger("0 15 10 ? * *"));
}
public void run(){
news.enviar();
}
}
Tenho a classe News:
@Component
@PrototypeScoped
public class News {
private Imagens imagens;
private ParameterLoader parameterLoader;
public News(ParameterLoader parameterLoader,Imagens imagens ) {
this.imagens = imagens;
this.parameterLoader = parameterLoader;
}
// codigo aqui
}
E tenho a classe ParameterLoader, que carrega uma classe PropertiesLoader, que faz a leitura de um arquivo param.properties, fiz isso para poder alterar parâmetros em arquivo de texto e não direto na classe, como a conta de email, senha e smtp para enviar o email, dica bastante útil do nosso colega Bronx.
[code]@Component
public class ParameterLoader {
private final String PROPERTIES_NAME = "param.properties";
private PropertiesLoader propertiesLoader;
public ParameterLoader(ServletContext servletContext) {
try {
this.propertiesLoader = new PropertiesLoader(new FileInputStream(new File(servletContext.getRealPath("/WEB-INF/properties/" + this.PROPERTIES_NAME))));
} catch (Exception exception) {
throw new RuntimeException(exception);
}
}
public String getParameter(String parameterName) {
return this.propertiesLoader.getValue(parameterName);
}
}
[/code]
Aí já não sei se está faltando alguma anotação em alguém ou se está sobrando, tentei adicionar @PrototypeScoped na ParameterLoader, mas não deu certo.
[]s
Descobri o que era, a classe News é @Component, e Imagens tb é, injetando Imagens no construtor da News estava dando zica, isto causava a exception no MyFirstAplicationTask.