开发者

Hibernate JBOSS JNDI Configuration

Currently I have an application that is configured for Hibernate and JNDI but runs on a Tomcat server. I have been tasked with moving this web application to JBOSS 5.1. I have done the following so far:

  1. Removed hibernate-3.2.1.ga.jar, hibernate-annotations-3.3.0.ga.jar, and hibernate-commons-annotations-3.3.0.ga.jar from the web application that I want to deploy.
  2. I have added ojdbc.5 jar to the /default/conf/lib directory.

I have the following web application files configured as so:

FILE1:hibernate.cfg.xml

<hibernate-configuration>
    <session-factory>
          <property name="hibernate.connection.datasource">java:comp/env/jdbc/ldcDataSource</property>
          <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
          <property name="hibernate.current_session_context_class">thread</property>
          <property name="hibernate.show_sql">true</property>
          <property name="hibernate.format_sql">true</property>
          <property name="hibernate.flushMode">COMMIT</property>
        ........
      </session-factory>
</hibernate-configuration>

FILE2:/META-INF/context.xml

<Context path="/ldc" debug="0" >

    <!-- Link to the user database we will get roles from -->
    <ResourceLink name="jdbc/ldcDataSource" global="jdbc/ldcDataSource"
                  type="javax.sql.DataSource"/>

    <ResourceLink name="jdbc/paybaseDataSource" global="jdbc/paybaseDataSource"
                  type="javax.sql.DataSource"/>
</Context>

FILE3:/WEB-INF/web.xml

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
     version="2.4">


   <resource-ref>
        <description>LDC Data Source</description>
        <res-ref-name>jdbc/ldcDataSource</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
   </resource-ref>

FILE4: /WEB-INF/jboss-web.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
    <resource-ref>
        <res-ref-name>jdbc/ldcDataSource</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <jndi-name>java:ldcDataSource</jndi-name>
    </resource-ref>

    <resource-ref>
        <res-ref-name>jdbc/paybaseDataSource</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <jndi-name>java:paybaseDataSource</jndi-name>
    </resource-ref>
</jboss-web>

In my deploy folder for jboss I have the datasource configured as so (url and password leftout):

File1: /deploy/ldcDataSource-ds.xml

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
  <local-tx-datasource>
    <jndi-name>jdbc/ldcDataSource</jndi-name>
     <use-java-context>true</use-java-context>
    <connection-url>***</connection-url>
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    <user-name>***</user-name>
    <password>***</password>
    <min-pool-size>5</min-pool-size>
    <max-pool-size>100</max-pool-size>
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
      <metadata>
         <type-mapping>Oracle11g</type-mapping>
      </metadata>
  </local-tx-datasource>
</datasources>

The error that I am currently receiving is the following:

ERROR [org.hibernate.connection.DatasourceConnectionProvider] (main) Could not find datasource: java:comp/env/jdbc/ldcDataSource
javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: ldcDataSource not bound]
 at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1352)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:817)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:833)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
 at javax.naming.InitialContext.lookup(InitialContext.java:392)
 at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75)
 at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137)
 at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:79)
 at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:448)
 at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89)
 at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325)
 at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
 at com.everbank.uft.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:24)
 at com.everbank.uft.util.HibernateUtil.<clinit>(HibernateUtil.java:19)
 at com.everbank.uft.filters.HibernateSessionRequestFilter.init(HibernateSessionRequestFilter.java:70)
 at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:234)
 at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:332)
 at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:90)
 at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3783)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4413)
 at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:310)
 at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:142)
 at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)
 at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
 at org.jboss.web.deployers.WebModule.start(WebModule.java:97)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
 at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
 at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)
 at $Proxy38.start(Unknown Source)
 at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)
 at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)
 at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
 at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
 at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
 at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
 at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)
 at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
 at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
 at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
 at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
 at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
 at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
 at org.jboss.system.ServiceController.doChange(ServiceController.java:688)
 at org.jboss.system.ServiceController.start(ServiceController.java:460)
 at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163)
 at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99)
 at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)
 at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
 at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
 at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
 at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
 at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
 at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
 at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
 at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
 at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
 at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
 at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
 at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
 at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
 at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
 at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
 at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
 at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
 at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
 at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
 at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)
 at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
 at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
 at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
 at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
 at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
 at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
 at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
 at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)
 at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)
 at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
 at org.jboss.Main.boot(Main.java:221)
 at org.jboss.Main$1.run(Main.java:556)
 at java.lang.Thread.run(Thread.java:662)
Caused by: javax.naming.NameNotFoundException: ldcDataSource not bound
 at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
 at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
 at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
 at org.jnp.server.NamingServer.lookup(NamingServer.java:443)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
 at javax.naming.InitialContext.lookup(InitialContext.java:392)
 at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1346)
 ... 87 more
2011-01-25 16:32:59,276 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/ldc]] (main) Exception starting filter HibernateSessionRequestFilter
java.lang.ExceptionInInitializerError
 at com.everbank.uft.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:30)
 at com.everbank.uft.util.HibernateUtil.<clinit>(HibernateUtil.java:19)
 at com.everbank.uft.filters.HibernateSessionRequestFilter.init(HibernateSessionRequestFilter.java:70)
 at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:234)
 at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:332)
 at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:90)
 at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3783)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4413)
 at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:310)
 at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:142)
 at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)
 at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
 at org.jboss.web.deployers.WebModule.start(WebModule.java:97)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
 at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
 at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)
 at $Proxy38.start(Unknown Source)
 at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)
 at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)
 at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
 at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
 at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
 at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
 at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)
 at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
 at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
 at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
 at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
 at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
 at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
 at org.jboss.system.ServiceController.doChange(ServiceController.java:688)
 at org.jboss.system.ServiceController.start(ServiceController.java:460)
 at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163)
 at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99)
 at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)
 at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
 at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
 at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
 at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
 at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
 at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
 at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
 at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
 at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
 at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
 at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
 at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
 at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
 at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
 at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
 at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
 at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
 at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
 at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
 at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)
 at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
 at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
 at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
 at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
 at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
 at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
 at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
 at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)
 at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)
 at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
 at org.jboss.Main.boot(Main.java:221)
 at org.jboss.Main$1.run(Main.java:556)
 at java.lang.Thread.run(Thread.java:662)
Caused by: org.hibernate.HibernateException: Could not find datasource
 at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:79)
 at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137)
 at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:79)
 at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:448)
 at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89)
 at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325)
 at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
 at com.everbank.uft.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:24)
 ... 74 more
Caused by: javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: ldcDataSource not bound]
 at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1352)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:817)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:833)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
 at javax.naming.InitialContext.lookup(InitialContext.java:392)
 at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75)
 ... 82 more
Caused by: javax.naming.NameNotFoundException: ldcDataSource not bound
 at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
 at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
 at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
 at org.jnp.server.NamingServer.lookup(NamingServer.java:443)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
 at javax.naming.InitialContext.lookup(InitialContext.java:392)
 at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1346)
 ... 87 more
2011-01-25 16:32:59,308 ERROR [org.apache.catalina.core.StandardContext] (main) Error filterStart
2011-01-25 16:32:59,308 ERROR [org.apache.catalina.core.StandardContext] (main) Context [/ldc] startup failed due to previous errors
2011-01-25 16:32:59,308 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (main) Error installing to Start: name=jboss.web.deployment:war=/ldc state=Create mode=Manual requiredState=Installed
org.jboss.deployers.spi.DeploymentException: URL file:/C:/jboss-5.1.0.GA/server/default/deploy/ldc.war/ deployment failed
 at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:331)
 at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:142)
 at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)
 at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
 at org.jboss.web.deployers.WebModule.start(WebModule.java:97)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
 at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
 at org.jboss.system.microco开发者_运维技巧ntainer.ServiceProxy.invoke(ServiceProxy.java:206)
 at $Proxy38.start(Unknown Source)
 at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)
 at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)
 at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
 at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
 at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
 at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
 at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)
 at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
 at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
 at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
 at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
 at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
 at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
 at org.jboss.system.ServiceController.doChange(ServiceController.java:688)
 at org.jboss.system.ServiceController.start(ServiceController.java:460)
 at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163)
 at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99)
 at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)
 at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
 at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
 at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
 at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
 at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
 at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
 at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
 at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
 at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
 at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
 at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
 at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
 at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
 at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
 at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
 at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
 at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
 at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
 at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
 at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)
 at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
 at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
 at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
 at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
 at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
 at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
 at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
 at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)
 at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)
 at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
 at org.jboss.Main.boot(Main.java:221)
 at org.jboss.Main$1.run(Main.java:556)
 at java.lang.Thread.run(Thread.java:662)
2011-01-25 16:32:59,355 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (main) Error installing to Real: name=vfsfile:/C:/jboss-5.1.0.GA/server/default/deploy/ldc.war/ state=PreReal mode=Manual requiredState=Real
org.jboss.deployers.spi.DeploymentException: URL file:/C:/jboss-5.1.0.GA/server/default/deploy/ldc.war/ deployment failed


Your jboss-web.xml file is referencing the wrong JNDI name. Your ldcDataSource-ds.xml data source file specifies this JNDI name:

 <jndi-name>jdbc/ldcDataSource</jndi-name>

However, your jboss-web.xml file references it as such:

<jndi-name>java:ldcDataSource</jndi-name>

Change your jboss-web.xml file so it is as follows:

<jndi-name>java:jdbc/ldcDataSource</jndi-name>

That should correct the issue. Also, @skaffman is correct that you do not need to use the comp/env if you don't want to, but by specifying your resource-ref within the WAR's web.xml file, your webapp will not deploy unless the necessary resources are found.

The data source file binds the provided resource-ref to a JNDI name. Your web.xml file specifies that your webapp requires a specific resource-ref name. What ties these together is the jboss-web.xml which ties a specific resource-ref to a JNDI name and makes it available under java:comp/env/{res-ref-name}.

This is the proper way to do it. Good luck!


Adding following to the *-ds.xml , worked for me.

It make your datasource available to the Global JNDI namespace in JBOSS

<use-java-context>false</use-java-context>


Why are you configuring Hibernate to use

java:comp/env/jdbc/ldcDataSource

You're not using EJBs here, you shouldn't need all that comp/env rubbish.

Try just java:jdbc/ldcDataSource instead, since that what your -ds.xml file is configured to expose.


I have used for hibernate Jboss JNDI configuration like:

I created the JNDI Name in standalone.xml file of jboss

<datasource jta="false" jndi-name="java:jboss/datasources/mydatasource" pool-name="mydatasource" enabled="true" use-ccm="false">

configure connection for database:

<connection-url>jdbc:mysql://localhost:3306/MyDB</connection-url>
                <driver-class>com.mysql.jdbc.Driver</driver-class>
                <driver>mysql</driver>
                <security>
                    <user-name>root</user-name>
                    <password>root</password>
                </security>
            </datasource>

configure drive class for database:

<drivers>
                <driver name="h2" module="com.h2database.h2">
                    <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                </driver>
                <driver name="mysql" module="com.mysql">
                    <xa-datasource-class>com.mysql.jdbc.Driver</xa-datasource-class>
                </driver>
            </drivers>


Adding following tag with false value to the *-ds.xml , worked for me.

It make your datasource available to the Global JNDI namespace in JBOSS "use-java-context"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜