2 Replies Latest reply on Aug 23, 2007 8:52 AM by Arnie Morein

    SessionFactory in java:namespace - not bound?!

    Arnie Morein Newbie

      I'm deploying a .har alongside my .war in an .ear. My session factory is using a secured data source (security-domain) as shown below:

      <datasources>
       <!-- connection to appsec -->
       <local-tx-datasource>
       <jndi-name>us/tx/state/oag/dev/ApplicationSecurity</jndi-name>
       <connection-url>jdbc:jtds:sybase://sydev1a:9000/application_security</connection-url>
       <driver-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</driver-class>
       <security-domain>WebAppDomainDevApplicationSecurity</security-domain>
       <min-pool-size>3</min-pool-size>
       <max-pool-size>5</max-pool-size>
       <metadata>
       <type-mapping>Sybase</type-mapping>
       </metadata>
       </local-tx-datasource>
      
      


      The .har has the requisite class and hbm.xml files in it, along with the following jboss-service.xml file:

       <mbean code="org.jboss.hibernate.jmx.Hibernate"
       name="jboss.jca:service=HbmSessFacDevApplicationSecurity">
      
       <attribute name="DatasourceName">java:us/tx/state/oag/dev/ApplicationSecurity</attribute>
       <attribute name="Dialect">org.hibernate.dialect.SybaseDialect</attribute>
      
       <attribute name="SessionFactoryName">java:/hibernate/dev/ApplicationSecurity</attribute>
      
       <attribute name="CacheProviderClass">org.hibernate.cache.HashtableCacheProvider</attribute>
       <attribute name="ShowSqlEnabled">true</attribute>
      
       <!-- I added this to get scanning of mapping files in JARs -->
       <attribute name="ScanForMappingsEnabled">true</attribute>
      
       <!-- we need the DataSource deployed before Hibernate deploys -->
       <depends>jboss.jca:name=us/tx/state/oag/dev/ApplicationSecurity,service=DataSourceBinding</depends>
       <depends>jboss.jca:service=RARDeployer</depends>
      
       </mbean>
      


      Things are being deployed and setup correctly (I think...)


      15:09:51,812 INFO [SessionFactoryImpl] building session factory
      15:09:53,406 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
      15:09:53,406 INFO [NamingHelper] JNDI InitialContext properties:{}
      15:09:53,484 INFO [Hibernate] SessionFactory successfully built and bound into JNDI [java:/hibernate/dev/ApplicationSecurity]


      The session factory is showing up in the JNDI view thusly:


      java: Namespace

      +- SecurityProxyFactory
      +- us
      | +- tx
      | | +- state
      | | | +- oag
      | | | | +- dev
      | | | | | +- Common
      | | | | | +- ApplicationSecurity
      | | | | | +- Workflows
      | | | | | +- EmployeeWarehouse
      | | | | +- prd
      | | | | | +- Common
      | | | | | +- ApplicationSecurity
      | | | | | +- DpsLicenses
      +- comp
      +- jaas
      | +- WebAppDomainPrdDpsLicenses
      | +- WebAppDomainDevCommon
      | +- WebAppDomainDevApplicationSecurity
      | +- WebAppDomainPrdCommon
      | +- WebAppDomainDevEmployeeWarehouse
      | +- WebAppDomainDevWorkflows
      | +- WebAppDomainPrdApplicationSecurity
      +- timedCacheFactory
      Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy
      +- TransactionPropagationContextExporter
      +- Mail
      +- TransactionPropagationContextImporter
      +- TransactionManager
      +- hibernate
      | +- dev
      | | +- ApplicationSecurity
      | | +- Common
      | | +- Workflows
      | | +- EmployeeWarehouse
      | +- prd
      | | +- ApplicationSecurity
      | | +- Common
      | | +- DpsLicenses


      and yet the following code always gets the same error:

      ctx = new InitialContext();
      lo_result = (SessionFactory)ctx.lookup("java:/hibernate/dev/ApplicationSecurity");
      



      15:15:28,468 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
      15:15:28,468 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
      15:15:28,468 ERROR [STDERR] at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
      15:15:28,468 ERROR [STDERR] at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
      15:15:28,468 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
      15:15:28,468 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
      15:15:28,468 ERROR [STDERR] at javax.naming.InitialContext.lookup(InitialContext.java:351)
      15:15:28,468 ERROR [STDERR] at us.tx.state.oag.util.jsf.BaseBean.getSessionFactory(BaseBean.java:72)
      15:15:28,468 ERROR [STDERR] at us.tx.state.oag.OagPortalRegistration.AuthenticationBean.authenticateUser(AuthenticationBean.java:125)
      15:15:28,468 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      15:15:28,468 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      15:15:28,468 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      15:15:28,468 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
      15:15:28,468 ERROR [STDERR] at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
      15:15:28,468 ERROR [STDERR] at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
      15:15:28,468 ERROR [STDERR] at javax.faces.component.UICommand.broadcast(UICommand.java:109)
      15:15:28,468 ERROR [STDERR] at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
      15:15:28,468 ERROR [STDERR] at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
      15:15:28,468 ERROR [STDERR] at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
      15:15:28,468 ERROR [STDERR] at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
      15:15:28,468 ERROR [STDERR] at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
      15:15:28,468 ERROR [STDERR] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
      15:15:28,468 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      15:15:28,468 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      15:15:28,468 ERROR [STDERR] at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:100)
      15:15:28,468 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      15:15:28,468 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      15:15:28,468 ERROR [STDERR] at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
      15:15:28,468 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      15:15:28,468 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      15:15:28,468 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      15:15:28,468 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      15:15:28,468 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      15:15:28,468 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      15:15:28,468 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      15:15:28,468 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      15:15:28,468 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      15:15:28,468 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      15:15:28,468 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      15:15:28,468 ERROR [STDERR] at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
      15:15:28,468 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      15:15:28,468 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      15:15:28,468 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      15:15:28,468 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      15:15:28,468 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      15:15:28,468 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      15:15:28,468 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)


      I just don't see how this can be happening. Is there some kind of odd security constraint put on things when they are deployed in an .ear?