spring - getting org.hibernate.exception.SQLGrammarException:Table not found -
my code working basicdatasource configuration. when have changed jndi-lookup (jndi data source jboss 7). getting below error.
17:28:39,865 info [org.jboss.as.server.controller] (deploymentscanner-threads - 2) deployed "documentmanager-0.0.1-snapshot.war" 17:28:50,616 warn [org.hibernate.engine.jdbc.spi.sqlexceptionhelper] (http--127.0.0.1-8080-1) sql error: 42102, sqlstate: 42s02 17:28:50,616 error [org.hibernate.engine.jdbc.spi.sqlexceptionhelper] (http--127.0.0.1-8080-1) table "documents" not found; sql statement: select document0_.id id0_, document0_.created created0_, document0_.description descript3_0_, document0_.filename filename0_, document0_.name name0_ documents document0_ [42102-145] 17:28:50,618 error [stderr] (http--127.0.0.1-8080-1) org.hibernate.exception.sqlgrammarexception: table "documents" not found; sql statement: 17:28:50,619 error [stderr] (http--127.0.0.1-8080-1) select document0_.id id0_, document0_.created created0_, document0_.description descript3_0_, document0_.filename filename0_, document0_.name name0_ documents document0_ [42102-145] 17:28:50,622 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.exception.internal.sqlstateconversiondelegate.convert(sqlstateconversiondelegate.java:122) 17:28:50,622 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.exception.internal.standardsqlexceptionconverter.convert(standardsqlexceptionconverter.java:49) 17:28:50,622 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.jdbc.spi.sqlexceptionhelper.convert(sqlexceptionhelper.java:125) 17:28:50,622 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.jdbc.spi.sqlexceptionhelper.convert(sqlexceptionhelper.java:110) 17:28:50,623 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.jdbc.internal.proxy.connectionproxyhandler.continueinvocation(connectionproxyhandler.java:146) 17:28:50,623 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.jdbc.internal.proxy.abstractproxyhandler.invoke(abstractproxyhandler.java:81) 17:28:50,624 error [stderr] (http--127.0.0.1-8080-1) @ com.sun.proxy.$proxy27.preparestatement(unknown source) 17:28:50,625 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.jdbc.internal.statementpreparerimpl$5.doprepare(statementpreparerimpl.java:147) 17:28:50,625 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.jdbc.internal.statementpreparerimpl$statementpreparationtemplate.preparestatement(statementpreparerimpl.java:166) 17:28:50,625 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.jdbc.internal.statementpreparerimpl.preparequerystatement(statementpreparerimpl.java:145) 17:28:50,626 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.loader.loader.preparequerystatement(loader.java:1720) 17:28:50,627 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.loader.loader.doquery(loader.java:828) 17:28:50,627 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.loader.loader.doqueryandinitializenonlazycollections(loader.java:289) 17:28:50,627 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.loader.loader.dolist(loader.java:2447) 17:28:50,627 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.loader.loader.dolist(loader.java:2433) 17:28:50,627 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.loader.loader.listignorequerycache(loader.java:2263) 17:28:50,628 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.loader.loader.list(loader.java:2258) 17:28:50,628 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.loader.hql.queryloader.list(queryloader.java:470) 17:28:50,628 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.hql.internal.ast.querytranslatorimpl.list(querytranslatorimpl.java:355) 17:28:50,628 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.engine.query.spi.hqlqueryplan.performlist(hqlqueryplan.java:196) 17:28:50,628 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.internal.sessionimpl.list(sessionimpl.java:1161) 17:28:50,629 error [stderr] (http--127.0.0.1-8080-1) @ org.hibernate.internal.queryimpl.list(queryimpl.java:101) 17:28:50,629 error [stderr] (http--127.0.0.1-8080-1) @ com.ecom.data.access.dao.documentdao.list(documentdao.java:31) 17:28:50,629 error [stderr] (http--127.0.0.1-8080-1) @ com.ecom.data.access.dao.documentdao$$fastclassbycglib$$9564c110.invoke(<generated>) 17:28:50,629 error [stderr] (http--127.0.0.1-8080-1) @ org.springframework.cglib.proxy.methodproxy.invoke(methodproxy.java:204) 17:28:50,629 error [stderr] (http--127.0.0.1-8080-1) @ org.springframework.aop.framework.cglibaopproxy$cglibmethodinvocation.invokejoinpoint(cglibaopproxy.java:698) 17:28:50,630 error [stderr] (http--127.0.0.1-8080-1) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:150) 17:28:50,630 error [stderr] (http--127.0.0.1-8080-1) @ org.springframework.transaction.interceptor.transactioninterceptor$1.proceedwithinvocation(transactioninterceptor.java:96) 17:28:50,630 error [stderr] (http--127.0.0.1-8080-1) @ org.springframework.transaction.interceptor.transactionaspectsupport.invokewithintransaction(transactionaspectsupport.java:260) 17:28:50,630 error [stderr] (http--127.0.0.1-8080-1) @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:94) 17:28:50,630 error [stderr] (http--127.0.0.1-8080-1) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172) 17:28:50,631 error [stderr] (http--127.0.0.1-8080-1) @ org.springframework.aop.framework.cglibaopproxy$dynamicadvisedinterceptor.intercept(cglibaopproxy.java:631) 17:28:50,631 error [stderr] (http--127.0.0.1-8080-1) @ com.ecom.data.access.dao.documentdao$$enhancerbycglib$$48352a12.list(<generated>) 17:28:50,631 error [stderr] (http--127.0.0.1-8080-1) @ com.ecom.data.access.controller.documentcontroller.index(documentcontroller.java:42) 17:28:50,631 error [stderr] (http--127.0.0.1-8080-1) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) 17:28:50,631 error [stderr] (http--127.0.0.1-8080-1) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) 17:28:50,632 error [stderr] (http--127.0.0.1-8080-1) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) 17:28:50,632 error [stderr] (http--127.0.0.1-8080-1) @ java.lang.reflect.method.invoke(method.java:597) 17:28:50,632 error [stderr] (http--127.0.0.1-8080-1) @ org.springframework.web.bind.annotation.support.handlermethodinvoker.invokehandlermethod(handlermethodinvoker.java:176) 17:28:50,632 error [stderr] (http--127.0.0.1-8080-1) @ org.springframework.web.servlet.mvc.annotation.annotationmethodhandleradapter.invokehandlermethod(annotationmethodhandleradapter.java:440) 17:28:50,633 error [stderr] (http--127.0.0.1-8080-1) @ org.springframework.web.servlet.mvc.annotation.annotationmethodhandleradapter.handle(annotationmethodhandleradapter.java:428) 17:28:50,633 error [stderr] (http--127.0.0.1-8080-1) @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:925) 17:28:50,633 error [stderr] (http--127.0.0.1-8080-1) @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:856) 17:28:50,633 error [stderr] (http--127.0.0.1-8080-1) @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:936) 17:28:50,634 error [stderr] (http--127.0.0.1-8080-1) @ org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:827) 17:28:50,634 error [stderr] (http--127.0.0.1-8080-1) @ javax.servlet.http.httpservlet.service(httpservlet.java:734) 17:28:50,634 error [stderr] (http--127.0.0.1-8080-1) @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:812) 17:28:50,634 error [stderr] (http--127.0.0.1-8080-1) @ javax.servlet.http.httpservlet.service(httpservlet.java:847) 17:28:50,634 error [stderr] (http--127.0.0.1-8080-1) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:329) 17:28:50,635 error [stderr] (http--127.0.0.1-8080-1) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:248) 17:28:50,635 error [stderr] (http--127.0.0.1-8080-1) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:275) 17:28:50,635 error [stderr] (http--127.0.0.1-8080-1) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:161) 17:28:50,635 error [stderr] (http--127.0.0.1-8080-1) @ org.jboss.as.web.security.securitycontextassociationvalve.invoke(securitycontextassociationvalve.java:139) 17:28:50,635 error [stderr] (http--127.0.0.1-8080-1) @ org.jboss.as.web.namingvalve.invoke(namingvalve.java:57) 17:28:50,636 error [stderr] (http--127.0.0.1-8080-1) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:154) 17:28:50,636 error [stderr] (http--127.0.0.1-8080-1) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:102) 17:28:50,636 error [stderr] (http--127.0.0.1-8080-1) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:109) 17:28:50,636 error [stderr] (http--127.0.0.1-8080-1) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:362) 17:28:50,636 error [stderr] (http--127.0.0.1-8080-1) @ org.apache.coyote.http11.http11processor.process(http11processor.java:877) 17:28:50,636 error [stderr] (http--127.0.0.1-8080-1) @ org.apache.coyote.http11.http11protocol$http11connectionhandler.process(http11protocol.java:667) 17:28:50,637 error [stderr] (http--127.0.0.1-8080-1) @ org.apache.tomcat.util.net.jioendpoint$worker.run(jioendpoint.java:952) 17:28:50,637 error [stderr] (http--127.0.0.1-8080-1) @ java.lang.thread.run(thread.java:662) 17:28:50,637 error [stderr] (http--127.0.0.1-8080-1) caused by: org.h2.jdbc.jdbcsqlexception: table "documents" not found; sql statement: 17:28:50,637 error [stderr] (http--127.0.0.1-8080-1) select document0_.id id0_, document0_.created created0_, document0_.description descript3_0_, document0_.filename filename0_, document0_.name name0_ documents document0_ [42102-145]
please find spring config below.
<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> <context:annotation-config /> <context:component-scan base-package="com.ecom.data.access" /> <bean id="jspviewresolver" class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="viewclass" value="org.springframework.web.servlet.view.jstlview" /> <property name="prefix" value="/web-inf/views/" /> <property name="suffix" value=".jsp" /> </bean> <bean id="propertyconfigurer" class="org.springframework.beans.factory.config.propertyplaceholderconfigurer" p:location="/web-inf/jdbc.properties" /> <util:properties id="documentmanagerproperties" location="classpath:jdbc.properties" /> <jee:jndi-lookup id="usermanagementdatasource" jndi-name="java:jboss/datasources/usermanagementdatasource" /> <bean id="sessionfactory" class="org.springframework.orm.hibernate4.localsessionfactorybean"> <property name="datasource" ref="usermanagementdatasource" /> <property name="configlocation"> <value>classpath:hibernate.cfg.xml</value> </property> <property name="hibernateproperties" ref="documentmanagerproperties"> <!-- <props> <prop key="hibernate.dialect">${jdbc.dialect}</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.connection.setbigstringtryclob">true</prop> <prop key="hibernate.jdbc.batch_size">0</prop> </props> --> </property> </bean> <bean id="multipartresolver" class="org.springframework.web.multipart.commons.commonsmultipartresolver"> <!-- 1 of properties available; maximum file size in bytes --> <property name="maxuploadsize" value="10000000" /> </bean> <tx:annotation-driven /> <bean id="transactionmanager" class="org.springframework.orm.hibernate4.hibernatetransactionmanager"> <property name="sessionfactory" ref="sessionfactory" /> </bean> </beans>
entity class:
package com.ecom.data.access.model; //import java.sql.blob; import java.sql.blob; import java.sql.date; import javax.persistence.column; import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.id; import javax.persistence.lob; //import javax.persistence.lob; import javax.persistence.table; @entity @table(name="documents") public class document { @id @generatedvalue @column(name="id") private integer id; @column(name="name") private string name; @column(name="description") private string description; @column(name="filename") private string filename; /* @column(name="content") @lob private blob content;*/ /*public blob getcontent() { return content; } public void setcontent(blob content) { this.content = content; }*/ /*@column(name="content_type") private string contenttype;*/ @column(name="created") private date created; public integer getid() { return id; } public void setid(integer id) { this.id = id; } public string getname() { return name; } public void setname(string name) { this.name = name; } public string getdescription() { return description; } public void setdescription(string description) { this.description = description; } public string getfilename() { return filename; } public void setfilename(string filename) { this.filename = filename; } /*public string getcontenttype() { return contenttype; } public void setcontenttype(string contenttype) { this.contenttype = contenttype; }*/ public date getcreated() { return created; } public void setcreated(date created) { this.created = created; } }
documetdao is:
package com.ecom.data.access.dao; import java.util.list; import com.ecom.data.access.model.document; import org.hibernate.hibernateexception; import org.hibernate.session; import org.hibernate.sessionfactory; import org.springframework.beans.factory.annotation.autowired; import org.springframework.stereotype.repository; import org.springframework.transaction.annotation.transactional; @repository public class documentdao { @autowired private sessionfactory sessionfactory; @transactional public void save(document document) { session session = sessionfactory.getcurrentsession(); session.save(document); } @transactional public list<document> list() { session session = sessionfactory.getcurrentsession(); list<document> documents = null; try { documents = (list<document>)session.createquery("from document").list(); system.out.println("list of document here----> "+ list().get(0)); } catch (hibernateexception e) { e.printstacktrace(); } return documents; } @transactional public document get(integer id) { session session = sessionfactory.getcurrentsession(); system.out.println("id is---------------------> "+ id); return (document)session.get(document.class, id); } /* @transactional public void remove(integer id) { session session = sessionfactory.getcurrentsession(); document document = (document)session.get(document.class, id); session.delete(document); }*/ }
table is:
create table `documents` ( `id` int(11) not null auto_increment, `name` varchar(200) not null, `description` text not null, `filename` varchar(200), `created` timestamp not null default current_timestamp, primary key (`id`) );
please me find out solution. in advance
Comments
Post a Comment