JBOSS,datasource,But In the init() mothod couldn't lookup datasource.
2005-10-13 13:55
519 查看
各位好!
以下是我发布到jboss.org,theserverside.com,javaworld.com等论坛上的求助问题的帖子,竟然没有人回答我,很郁闷。
问题是:我配置的数据源绝对没有问题,可是我在StartupServlet的init方法中就是不能lookup到datasource,而一旦JBOSS启动完毕,程序就能正常lookup到datasource!我需要在系统启动时从数据库中读出数据来进行初始化。
在javaworld.com.tw的论坛上贴了一次后,还有个台胞答复我了,真是一家人,哈哈。老外大大的坏!我还在那些国外论坛上回复了几个帖子呢,娘的。
JBOSS,datasource jndi,datasource's config should be correct!But In the init() mothod of HttpServlet's instance I could not lookup datasource.
Hi all!
env:
jboss3.26+linux+jdk1.4.2,DB:oracle9i
I met with a little matter in my project.
When I init the data in my startup-servlet,I can't lookup the datasource.
Datasource's config should be correct! I'm reffering to 'example/jca/oracle_ds.xml'
Thus once the web-app has deployed,it is normal for accessing the datasource! I'm worried and indignant.
Maybe some config was missing or wrong! Help me! thank u very very very much!
1、config datasource:
<!--test_oracle_ds.xml-->
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/test</jndi-name>
....
ps:config in web.xml and jboss-web.xml
<!--web.xml-->
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/test</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
==============================
<!--jboss-web.xml-->
<jboss-web>
<resource-ref>
<res-ref-name>jdbc/test</res-ref-name>
<jndi-name>java:/jdbc/test</jndi-name>
</resource-ref>
</jboss-web>
2、java code
StartupServlet.java:
init(..)
Context init = new javax.naming.InitialContext();
ctx = (Context) init.lookup("java:comp/env");
DataSource ds = (DataSource)ctx.lookup("jdbc/test");
or Context ctx = new javax.naming.InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:/jdbc/test");
or Context ctx = new javax.naming.InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/test");
All of this are fail,they give me the info: datasource no bound
more info :"javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: jdbc not bound]"
jdbc not bound: this jdbc must be refer to the "jdbc" of "<jndi-name>jdbc/test</jndi-name>",
as I have tested "<jndi-name>test</jndi-name>", then give me info- "test not bound".
The rather that when I read the log,I find the datasource has been bound to "java:/jdbc/test".
The state of datasource must be valid.
........
mbeans:
jboss.jca:service=LocalTxCM,name=jdbc/test state: Registered
jboss.jca:service=ManagedConnectionPool,name=jdbc/test state: Started
jboss.jca:service=ManagedConnectionFactory,name=jdbc/test state: Started
.....
.......
[org.jboss.web.tomcat.tc5.TomcatDeployer] Linking 'jdbc/test' to JNDI name: java:/jdbc/test
Thus once the web-app has deployed,it is normal for accessing the datasource! I'm worried and indignant.
I greatly appreciate your timely help.
The relative oracle jar(ojdbc14.jar) has been copied into "...server/all/lib".
I greatly appreciate your timely help.
以下是我发布到jboss.org,theserverside.com,javaworld.com等论坛上的求助问题的帖子,竟然没有人回答我,很郁闷。
问题是:我配置的数据源绝对没有问题,可是我在StartupServlet的init方法中就是不能lookup到datasource,而一旦JBOSS启动完毕,程序就能正常lookup到datasource!我需要在系统启动时从数据库中读出数据来进行初始化。
在javaworld.com.tw的论坛上贴了一次后,还有个台胞答复我了,真是一家人,哈哈。老外大大的坏!我还在那些国外论坛上回复了几个帖子呢,娘的。
JBOSS,datasource jndi,datasource's config should be correct!But In the init() mothod of HttpServlet's instance I could not lookup datasource.
Hi all!
env:
jboss3.26+linux+jdk1.4.2,DB:oracle9i
I met with a little matter in my project.
When I init the data in my startup-servlet,I can't lookup the datasource.
Datasource's config should be correct! I'm reffering to 'example/jca/oracle_ds.xml'
Thus once the web-app has deployed,it is normal for accessing the datasource! I'm worried and indignant.
Maybe some config was missing or wrong! Help me! thank u very very very much!
1、config datasource:
<!--test_oracle_ds.xml-->
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/test</jndi-name>
....
ps:config in web.xml and jboss-web.xml
<!--web.xml-->
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/test</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
==============================
<!--jboss-web.xml-->
<jboss-web>
<resource-ref>
<res-ref-name>jdbc/test</res-ref-name>
<jndi-name>java:/jdbc/test</jndi-name>
</resource-ref>
</jboss-web>
2、java code
StartupServlet.java:
init(..)
Context init = new javax.naming.InitialContext();
ctx = (Context) init.lookup("java:comp/env");
DataSource ds = (DataSource)ctx.lookup("jdbc/test");
or Context ctx = new javax.naming.InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:/jdbc/test");
or Context ctx = new javax.naming.InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/test");
All of this are fail,they give me the info: datasource no bound
more info :"javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: jdbc not bound]"
jdbc not bound: this jdbc must be refer to the "jdbc" of "<jndi-name>jdbc/test</jndi-name>",
as I have tested "<jndi-name>test</jndi-name>", then give me info- "test not bound".
The rather that when I read the log,I find the datasource has been bound to "java:/jdbc/test".
The state of datasource must be valid.
........
mbeans:
jboss.jca:service=LocalTxCM,name=jdbc/test state: Registered
jboss.jca:service=ManagedConnectionPool,name=jdbc/test state: Started
jboss.jca:service=ManagedConnectionFactory,name=jdbc/test state: Started
.....
.......
[org.jboss.web.tomcat.tc5.TomcatDeployer] Linking 'jdbc/test' to JNDI name: java:/jdbc/test
Thus once the web-app has deployed,it is normal for accessing the datasource! I'm worried and indignant.
I greatly appreciate your timely help.
The relative oracle jar(ojdbc14.jar) has been copied into "...server/all/lib".
I greatly appreciate your timely help.
相关文章推荐
- “You couldn’t see my tears cause I am in the water.“ Fish said to water.“But I could feel your tears cause you are in my heart..“ Answered water.
- com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException: This application is out of date, please click the refresh but
- django提交表单报错"You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SL
- You called this URL via POST, but the URL doesn't end in a slash and you hav。。。
- ReactJs 报错 Element type is invalid: expected a string (from built-in components) or a class/function (for composite components) but got: undefined. Check the render method of `Me`.
- The operation couldn’t be completed. Unable to log in with account ''
- iOS 上架Appstore被拒原因:PLA 3.3.12 We found that your app uses the Advertising but does not in
- 关于error:Cannot assign to 'self' outside of a method in the init family
- SPRING IN ACTION 第4版笔记-第十章Hitting the database with spring and jdbc-003-四种方式获取DataSource
- The goal you specified requires a project to execute but there is no POM in this directory
- Couldn't find host in the .netrc file问题解决
- ipad The data couldn’t be read because it isn’t in the correct format
- A class extends ArrayList, but the instance of the calss do not work in a complex case.
- Cannot assign to 'self' outside of a method in the init family
- java.lang.NullPointerException: Expected timestamp in the Flume event headers, but it was null
- java.lang.NullPointerException: Expected timestamp in the Flume event headers, but it was null
- 关于error:Cannot assign to 'self' outside of a method in the init family
- 关于error:Cannot assign to 'self' outside of a method in the init family
- java.lang.NullPointerException: Expected timestamp in the Flume event headers, but it was null
- MySQL5.7 启动报错:initialize specified but the data directory has files in it. Aborting.