6
votes

RAD 7, WebSphere 7.

ibm-web-bnd.xml:

<resource-ref name="jdbc/devl" binding-name="jdbc/devl" />

web.xml:

<resource-ref>
  <res-ref-name>jdbc/devl</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Application</res-auth>
  <res-sharing-scope>Unshareable</res-sharing-scope>
  <mapped-name>jdbc/devl</mapped-name>
</resource-ref>

This conforms to the examples I see on the internet. This comes up because I am converting this app to servlet 2.5. As I understand it, the res-ref-name in web.xml should match the name attribute in resource-ref. The binding-name then matches the datasource defined in the admin console. To make it simple, I made them all match.

Is there another setting somewhere? Because this produces the error described in the title of the question.

2
Yes, the <resource-ref name="..."> should match the <res-ref-name> (and the binding-name="..." should match the data source name, but that would be a different error). I'm not sure what's wrong. Can you update your question with the full error message? Perhaps there is a hint in the error message.Brett Kail
@bkail - Actually, that IS the full message. It's an XML validation error. If I run with errors I get a regular jndi "what the heck is this" type exception. Like so: javax.naming.NameNotFoundException: Name "comp/env/devl" not found in context "java:".Entropy
@bkail - I am able to make the XML validation error go away, but the jndi exception remains. I found some config files related to the project facet that thought the project was still in servlet 2.2. I thought just changing the web.xml and the .xmi's into xmls accomplished this. Are there other settings I am missing?Entropy
If you can include the full error message (with timestamp, component, message ID, etc.) or exception (with full stack trace, all caused by, etc.), then I can try to take a closer look. I'm familiar with the product internals, so sometimes I can give a better answer (or ask more direct questions) if I can see all the information.Brett Kail
Please attach full exception and also piece of code that does the lookup. As from the fragment of exception NameNotFoundException: Name "comp/env/devl" , the reference name is dev1 not jdbc/dev1 if you pasted it correctly...Gas

2 Answers

1
votes

If you are using Eclipse, try to update the web module version in project.facet.core.xml. It should be in synch with the web.xml web-app version.

1
votes

I have the same issue many times. It disappeared when I closed the eclipse and when I reopened it I made a "project -> clean". I hope it works for the next person who has this error. enter image description here

Also make sure you have the web.xml header updated to 2.5 or higher (3.0).This is related to the facets of the project, make sure they are with the same version enter image description here

if it doesn't let you change it, you should change it in this file : "org.eclipse.wst.common.project.facet.core.xml"

If the error continues, you should generate the binding file again. Make sure you have the correct server settings in the facets of the project enter image description here

To generate the file you must do it from java EE Tools. enter image description here

Remember that ibm-web-bnd.xml and web.xml must be in the same directory

Build, and clean project.