Announcement Announcement Module
Collapse
No announcement yet.
Always get a javax.naming.NameNotFoundException why? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Always get a javax.naming.NameNotFoundException why?

    Running Glassfish 2.1, I'm always getting this error:

    Caused by: javax.naming.NameNotFoundException: SimpleUsageTrackingDatasource not found
    at com.sun.enterprise.naming.TransientContext.doLooku p(TransientContext.java:216)
    at com.sun.enterprise.naming.TransientContext.lookup( TransientContext.java:188)
    at com.sun.enterprise.naming.SerialContextProviderImp l.lookup(SerialContextPr
    here is my spring config xml:
    <jee:jndi-lookup id="SimpleUsageTrackingDatasource"
    jndi-name="SimpleUsageTrackingDatasource"
    resource-ref="false" />
    here is my web.xml:
    <resource-ref>
    <res-ref-name>SimpleUsageTrackingDatasource</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    and here is my sun-web.xml in my web-inf dir:
    <sun-web-app error-url="">
    <resource-ref>
    <res-ref-name>SimpleUsageTrackingDatasource</res-ref-name>
    <jndi-name>jdbc/SimpleUsageTrackingDatasource</jndi-name>
    </resource-ref>
    And finally, yes, I do have a datasource named visible jdbc/SimpleUsageTrackingDatasource in the JNDI browser of Glassfish. I'm completely stuck. Why can't I ever resolve this?
    Last edited by cj91; Mar 16th, 2009, 04:42 PM.

  • #2
    Hey,
    I've got exactly the same problem. Have you found any solution?

    Comment


    • #3
      unfortunately no.

      It's turns out it's a problem with glassfish 2.1 not honoring the sun-web.xml nor the context.xml. I never found a workaround.

      Comment


      • #4
        Dude, I just found out it actually works. I've had this problem with a SLSB, not a datasource but I guess it's the same issue, I've had the same exception:

        Code:
        Caused by: javax.naming.NameNotFoundException: xxx not found
        at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
        Technically speaking I still have it, but the reference is set anyway. Here's my config:

        web.xml:
        Code:
        	<ejb-local-ref id="ejb_testmanager">
        		<ejb-ref-name>ejb/TestManager</ejb-ref-name>
        		<ejb-ref-type>Session</ejb-ref-type>
        		<local>yyy.test.TestManager</local>
        	</ejb-local-ref>
        applicationContext.xml:
        Code:
        	<jee:jndi-lookup id="xxxx" jndi-name="java:comp/env/ejb/TestManager"/>
        java class, spring controller:
        Code:
        @Controller
        public class TestUIController {
         ...
        	private TestManager testManager;
        
        	@RequestMapping("/")
        	public String indexHandler() {
        		System.out.println("wtf: " + testManager);
        		
        		if (testManager != null) {
        			System.out.println("Wooohooo!");
        			testManager.GenerateSomeData();
        		}				
        		return "index";
        	}
         ...
        	@Resource(name="xxxx")
        	public void setTestManager(TestManager testManager) {
        		this.testManager = testManager;
        	}
        
        }
        And this is just fine. The indexHandler method generates some data.
        Yes, I've still got the NameNotFoundException exception from sun, but spring is just fine. I guess this is the first exception in my project I'll have to ignore, hope the last one :/ Maybe you've got a similar issue? HTH

        Kornel

        Comment


        • #5
          I think it works beacuse you put the complete lookup string in your spring config. If you put java:comp/env/ejb/TestManager in your web.xml you could probably get rid of the error.

          The problem is glassfish doesn't seem to support renaming or redirecting of jndi lookups inside ears/wars

          Comment


          • #6
            Thanks for your effort, Kornel. Your post did help me out of my Spring misery. Glassfish seems to be very complicated, I'll have to practice a lot.

            Comment

            Working...
            X