论坛首页 入门技术论坛

找不到 数据源 ,高手来帮着看看,多谢了

浏览 3073 次
该帖已经被评为新手帖
作者 正文
   发表时间:2006-12-05  
我用jboss4.04GA  +  hibernate  +sqlserver2005  做 sar

其中sqlserver2005-ds.xml如下

<?xml version="1.0" encoding="UTF-8"?>

<datasources>
  <local-tx-datasource>
    <jndi-name>SqlServer2005DS</jndi-name>
    <connection-url>jdbc:sqlserver://192.168.0.1:1433;databaseName=Test</connection-url>
    <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
    <user-name>sa</user-name>
    <password>sa</password>
      <metadata>
         <type-mapping>MS SQLSERVER2005</type-mapping>
      </metadata>
  </local-tx-datasource>

</datasources>



sar下面的META-INF下的jboss-service.xml如下


<?xml version="1.0" encoding="UTF-8"?>
<server>

<mbean code="org.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactory,name=HibernateFactory">

    <depends>jboss.jca:service=RARDeployer</depends>
    <depends>jboss.jca:name=SqlServer2005DS,service=LocalTxCM</depends>

    <attribute name="JndiName">java:/hibernate/SessionFactory</attribute>

    <attribute name="Datasource">java:/SqlServer2005DS</attribute>
    <attribute name="Dialect">org.hibernate.dialect.SQLServerDialect</attribute>

    <attribute name="TransactionStrategy">org.hibernate.transaction.JTATransactionFactory</attribute>
    <attribute name="TransactionManagerLookupStrategy">org.hibernate.transaction.JBossTransactionManagerLookup</attribute>
    <attribute name="FlushBeforeCompletionEnabled">true</attribute>
    <attribute name="AutoCloseSessionEnabled">true</attribute>

    <attribute name="MaximumFetchDepth">5</attribute>

    <attribute name="SecondLevelCacheEnabled">true</attribute>
    <attribute name="CacheProviderClass">org.hibernate.cache.EhCacheProvider</attribute>
    <attribute name="QueryCacheEnabled">true</attribute>

    <attribute name="ShowSqlEnabled">true</attribute>

    <attribute name="MapResources">test/po/Customer.hbm.xml</attribute>

</mbean>

</server>



但是就是找不到 数据源
看 网上高人 zhjjava的 文章
http://www.javaworld.com.tw/jute/post/view?bid=9&id=129747&sty=1&tpg=1&age=0
中提到相似问题
说要在war工程的WEB-INF目录下做一个 jboss-web.xml
按其方法 做了
但是仍然不能找到 数据源
那位高人 曾做过相关东西 或者 解决过类似问题 帮我看看 是哪里出的毛病
多谢了
   发表时间:2006-12-05  
错误贴在这里

11:30:47,617 FATAL [DatasourceConnectionProvider] Could not find datasource:
a:/SqlServer2005DS
javax.naming.NameNotFoundException: SqlServer2005DS not bound
        at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
        at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
        at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
        at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
        at javax.naming.InitialContext.lookup(InitialContext.java:351)
        at org.hibernate.connection.DatasourceConnectionProvider.configure(Da
ourceConnectionProvider.java:52)
        at org.hibernate.connection.ConnectionProviderFactory.newConnectionPr
der(ConnectionProviderFactory.java:124)
        at org.hibernate.connection.ConnectionProviderFactory.newConnectionPr
der(ConnectionProviderFactory.java:56)
        at org.hibernate.cfg.SettingsFactory.createConnectionProvider(Setting
ctory.java:397)
        at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.ja
62)
        at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1
)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.
a:1216)
        at org.hibernate.jmx.HibernateService.buildSessionFactory(HibernateSe
ce.java:64)
        at org.hibernate.jmx.HibernateService.start(HibernateService.java:40)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorIm
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAc
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispa
er.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvok
java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:65
        at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceCont
ler.java:995)
        at $Proxy0.start(Unknown Source)
        at org.jboss.system.ServiceController.start(ServiceController.java:41
        at org.jboss.system.ServiceController.start(ServiceController.java:43
        at org.jboss.system.ServiceController.start(ServiceController.java:43
        at org.jboss.system.ServiceController.start(ServiceController.java:43
        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAc
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispa
er.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvok
java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:65
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy4.start(Unknown Source)
        at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorIm
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAc
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispa
er.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterc
or.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(Mod
BeanOperationInterceptor.java:142)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvok
java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:65
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy42.start(Unknown Source)
        at org.jboss.deployment.XSLSubDeployer.start(XSLSubDeployer.java:197)
        at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1007)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:808)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
        at sun.reflect.GeneratedMethodAccessor55.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAc
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispa
er.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterc
or.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(Mod
BeanOperationInterceptor.java:142)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvok
java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:65
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy8.deploy(Unknown Source)
        at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploy
tScanner.java:421)
        at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeployme
canner.java:634)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThre
doScan(AbstractDeploymentScanner.java:263)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner.startServic
bstractDeploymentScanner.java:336)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBe
upport.java:289)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(Servic
eanSupport.java:245)
        at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAc
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispa
er.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvok
java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:65
        at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceCont
ler.java:978)
        at $Proxy0.start(Unknown Source)
        at org.jboss.system.ServiceController.start(ServiceController.java:41
        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAc
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispa
er.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvok
java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:65
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy4.start(Unknown Source)
        at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
        at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1007)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:808)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:755)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorIm
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAc
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispa
er.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterc
or.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(Mod
BeanOperationInterceptor.java:142)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvok
java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:65
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy5.deploy(Unknown Source)
        at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
        at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
        at org.jboss.Main.boot(Main.java:200)
        at org.jboss.Main$1.run(Main.java:464)
        at java.lang.Thread.run(Thread.java:595)


数据源本身绑定
11:30:47,967 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager 'jb
oss.jca:service=DataSourceBinding,name=SqlServer2005DS' to JNDI name 'java:SqlSe
rver2005DS'


数据源已经绑定
但是问题就在这里
是在service加载之后才绑定的

如何让service在数据源绑定后 才加载 或者让数据源先绑定

或者其他方法
望高手告知
多谢

0 请登录后投票
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics