JNDI-DataSource mit Tomcat 6 und Eclipse
Ich kann nicht mein DataSource arbeiten mit JNDI und Tomcat 6, beim ausführen aus Eclipse heraus. Ich habe ein context.xml zu meinem /META-INF mit dem folgenden Inhalt:
<Context>
<Resource name="jdbc/myDB" auth="Container" type="javax.sql.DataSource"
username="root"
password="root"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/database"
maxActive="15"
maxIdle="7"
validationQuery="Select 1" />
</Context>
Konfiguriert und mein Spring-Bean wie folgt:
<bean id="UserDatabase" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/myDB"></property>
<property name="lookupOnStartup" value="true"></property>
<property name="cache" value="true"></property>
<property name="proxyInterface" value="javax.sql.DataSource"></property>
</bean>
Außerdem habe ich diese Zeilen zu meiner web.xml:
<resource-ref>
<description>Connection Pool</description>
<res-ref-name>jdbc/myDB</res-ref-name>
<res-type>javax.sql.Datasource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Aber aus irgendeinem Grund bekomme ich noch diese Fehlermeldung:
javax.naming.NameNotFoundException: The name jdbc is not associated to this context
at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)
Ich kann nicht verstehen, warum das nicht funktioniert... keine Ahnung?
Du musst angemeldet sein, um einen Kommentar abzugeben.
Ich habe die folgende und jetzt funktioniert es:
In meinem context.xml abgeschlossen
Context
tag mit:Und in der Verbindungs-URL den Charakter
&
verursacht dieCannot create resource
Fehler, weiß nicht warum, also meine URL ist jetzt wie:Bitte beachten Sie die
&
int die URL...Wenn ich mich richtig erinnere sollten Sie zugreifen
Im Frühjahr appcontext, tauschen Sie Ihre definition mit: