개발사랑211333
10
2019-01-13 05:48:54 작성 2019-01-13 05:49:55 수정됨
0
63

JDBC 연동 후 에러 발생.. 질문드립니다.!


ㅁ 환경 설명

- servlet-context.xml

 <beans:bean name="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  <beans:property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
  <beans:property name="url" value="jdbc:oracle:thin:@localhost:1521:xe"/>
  <beans:property name="username" value="scott"/>
  <beans:property name="password" value="tiger"/>
 </beans:bean>
 
 <beans:bean name="template" class="org.springframework.jdbc.core.JdbcTemplate">
  <beans:property name="dataSource" ref="dataSource"/>
 </beans:bean>

- BController.java

@Controller
public class BController {
 
 BCommand command;
 public JdbcTemplate template;
 
 @Autowired
 public void setTemplate(JdbcTemplate template) {
  this.template = template;
  Constant.template = this.template;
 }
 
 
 
 @RequestMapping("/list")
 public String list(Model model) {
  System.out.println("list()");
  
  command = new BListCommand();
  command.execute(model);
  
  return "list";
 }

}


- BDao.java

public class BDao {

 DataSource dataSource;
 JdbcTemplate template = null;
 
 public BDao() {
  // TODO Auto-generated constructor stub


  try {
   Context context = new InitialContext();
   dataSource = (DataSource)context.lookup("java:comp/env/jdbc/Oracle11g");
  } catch (NamingException e) {
   e.printStackTrace();
  }
  
  template = Constant.template;
 }
 
 public ArrayList<BDto> list() {
  
  String query = "select bId, bName, bTitle, bContent, bDate, bHit, bGroup, bStep, bIndent from mvc_board order by bGroup desc, bStep asc";
  return (ArrayList<BDto>) template.query(query, new BeanPropertyRowMapper<BDto>(BDto.class));

} }


- BDto.java

public class BDto {
 
 int bId;
 String bName;
 String bTitle;
 String bContent;
 Timestamp bDate;
 int bHit;
 int bGroup;
 int bStep;
 int bIndent;
 
 public BDto(int bId, String bName, String bTitle, String bContent, Timestamp bDate, int bHit, int bGroup, int bStep, int bIndent) {
  this.bId = bId;
  this.bName = bName;
  this.bTitle = bTitle;
  this.bContent = bContent;
  this.bDate = bDate;
  this.bHit = bHit;
  this.bGroup = bGroup;
  this.bStep = bStep;
  this.bIndent = bIndent;
 }


 public int getbId() {
  return bId;
 }


 public void setbId(int bId) {
  this.bId = bId;
 }


 public String getbName() {
  return bName;
 }


 public void setbName(String bName) {
  this.bName = bName;
 }


 public String getbTitle() {
  return bTitle;
 }


 public void setbTitle(String bTitle) {
  this.bTitle = bTitle;
 }


 public String getbContent() {
  return bContent;
 }


 public void setbContent(String bContent) {
  this.bContent = bContent;
 }


 public Timestamp getbDate() {
  return bDate;
 }


 public void setbDate(Timestamp bDate) {
  this.bDate = bDate;
 }


 public int getbHit() {
  return bHit;
 }


 public void setbHit(int bHit) {
  this.bHit = bHit;
 }


 public int getbGroup() {
  return bGroup;
 }


 public void setbGroup(int bGroup) {
  this.bGroup = bGroup;
 }


 public int getbStep() {
  return bStep;
 }


 public void setbStep(int bStep) {
  this.bStep = bStep;
 }


 public int getbIndent() {
  return bIndent;
 }


 public void setbIndent(int bIndent) {
  this.bIndent = bIndent;
 }
}



위의 환경에서 아래의 URL 접속 시 오류 발생


- URL : http://localhost:8181/spring_pjt_board/list

- 오류 메세지

1월 13, 2019 5:40:14 오전 org.apache.catalina.core.StandardWrapperValve invoke
심각: Servlet.service() for servlet [appServlet] in context with path [/spring_pjt_board] threw exception [Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.javalec.spring_pjt_board.dto.BDto]: Is it an abstract class?; nested exception is java.lang.InstantiationException: com.javalec.spring_pjt_board.dto.BDto] with root cause
java.lang.NoSuchMethodException: com.javalec.spring_pjt_board.dto.BDto.<init>()
 at java.lang.Class.getConstructor0(Unknown Source)
 at java.lang.Class.newInstance(Unknown Source)
 at org.springframework.beans.BeanUtils.instantiate(BeanUtils.java:78)
 at org.springframework.jdbc.core.BeanPropertyRowMapper.mapRow(BeanPropertyRowMapper.java:236)
 at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:93)
 at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:60)
 at org.springframework.jdbc.core.JdbcTemplate$1QueryStatementCallback.doInStatement(JdbcTemplate.java:460)
 at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:405)
 at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:471)
 at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:481)
 at com.javalec.spring_pjt_board.dao.BDao.list(BDao.java:42)
 at com.javalec.spring_pjt_board.command.BListCommand.execute(BListCommand.java:17)
 at com.javalec.spring_pjt_board.controller.BController.list(BController.java:41)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
 at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
 at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777)
 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706)
 at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
 at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
 at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
 at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1137)
 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
 at java.lang.Thread.run(Unknown Source)

일단 BDto 클래스는 추상 클래스가 아닙니다.. 저 에러 메세지가 뜨면서

제가 만든 게시판(list) 글을 읽어지 못합니다..

증상은 게시글이 존재하는 경우(DB에 데이터가 있는경우) 저 오류 메세지를 뿌리구요..

게시글이 존재하지 않는 경우 오류메세지가 나오지 않습니다...


무엇이 문제일까요?


0
0
  • 답변 0

  • 로그인을 하시면 답변을 등록할 수 있습니다.