Datasource JNDI JBoss
18/06/2010 00:00
0
Estou com alguns problemas para achar pelo grails um Datasource por JNDI do jboss 5, ele da um mensagem de erro falando que ele não acha o contexto, eu to utilizando pelo grails uma conexão jms com o jboss 5 e ele acha normalmente, alguém sabe o que poderia ser?
Arquivo datasource:
dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = "root"
}
hibernate {
cache.use_second_level_cache=true
cache.use_query_cache=true
cache.provider_class='net.sf.ehcache.hibernate.EhCacheProvider'
}
environments {
development {
dataSource {
dbCreate = "create-drop"
url = "jdbc:mysql://localhost/tcceletronic_dev"
}
}
production {
dataSource {
jndiName = "java:mysqlDS"
dbCreate = "create-drop"
}
}
}


Datasource no JBoss:
<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>

<!-- See http&#58;//www.jboss.org/community/wiki/Multiple1PC for information about local-tx-datasource -->
<!-- $Id&#58; mysql-ds.xml 88948 2009-05-15 14&#58;09&#58;08Z jesper.pedersen $ -->
<!-- Datasource config for MySQL using 3.0.9 available from&#58;
http&#58;//www.mysql.com/downloads/api-jdbc-stable.html
-->

<datasources>
<local-tx-datasource>
<jndi-name>mysqlDS</jndi-name>
<connection-url>jdbc&#58;mysql&#58;//localhost&#58;3306/tcceletronic_prod</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>root</password>
<min-pool-size>5</min-pool-size>
<max-pool-size>30</max-pool-size>
<idle-timeout-minutes>1</idle-timeout-minutes>
</local-tx-datasource>
</datasources>


Erro:
2010-06-18 14&#58;58&#58;57,174 [main] ERROR context.ContextLoader  - Context initializa
tion failed
org.springframework.beans.factory.BeanCreationException&#58; Error creating bean wit
h name 'messageSource'&#58; Initialization of bean failed; nested exception is org.s
pringframework.beans.factory.BeanCreationException&#58; Error creating bean with nam
e 'transactionManager'&#58; Cannot resolve reference to bean 'sessionFactory' while
setting bean property 'sessionFactory'; nested exception is org.springframework.
beans.factory.BeanCreationException&#58; Error creating bean with name 'sessionFacto
ry'&#58; Cannot resolve reference to bean 'dataSource' while setting bean property '
dataSource'; nested exception is org.springframework.beans.factory.BeanCreationE
xception&#58; Error creating bean with name 'dataSource'&#58; Cannot resolve reference t
o bean 'dataSourceUnproxied' while setting constructor argument; nested exceptio
n is org.springframework.beans.factory.BeanCreationException&#58; Error creating bea
n with name 'dataSourceUnproxied'&#58; Invocation of init method failed; nested exce
ption is javax.naming.NameNotFoundException&#58; Name mysqlDS is not bound in this C
ontext
at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy&#58;164)
at grails.web.container.EmbeddableServer$start.call(Unknown Source)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy&#58;15
9)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy&#58;2
82)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy&#58;150)
at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
at _GrailsRun_groovy.runInline(_GrailsRun_groovy&#58;116)
at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy&#58;59)
at RunApp$_run_closure1.doCall(RunApp.groovy&#58;33)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy&#58;381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy&#58;415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy&#58;427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy&#58;415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy&#58;590)
at gant.Gant.executeTargets(Gant.groovy&#58;589)
Caused by&#58; org.springframework.beans.factory.BeanCreationException&#58; Error creati
ng bean with name 'transactionManager'&#58; Cannot resolve reference to bean 'sessio
nFactory' while setting bean property 'sessionFactory'; nested exception is org.
springframework.beans.factory.BeanCreationException&#58; Error creating bean with na
me 'sessionFactory'&#58; Cannot resolve reference to bean 'dataSource' while setting
bean property 'dataSource'; nested exception is org.springframework.beans.facto
ry.BeanCreationException&#58; Error creating bean with name 'dataSource'&#58; Cannot res
olve reference to bean 'dataSourceUnproxied' while setting constructor argument;
nested exception is org.springframework.beans.factory.BeanCreationException&#58; Er
ror creating bean with name 'dataSourceUnproxied'&#58; Invocation of init method fai
led; nested exception is javax.naming.NameNotFoundException&#58; Name mysqlDS is not
bound in this Context
... 23 more
Caused by&#58; org.springframework.beans.factory.BeanCreationException&#58; Error creati
ng bean with name 'sessionFactory'&#58; Cannot resolve reference to bean 'dataSource
' while setting bean property 'dataSource'; nested exception is org.springframew
ork.beans.factory.BeanCreationException&#58; Error creating bean with name 'dataSour
ce'&#58; Cannot resolve reference to bean 'dataSourceUnproxied' while setting constr
uctor argument; nested exception is org.springframework.beans.factory.BeanCreati
onException&#58; Error creating bean with name 'dataSourceUnproxied'&#58; Invocation of
init method failed; nested exception is javax.naming.NameNotFoundException&#58; Name
mysqlDS is not bound in this Context
... 23 more
Caused by&#58; org.springframework.beans.factory.BeanCreationException&#58; Error creati
ng bean with name 'dataSource'&#58; Cannot resolve reference to bean 'dataSourceUnpr
oxied' while setting constructor argument; nested exception is org.springframewo
rk.beans.factory.BeanCreationException&#58; Error creating bean with name 'dataSourc
eUnproxied'&#58; Invocation of init method failed; nested exception is javax.naming.
NameNotFoundException&#58; Name mysqlDS is not bound in this Context
... 23 more
Caused by&#58; org.springframework.beans.factory.BeanCreationException&#58; Error creati
ng bean with name 'dataSourceUnproxied'&#58; Invocation of init method failed; neste
d exception is javax.naming.NameNotFoundException&#58; Name mysqlDS is not bound in
this Context
... 23 more
Caused by&#58; javax.naming.NameNotFoundException&#58; Name mysqlDS is not bound in this
Context
at org.apache.naming.NamingContext.lookup(NamingContext.java&#58;770)
at org.apache.naming.NamingContext.lookup(NamingContext.java&#58;153)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java&#58;137)
at javax.naming.InitialContext.lookup(InitialContext.java&#58;392)
... 23 more
2010-06-18 14&#58;58&#58;57,174 [main] ERROR [localhost].[/TCCEletronic] - Exception se
nding context initialized event to listener instance of class org.codehaus.groov
y.grails.web.context.GrailsContextLoaderListener
org.springframework.beans.factory.BeanCreationException&#58; Error creating bean wit
h name 'messageSource'&#58; Initialization of bean failed; nested exception is org.s
pringframework.beans.factory.BeanCreationException&#58; Error creating bean with nam
e 'transactionManager'&#58; Cannot resolve reference to bean 'sessionFactory' while
setting bean property 'sessionFactory'; nested exception is org.springframework.
beans.factory.BeanCreationException&#58; Error creating bean with name 'sessionFacto
ry'&#58; Cannot resolve reference to bean 'dataSource' while setting bean property '
dataSource'; nested exception is org.springframework.beans.factory.BeanCreationE
xception&#58; Error creating bean with name 'dataSource'&#58; Cannot resolve reference t
o bean 'dataSourceUnproxied' while setting constructor argument; nested exceptio
n is org.springframework.beans.factory.BeanCreationException&#58; Error creating bea
n with name 'dataSourceUnproxied'&#58; Invocation of init method failed; nested exce
ption is javax.naming.NameNotFoundException&#58; Name mysqlDS is not bound in this C
ontext
at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy&#58;164)
at grails.web.container.EmbeddableServer$start.call(Unknown Source)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy&#58;15
9)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy&#58;2
82)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy&#58;150)
at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
at _GrailsRun_groovy.runInline(_GrailsRun_groovy&#58;116)
at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy&#58;59)
at RunApp$_run_closure1.doCall(RunApp.groovy&#58;33)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy&#58;381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy&#58;415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy&#58;427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy&#58;415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy&#58;590)
at gant.Gant.executeTargets(Gant.groovy&#58;589)
Caused by&#58; org.springframework.beans.factory.BeanCreationException&#58; Error creati
ng bean with name 'transactionManager'&#58; Cannot resolve reference to bean 'sessio
nFactory' while setting bean property 'sessionFactory'; nested exception is org.
springframework.beans.factory.BeanCreationException&#58; Error creating bean with na
me 'sessionFactory'&#58; Cannot resolve reference to bean 'dataSource' while setting
bean property 'dataSource'; nested exception is org.springframework.beans.facto
ry.BeanCreationException&#58; Error creating bean with name 'dataSource'&#58; Cannot res
olve reference to bean 'dataSourceUnproxied' while setting constructor argument;
nested exception is org.springframework.beans.factory.BeanCreationException&#58; Er
ror creating bean with name 'dataSourceUnproxied'&#58; Invocation of init method fai
led; nested exception is javax.naming.NameNotFoundException&#58; Name mysqlDS is not
bound in this Context
... 23 more
Caused by&#58; org.springframework.beans.factory.BeanCreationException&#58; Error creati
ng bean with name 'sessionFactory'&#58; Cannot resolve reference to bean 'dataSource
' while setting bean property 'dataSource'; nested exception is org.springframew
ork.beans.factory.BeanCreationException&#58; Error creating bean with name 'dataSour
ce'&#58; Cannot resolve reference to bean 'dataSourceUnproxied' while setting constr
uctor argument; nested exception is org.springframework.beans.factory.BeanCreati
onException&#58; Error creating bean with name 'dataSourceUnproxied'&#58; Invocation of
init method failed; nested exception is javax.naming.NameNotFoundException&#58; Name
mysqlDS is not bound in this Context
... 23 more
Caused by&#58; org.springframework.beans.factory.BeanCreationException&#58; Error creati
ng bean with name 'dataSource'&#58; Cannot resolve reference to bean 'dataSourceUnpr
oxied' while setting constructor argument; nested exception is org.springframewo
rk.beans.factory.BeanCreationException&#58; Error creating bean with name 'dataSourc
eUnproxied'&#58; Invocation of init method failed; nested exception is javax.naming.
NameNotFoundException&#58; Name mysqlDS is not bound in this Context
... 23 more
Caused by&#58; org.springframework.beans.factory.BeanCreationException&#58; Error creati
ng bean with name 'dataSourceUnproxied'&#58; Invocation of init method failed; neste
d exception is javax.naming.NameNotFoundException&#58; Name mysqlDS is not bound in
this Context
... 23 more
Caused by&#58; javax.naming.NameNotFoundException&#58; Name mysqlDS is not bound in this
Context
at org.apache.naming.NamingContext.lookup(NamingContext.java&#58;770)
at org.apache.naming.NamingContext.lookup(NamingContext.java&#58;153)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java&#58;137)
at javax.naming.InitialContext.lookup(InitialContext.java&#58;392)
... 23 more
2010-06-18 14&#58;58&#58;57,221 [main] ERROR core.StandardContext - Error listenerStart

2010-06-18 14&#58;58&#58;57,236 [main] ERROR core.StandardContext - Context [/TCCEletro
nic] startup failed due to previous errors
Tags: Tópicos avançados


0
Utilizando o código a abaixo no resources.groovy o Jndi conecta normalmente no JBoss 5, mas o ideal ainda seria utilizando o jndiName no datasource, deve ser alguma configuração faltando?

dataSource(org.springframework.jndi.JndiObjectFactoryBean) {
jndiName = &quot;mysqlDS&quot;
jndiTemplate = ref(&quot;jndiTemp&quot;)
}
18/06/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