A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Products
»
Other Java Products and Servers
Author
InjectionException
Chetan Raju
Ranch Hand
Joined: Aug 02, 2006
Posts: 109
posted
Aug 07, 2008 05:22:00
0
Hello All,
I have deployed a
servlet
on Sun Java System App Server 9.1. The code snippet for the problem area is
public class GreetingServlet extends HttpServlet { [B] @Resource DataSource myDB //already imported javax.sql.DataSource[/B] @Override public void doGet( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { response.setContentType("text/html"); response.setBufferSize(8192); PrintWriter out = response.getWriter(); Connection con = myDB.getConnection();
I am getting a
com.sun.enterprise.InjectionException: Exception attempting to inject Res-Ref-Env-Property: servlets.GreetingServlet/myDB@javax.sql.DataSource@ resolved as: jndi: servlets.GreetingServlet/myDB@res principal: null@mail: null
I am trying to connect to a MySQL database instance. I have also configured the web.xml for the resource which is a
DataSource
<resource-ref> <res-ref-name>myDB</res-ref-name> <jndi-name>myDB</jndi-name> <res-ref-type>javax.sql.DataSource</res-ref-type> </resource-ref>
What could be the problem ? Can anyone help ?
David O'Meara
Rancher
Joined: Mar 06, 2001
Posts: 13459
I like...
posted
Aug 07, 2008 05:57:00
0
Please don't post the same question in multiple forums. It creates duplicate conversations and wastes the time of the people trying to help you.
Thanks,
Dave
I agree. Here's the link:
http://zeroturnaround.com/jrebel
subject: InjectionException
Similar Threads
Retrieving datasource from jndi in java studio creator
InjectionException
InjectionException
Errored while looking up datasource: PWC4216: Name jdbc is not bound in this Context
Stateless EBJ using JNDI to get DataSource with JBOSS 4.2
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter