Importar Projeto FJ21

10 respostas
denisspitfire

Pessoal, estou tentando importar meu projeto, estou no capitulo 12. Na caelum funcionava hehe, quando eu importei pra ca deu pau em quase todas as classes. Dai eu alterei a JRE e… quase foi. Alterei o Banco de dados, testei a conexao e ele se conecta a um banco que eu tenho hospedado.
Blz…
São 12 problemas, a lista-contatos-scriplet.jsp é o primeiro.

<%@ page import ="java.util.*,br.com.caelum.agenda.dao.*,br.com.caelum.agenda.modelo.*" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<table>
	<%ContatoDAO dao = new ContatoDAO();
List<Contato> contatos = dao.getLista();
for(Contato contato : contatos){
%>
	<tr>
		<td><%=contato.getNome()%></td>
		<td><%=contato.getEmail()%></td>
		<td><%=contato.getEndereco()%></td>
		<td><%=contato.getDataNascimento().getTime()%></td>
		
	</tr>
	<%} %>
</table>
</body>
</html>

Linha 1, 13, 17-20.
why?? :frowning:

10 Respostas

mario.fts

Oi Denis

Pra um projeto web, vc tem q ter os seguintes items no buildpath (botão direito no projeto => BuildPath => configure BuildPath, depois clique em Libraries)

JRE System Library - Compilador, tem q apontar pro java instalado no micro
Web App Libraries - Bibliotecas que estão no seu diretório WEB-INF/lib
Server Runtime (Apache Tomcat) - Bibliotecas do servidor, servlet e jsp.

Se algum desses items não estiver presente, é só adicionar, ou se estiver escrito Unbound em algum deles, é clicar duas vezes a apontar pro diretório correto.

QQ problema posta ai.

[]'s

denisspitfire

Cara ainda nao reconheceu.
Configurei essas 3 partes. o server runtime mudei para o tomcat 7 que estava usando o 6.
jre eu mudei pro 7 também pois é a que esta instalanda e a webapp escolhi a app do projeto que esta criada. porém resolveu alguns e outros nao. tem mais alguma coisa?

mario.fts

O que que está aparecendo na aba de problemas?

manda um print

denisspitfire

Estes são os erros


mario.fts

não está achando as bibliotecas do tomcat. remove o server runtime e adiciona novamente.

denisspitfire

Console

Mar 29, 2012 5:02:39 PM org.apache.catalina.core.AprLifecycleListener init

Informações: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files (x86)/Java/jre6/bin/client;C:/Program Files (x86)/Java/jre6/bin;C:/Program Files (x86)/Java/jre6/lib/i386;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;c:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Windows Live\Shared;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn;c:\Program Files\Microsoft SQL Server\100\Tools\Binn;c:\Program Files\Microsoft SQL Server\100\DTS\Binn;C:\Program Files (x86)\IDM Computer Solutions\UltraEdit;C:\Users\willian\Desktop\eclipse;;.

Mar 29, 2012 5:02:39 PM org.apache.tomcat.util.digester.SetPropertiesRule begin

Advertência: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property source to org.eclipse.jst.jee.server:fj21-tarefas did not find a matching property.

Mar 29, 2012 5:02:40 PM org.apache.coyote.AbstractProtocolHandler init

Informações: Initializing ProtocolHandler [http-bio-8080]

Mar 29, 2012 5:02:40 PM org.apache.coyote.AbstractProtocolHandler init

Informações: Initializing ProtocolHandler [ajp-bio-8009]

Mar 29, 2012 5:02:40 PM org.apache.catalina.startup.Catalina load

Informações: Initialization processed in 2213 ms

Mar 29, 2012 5:02:40 PM org.apache.catalina.core.StandardService startInternal

Informações: Starting service Catalina

Mar 29, 2012 5:02:40 PM org.apache.catalina.core.StandardEngine startInternal

Informações: Starting Servlet Engine: Apache Tomcat/7.0.12

Mar 29, 2012 5:02:43 PM org.apache.catalina.core.ApplicationContext log

Informações: Initializing Spring FrameworkServlet springmvc

17:02:43,356  INFO DispatcherServlet:320 - FrameworkServlet springmvc: initialization started

17:02:43,503  INFO XmlWebApplicationContext:456 - Refreshing WebApplicationContext for namespace springmvc-servlet: startup date [Thu Mar 29 17:02:43 BRT 2012]; root of context hierarchy

17:02:43,683  INFO XmlBeanDefinitionReader:315 - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-context.xml]

17:02:45,102  INFO DefaultListableBeanFactory:557 - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@19d7e792: defining beans [loginController,olaMundoController,tarefasController,tarefaDAO,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.config.viewControllerHandlerAdapter,org.springframework.web.servlet.config.viewControllerHandlerMapping,org.springframework.web.servlet.handler.MappedInterceptor#1,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,dataSource,org.springframework.web.servlet.view.InternalResourceViewResolver#0,messageSource]; root of factory hierarchy

17:02:46,015  INFO DefaultListableBeanFactory:422 - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@19d7e792: defining beans [loginController,olaMundoController,tarefasController,tarefaDAO,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.config.viewControllerHandlerAdapter,org.springframework.web.servlet.config.viewControllerHandlerMapping,org.springframework.web.servlet.handler.MappedInterceptor#1,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,dataSource,org.springframework.web.servlet.view.InternalResourceViewResolver#0,messageSource]; root of factory hierarchy

17:02:46,020 ERROR DispatcherServlet:333 - Context initialization failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name tarefasController: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private br.com.caelum.tarefas.dao.TarefaDAO br.com.caelum.tarefas.controller.TarefasController.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name tarefaDAO defined in file [C:\Users\willian\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\fj21-tarefas\WEB-INF\classes\br\com\caelum\tarefas\dao\TarefaDAO.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [br.com.caelum.tarefas.dao.TarefaDAO]: Constructor threw exception; nested exception is java.lang.RuntimeException: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user root@localhost (using password: NO))

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)

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$1.getObject(AbstractBeanFactory.java:293)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)

at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:467)

at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:483)

at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:358)

at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:325)

at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)

at javax.servlet.GenericServlet.init(GenericServlet.java:160)

at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1189)

at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1103)

at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1010)

at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4935)

at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5262)

at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5257)

at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)

at java.util.concurrent.FutureTask.run(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private br.com.caelum.tarefas.dao.TarefaDAO br.com.caelum.tarefas.controller.TarefasController.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name tarefaDAO defined in file [C:\Users\willian\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\fj21-tarefas\WEB-INF\classes\br\com\caelum\tarefas\dao\TarefaDAO.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [br.com.caelum.tarefas.dao.TarefaDAO]: Constructor threw exception; nested exception is java.lang.RuntimeException: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user root@localhost (using password: NO))

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)

at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)

 27 more

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name tarefaDAO defined in file [C:\Users\willian\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\fj21-tarefas\WEB-INF\classes\br\com\caelum\tarefas\dao\TarefaDAO.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [br.com.caelum.tarefas.dao.TarefaDAO]: Constructor threw exception; nested exception is java.lang.RuntimeException: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user root@localhost (using password: NO))

at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:288)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)

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$1.getObject(AbstractBeanFactory.java:293)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)

 29 more

Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [br.com.caelum.tarefas.dao.TarefaDAO]: Constructor threw exception; nested exception is java.lang.RuntimeException: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user root@localhost (using password: NO))

at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)

at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:108)

at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)

 41 more

Caused by: java.lang.RuntimeException: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user root@localhost (using password: NO))

at br.com.caelum.tarefas.dao.TarefaDAO.(TarefaDAO.java:28)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)

 43 more

Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user root@localhost (using password: NO))

at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)

at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)

at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)

at br.com.caelum.tarefas.dao.TarefaDAO.(TarefaDAO.java:26)

 48 more

Caused by: java.sql.SQLException: Access denied for user root@localhost (using password: NO)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:935)

at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4101)

at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1300)

at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2337)

at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2370)

at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154)

at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:792)

at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)

at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)

at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)

at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)

at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)

at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)

at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)

 51 more

Mar 29, 2012 5:02:46 PM org.apache.catalina.core.ApplicationContext log

Grave: StandardWrapper.Throwable

org.springframework.beans.factory.BeanCreationException: Error creating bean with name tarefasController: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private br.com.caelum.tarefas.dao.TarefaDAO br.com.caelum.tarefas.controller.TarefasController.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name tarefaDAO defined in file [C:\Users\willian\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\fj21-tarefas\WEB-INF\classes\br\com\caelum\tarefas\dao\TarefaDAO.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [br.com.caelum.tarefas.dao.TarefaDAO]: Constructor threw exception; nested exception is java.lang.RuntimeException: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user root@localhost (using password: NO))

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)

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$1.getObject(AbstractBeanFactory.java:293)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)

at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:467)

at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:483)

at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:358)

at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:325)

at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)

at javax.servlet.GenericServlet.init(GenericServlet.java:160)

at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1189)

at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1103)

at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1010)

at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4935)

at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5262)

at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5257)

at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)

at java.util.concurrent.FutureTask.run(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private br.com.caelum.tarefas.dao.TarefaDAO br.com.caelum.tarefas.controller.TarefasController.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name tarefaDAO defined in file [C:\Users\willian\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\fj21-tarefas\WEB-INF\classes\br\com\caelum\tarefas\dao\TarefaDAO.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [br.com.caelum.tarefas.dao.TarefaDAO]: Constructor threw exception; nested exception is java.lang.RuntimeException: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user root@localhost (using password: NO))

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)

at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)

 27 more

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name tarefaDAO defined in file [C:\Users\willian\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\fj21-tarefas\WEB-INF\classes\br\com\caelum\tarefas\dao\TarefaDAO.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [br.com.caelum.tarefas.dao.TarefaDAO]: Constructor threw exception; nested exception is java.lang.RuntimeException: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user root@localhost (using password: NO))

at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:288)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)

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$1.getObject(AbstractBeanFactory.java:293)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)

 29 more

Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [br.com.caelum.tarefas.dao.TarefaDAO]: Constructor threw exception; nested exception is java.lang.RuntimeException: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user root@localhost (using password: NO))

at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)

at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:108)

at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)

 41 more

Caused by: java.lang.RuntimeException: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user root@localhost (using password: NO))

at br.com.caelum.tarefas.dao.TarefaDAO.(TarefaDAO.java:28)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)

 43 more

Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user root@localhost (using password: NO))

at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)

at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)

at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)

at br.com.caelum.tarefas.dao.TarefaDAO.(TarefaDAO.java:26)

 48 more

Caused by: java.sql.SQLException: Access denied for user root@localhost (using password: NO)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:935)

at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4101)

at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1300)

at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2337)

at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2370)

at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154)

at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:792)

at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)

at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)

at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)

at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)

at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)

at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)

at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)

 51 more
Mar 29, 2012 5:02:46 PM org.apache.catalina.core.StandardContext loadOnStartup

Grave: Servlet /fj21-tarefas threw load() exception

java.sql.SQLException: Access denied for user root’@‘localhost (using password: NO)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:935)

at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4101)

at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1300)

at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2337)

at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2370)

at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154)

at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:792)

at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)

at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)

at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)

at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)

at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)

at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)

at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)

at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)

at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)

at br.com.caelum.tarefas.dao.TarefaDAO.(TarefaDAO.java:26)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)

at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:108)

at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)

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$1.getObject(AbstractBeanFactory.java:293)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)

at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)

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$1.getObject(AbstractBeanFactory.java:293)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)

at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:467)

at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:483)

at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:358)

at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:325)

at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)

at javax.servlet.GenericServlet.init(GenericServlet.java:160)

at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1189)

at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1103)

at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1010)

at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4935)

at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5262)

at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5257)

at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)

at java.util.concurrent.FutureTask.run(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

Mar 29, 2012 5:02:46 PM org.apache.coyote.AbstractProtocolHandler start
Informações: Starting ProtocolHandler [“http-bio-8080”]
Mar 29, 2012 5:02:46 PM org.apache.coyote.AbstractProtocolHandler start
Informações: Starting ProtocolHandler [“ajp-bio-8009”]
Mar 29, 2012 5:02:46 PM org.apache.catalina.startup.Catalina start
Informações: Server startup in 6000 ms

mario.fts

Usuário ou senha inválido no banco de dados.

Da uma olhada na mensagem da stacktrace, é mais rápido que vc esperar alguém te ajudar.

denisspitfire

mas o problema é o seguinte, eu uso essa mesma classe com o teste e conecta… se conecta como pode dar usuario invalido?

denisspitfire
public class TestaConexao {
	public static void main(String[] args) throws SQLException {
		Connection connection = new ConnectionFactory().getConnection();
		System.out.println("Conexao aberta!");
		connection.close();
	}
}

tipo, essa classe chama a ConectionFactory, e da certo! mas quando eu do play no servidor da esse problema. Para garantir eu exclui todos os projetos para ver se nao era um link errado com outro conection e funcionou.

mario.fts

Olha no arquivo de configuração do spring e ve se ta tudo certo lá.

Criado 29 de março de 2012
Ultima resposta 29 de mar. de 2012
Respostas 10
Participantes 2