grails prod war > grails run-war não funciona
06/05/2010 00:00
0
Olá,

Criei uma aplicação simples e instalei o plugin acegi.

Mapeei todas as tabelas no banco mysql.

Tudo funciona direitinho com o comando grails run-app.

Mas ao gerar o war 'grails prod war' e tentar rodar 'grails run-war' o mesmo apresenta o seguinte erro abaixo:

org.hibernate.exception.SQLGrammarException: could not execute query

at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)

at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)

at org.hibernate.loader.Loader.doList(Loader.java:2231)

at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2157)

at org.hibernate.loader.Loader.list(Loader.java:2117)

at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)

at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)

at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)

at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)

at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:229)

at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)

at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:121)

at org.codehaus.groovy.grails.plugins.springsecurity.GrailsDaoImpl.loadDomainUser(GrailsDaoImpl.groovy:102)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:266)

at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:51)

at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:155)

at org.codehaus.groovy.grails.plugins.springsecurity.GrailsDaoImpl.loadUserByUsername(GrailsDaoImpl.groovy:72)

at org.codehaus.groovy.grails.plugins.springsecurity.GrailsDaoImpl$loadUserByUsername.callCurrent(Unknown Source)

at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:155)

at org.codehaus.groovy.grails.plugins.springsecurity.GrailsDaoImpl.loadUserByUsername(GrailsDaoImpl.groovy:52)

at org.springframework.security.ui.rememberme.TokenBasedRememberMeServices.processAutoLoginCookie(TokenBasedRememberMeServices.java:112)

at org.springframework.security.ui.rememberme.AbstractRememberMeServices.autoLogin(AbstractRememberMeServices.java:85)

at org.springframework.security.ui.rememberme.RememberMeProcessingFilter.doFilterHttp(RememberMeProcessingFilter.java:74)

at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)

at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)

at org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter.doFilterHttp(SecurityContextHolderAwareRequestFilter.java:91)

at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)

at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)

at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:277)

at org.codehaus.groovy.grails.plugins.springsecurity.GrailsAuthenticationProcessingFilter.super$3$doFilterHttp(GrailsAuthenticationProcessingFilter.groovy)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)

at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)

at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1049)

at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:923)

at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:127)

at org.codehaus.groovy.grails.plugins.springsecurity.GrailsAuthenticationProcessingFilter.doFilterHttp(GrailsAuthenticationProcessingFilter.groovy:56)

at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)

at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)

at org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89)

at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)

at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)

at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)

at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)

at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)

at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)

at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)

at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.codehaus.groovy.grails.web.servlet.filter.GrailsReloadServletFilter.doFilterInternal(GrailsReloadServletFilter.java:101)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:65)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:66)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)

at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)

at java.lang.Thread.run(Thread.java:619)

Caused by: java.sql.SQLException: Table not found in statement [select user0_.idusuario as idusuario12_, user0_.enabled as enabled12_, user0_.passwd as passwd12_, user0_.userRealName as userReal4_12_, user0_.username as username12_, user0_.emailshow as emailshow12_, user0_.email as email12_, user0_.description as descript8_12_ from usuario user0_ where user0_.username=?]

at org.hsqldb.jdbc.Util.throwError(Unknown Source)

at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)

at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)

at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:534)

at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:452)

at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)

at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1573)

at org.hibernate.loader.Loader.doQuery(Loader.java:696)

at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)

at org.hibernate.loader.Loader.doList(Loader.java:2228)

... 93 more
Tags: Tópicos avançados


0
Lembre-se de que o banco de dados de produção não é o mesmo do de desenvolvimento sempre.

Saca só esta linha no seu stacktrace:

Caused by: java.sql.SQLException: Table not found in statement [select user0_.idusuario as idusuario12_, user0_.enabled as enabled12_, user0_.passwd as passwd12_, user0_.userRealName as userReal4_12_, user0_.username as username12_, user0_.emailshow as emailshow12_, user0_.email as email12_, user0_.description as descript8_12_ from usuario user0_ where user0_.username=?]

Verifique se a tabela usuario existe de fato em ambas as bases de dados. Porque o erro é justamente a ausência da tabela.


0
Eu percebi isso, acontece q eu desenvolvi apontando para o banco de produção mesmo, o meu DataSource.groovy tá assim até:

url = &quot;jdbc:mysql://xxxxx:3306/xxxxx&quot; >> está apontando para o bd de dados remoto: ex: de ip remoto: 176.876.56.345, eu ñ coloquei localhost nem 127.0.0.1, apesar de estar no mesmo local q estou publicando deixei o ip válido para garantir.

dataSource {
boolean pooled = true
String driverClassName = &quot;com.mysql.jdbc.Driver&quot;
String username = &quot;xxxxx&quot;
String password = &quot;xxxxx&quot;
String dialect = org.hibernate.dialect.MySQL5InnoDBDialect
}
hibernate {
cache.use_second_level_cache=true
cache.use_query_cache=true
cache.provider_class='net.sf.ehcache.hibernate.EhCacheProvider'
}
// environment specific settings
environments {
development {
dbCreate = &quot;create-update&quot;
url = &quot;jdbc:mysql://xxxxx:3306/xxxxx&quot;
String driverClassName = &quot;com.mysql.jdbc.Driver&quot;
String username = &quot;xxxxxx&quot;
String password = &quot;xxxxxx&quot;
String dialect = org.hibernate.dialect.MySQL5InnoDBDialect
}
test {
dataSource {
dbCreate = &quot;create-update&quot;
url = &quot;jdbc:mysql://xxxxx:3306/xxxxx&quot;
String driverClassName = &quot;com.mysql.jdbc.Driver&quot;
String username = &quot;xxxxxx&quot;
String password = &quot;xxxxxx&quot;
String dialect = org.hibernate.dialect.MySQL5InnoDBDialect
}
}
production {
dataSource {
dbCreate = &quot;create-update&quot;
url = &quot;jdbc:mysql://xxxxx:3306/xxxxx&quot;
String driverClassName = &quot;com.mysql.jdbc.Driver&quot;
String username = &quot;xxxxxx&quot;
String password = &quot;xxxxxx&quot;
String dialect = org.hibernate.dialect.MySQL5InnoDBDialect
}
}
}
07/05/2010 00:00


0
Todos os ambientes apontam para o mesmo banco de dados e mesmo assim o erro continua?


0
Vlw pela ajuda.


Resolvi com o seguinte:

Antes

dataSource {
boolean pooled = true

String driverClassName = &quot;com.mysql.jdbc.Driver&quot;
String username = &quot;xxxxx&quot;
String password = &quot;xxxxx&quot;

String dialect = org.hibernate.dialect.MySQL5InnoDBDialect
}


Tirei o tipo da variável, tinha visto isto antes no google, mas nem me atentei já que o povo reclamava que nem compilava o código, mas o meu compilava normal, só na hora de rodar o war que dava problemas.

Depois
dataSource {
pooled = true

driverClassName = &quot;com.mysql.jdbc.Driver&quot;
username = &quot;xxxxx&quot;
password = &quot;xxxxx&quot;

dialect = org.hibernate.dialect.MySQL5InnoDBDialect
}

Obrigado.
07/05/2010 00:00



Ainda não faz parte da comunidade???

Para se registrar, clique aqui.


Aprenda Groovy e Grails com a Formação itexto!

Newsletter Semana Groovy

Assinar

Envie seu link!


Livro de Grails


/dev/All

Os melhores blogs de TI (e em português) em um único lugar!

 
Creative Commons
RSS Grails Brasil é mantido por itexto Consultoria.
Em caso de problemas contacte Henrique Lobo Weissmann (Kico) por e-mail: kico@itexto.com.br
Todo o conteúdo presente neste site adota o Creative Commons como licença padrão.
Ver: 4.14.0
itexto