3 Replies Latest reply on May 4, 2004 11:44 PM by artsi

    LoginModule & hibernate & jndi datasource.

    artsi

      Hi!

      I try to write my own LoginModule, where i user hiberante.
      I have wrote datasource, put it to deploy directory, and it works fine with hibernate, i try to lookup it in my login module, and i find it. But when i try to use hibernate in my login module, it throws following:

      net.sf.hibernate.HibernateException: Could not find datasource
      at net.sf.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:48)
      at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:83)
      at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:64)
      at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1091)
      at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:737)


      Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:
      java.naming.factory.initial
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
      at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)


      Any hints?!??

      Artsi

        • 1. Re: LoginModule & hibernate & jndi datasource.
          artsi

          I changed hibernate's DatasourceConnectionProvider's code to list all object's from JNDI, and it was empy, then i tried these properties:

          p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
          p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
          p.put(Context.PROVIDER_URL, "localhost:1099");

          .. and i got my bean's and some other stuff, but no that datasource.
          But anyway, does someone know why i got different Context's in my LoginModule and DatasourceConnectionProvider?!??

          Artsi

          • 2. Re: LoginModule & hibernate & jndi datasource.
            omni

            I am going through the same thing, the JAAS howto is not very specific on how best to implement this.

            I wish jBoss would make a step-by-step for this issue.

            ---Jason

            • 3. Re: LoginModule & hibernate & jndi datasource.
              artsi

              Hi Jason.

              I'm quite newbie with JAAS, and in my situtation the problem was, that i didn't known that in standalone client LoginModule is driven in client, not in server (very innovative idea!). That's why jndi couldn't find datasource.
              Anyway i think that there is quite little information at standalone client's, and this information i got some old JBoss book. I think it was JBoss Development & Administration or something like that.

              Artsi