Na expectativa de melhorar o desempenho ao acesso no BD eu comecei a implementar um pool de conexões dentro da minha Aplicação web. Porém sempre que vou dar um lookup na aplicação me ocorre o seguinte erro
javax.naming.NameNotFoundException: Name [jdbc/bolsa] is not bound in this Context. Unable to find [jdbc]. at org.apache.naming.NamingContext.lookup(NamingContext.java:818) at org.apache.naming.NamingContext.lookup(NamingContext.java:166) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:157) at javax.naming.InitialContext.lookup(InitialContext.java:417) at Filtro.Filtro.doFilter(Filtro.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206 ....(continua)
Ao procura vários QeA e tutoriais eu acabei implementando os arquivos do Tomcat
da seguinte maneira
server.xml
<GlobalNamingResources>
<Resource name="jdbc/bolsa" auth="Container" type="javax.sql.DataSource"
maxTotal="100" maxIdle="30" maxWaitMillis="10000"
username="root" password="" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/bolsa"/>
</GlobalNamingResources>
context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/zk_login">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<ResourceLink global="jdbc/bolsa" name="jdbc/bolsa" type="javax.sql.DataSource" />
<Resource name="jdbc/bolsa" auth="Container" type="javax.sql.DataSource"
maxTotal="100" maxIdle="30" maxWaitMillis="10000"
username="root" password="" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/bolsa"/>
</Context>
Já dentro do meu sistema
eu o persistence.xml ficou da seguinte maneira
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="bolsa" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>java:comp/env/jdbc/bolsa</non-jta-data-source>
<class>bean.Permissao</class>
<class>bean.Usuario</class>
<class>bean.Pagina</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
<property name="hibernate.show_sql" value="true"/>
<!-- dados da conexao -->
<!-- propriedades do hibernate -->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
<property name="hibernate.format_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>
e o web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<description>MySQL Test App</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/bolsa</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
Como posso configurar o meu servidor ou se estou minha chamada esta errada e como posso solucionar esse problema.
Infelizmente eu ja olhei vários tutoriais e video mas nenhum dele funcionou :/
<Resource ..... />
do context.xml não funciona?