Configuring JNDI in Tomcat requires writing a context.xml and put it in the META-INF directory of your application or can be put in the servere.xml file in conf directory of Tomcat server
For datasource, the context.xml looks like
<Context>
<Resource name="jdbc/dbConnection"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="j<url to database>"
username="user"
password="pwdt"
validationQuery="select 1"
removeAbandoned="true"
removeAbandonedTimeout="120"
maxWait="60"
maxActive="20"
maxIdle="10" />
</Context>
For connecting to mail server. (Resource element to be put inside the Context element).
<Resource
name="mail/Session"
auth="Container"
type="javax.mail.Session"
mail.transport.protocol="smtp"
mail.smtp.host="<Server name>"
mail.smtp.port="25" />
For JMS connection. (Resource element to be put inside the Context element).
<Resource
name="jms/ConnectionFactory"
auth="Container"
type="org.apache.activemq.ActiveMQConnectionFactory"
description="JMS Connection Factory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL="vm://localhost"
brokerName="LocalActiveMQBroker" />
No comments:
Post a Comment