Estoy tratando de definir dos orígenes de datos en mi aplicación web, utilizando el archivo jetty-env.xml
. Funciona bien con una sola fuente de datos, sin embargo consigo esta excepción cuando se añade la segunda fuente de datos:Definición de dos orígenes de datos en embarcadero (embarcadero-env.xml)
java.lang.IllegalStateException: Nothing to bind for name javax.sql.DataSource/default
Aquí está mi configuración:
muelle de una env.xml
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<New id="ds" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg>jdbc/mybd1</Arg>
<Arg>
<New class="com.mchange.v2.c3p0.ComboPooledDataSource">
<Set name="driverClass">com.microsoft.sqlserver.jdbc.SQLServerDriver</Set>
<Set name="jdbcUrl">jdbc:jtds:sqlserver://url:1433/mybd1</Set>
<Set name="user">xx</Set>
<Set name="password">yy</Set>
</New>
</Arg>
</New>
<New id="ds2" class="org.eclipse.jetty.plus.jndi.Resource" >
<Arg>jdbc/mybd2</Arg>
<Arg>
<New class="com.mchange.v2.c3p0.ComboPooledDataSource">
<Set name="driverClass">com.microsoft.sqlserver.jdbc.SQLServerDriver</Set>
<Set name="jdbcUrl">jdbc:jtds:sqlserver://url:1433/mybd2</Set>
<Set name="user">xx</Set>
<Set name="password">yy</Set>
</New>
</Arg>
</New>
</Configure>
web.xml
<resource-ref>
<res-ref-name>jdbc/mybd1</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<res-ref-name>jdbc/mybd2</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
hibernate.cfg.xml (hay otro hibernate.cfb.xml para configurar la segunda fuente de datos)
<session-factory>
<property name="connection.datasource">jdbc/mybd1</property>
<!-- ... -->
Alguna pista?
Gracias , pero obtengo el mismo error :( – polypiel
tuve un problema similar, y esto funcionó para mí. Pero ahora tengo otro problema m ... – Raedwald
jejeje ... ¿Alguna vez miró la construcción de jndi.Resource? Recurso (Object scope, String jndiName, Object objToBind) Recurso (String jndiName, Object objToBind) ... para que pueda utilizar igualmente tres parámetros con valores, vacío 1st param scope con otros dos params o solo dos params – Striker