Weblogic7.0,DataSource,ejb
Hi all ,
I am using weblogic 7.0
I need little bit clarification in the following points.
1) Does the connection pool which is created can be displayed in JNDI Tree???
I am seeing only DataSOurce in the JNDI Tree Only.
2)In case of Bean Managed Persistance, in ejb-jar.xml,
I had given the following info.
<resource-ref>
<res-ref-name>ramukkDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Does the <res-ref-name> refers to Datasource Name??
In weblogic-ejb-jar.xml
<reference-descriptor>
<resource-description>
<res-ref-name>ramukkDataSource</res-ref-name>
<jndi-name>ramukkpool</jndi-name>
</resource-description>
</reference-descriptor>
Here <jndi-name> refers to connection pool as per weblogic bible book.
If so when i deployed my ejb into the server iam getting Datasource cant be found.
If i had given like the following,
In ejb-jar.xml
<resource-ref>
<res-ref-name>jdbc/ramuJndi</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
In weblogic-ejb-jar.xml
<reference-descriptor>
<resource-description>
<res-ref-name>jdbc/ramuJndi</res-ref-name>
<jndi-name>jdbc/ramuJndi</jndi-name>
</resource-description>
</reference-descriptor>
Then only my ejb code is successfully deploying doing some work which is as per xpectation.
Can any body tell why I have to give the same name for <res-ref-name> n <jndi-name>??
I am working on this problem from last one week. Still not found the solution.
Connection Pool Creation
GENERAL::
Name : ramukkpool
url : jdbc:mysql://localhost:3306/test
Driver Classname: com.mysql.jdbc.Driver
Properties :
user = root
Password = XXX
createTARGETS::
i had shifted myServer from left side to right side n clicked >>Apply
(Techncially can we say this as deploying the connection pool into server ???????????
If not how to deploy the connection pool into server??)
I did not get any errors in the console.
Now i am creating a datasource
CONFIGURATION:
Name : ramukkDataSource
JNDIName: jdbc/ramuJndi(Does we have to follow this convention only?? i.e JNDIName should start with jdbc/ only)
PoolName: ramukkpool
createTARGETS::
I had shifed myServer from left to right n >>Apply.
Now also i did not get any errors in the console.
Thanx(in advance),
ramu
Hi Sujith,
Get the sample examples in bea\weblogic700\samples\server\src\examples\ejb20 folder.
Create a jar or war or ear file from the java files given in the folders.
Deploy the same in ur WLS Console.
Run the client program to test the same.
Seetesh
Similar Messages
-
Weblogic7/examples/clustering/ejb Automatic failover for idempotent methods ?
This one should be easy since it is from the examples folder of bea 7 about
clustering.
Ref : \bea7\weblogic007\samples\server\src\examples\cluster\ejb
I am referring to the cluster example provided with the weblogic server 7.0
on windows 2000.
I deployed Admin server and 2 managed server as described in document.
Everything works fine as shown by the example. I get load balancing and
failover both. Too Good.
Client.java is using the while loop to manage the failover. So on exception
it will go thru the loop again.
I understand from the documentation that the stateless session EJB will
provide the automatic failover for Idempotent stateless bean
Case Failover Idempotent : ( Automatic )
If methods are written in such a way that repeated calls to the same method
do not cause duplicate updates, the method is said to be "idempotent." For
idempotent methods, WebLogic Server provides the
stateless-bean-methods-are-idempotent deployment property. If you set this
property to "true" in weblogic-ejb-jar.xml, WebLogic Server assumes that the
method is idempotent and will provide failover services for the EJB method,
even if a failure occurs during a method call.
Now I made 2 changes to the code.
1 . I added as follows to the weblogic-ejb-jar.xml of teller stateless EJB
<stateless-clustering>
<stateless-bean-is-clusterable>true</stateless-bean-is-clusterable>
<stateless-bean-load-algorithm>random</stateless-bean-load-algorithm>
<stateless-bean-methods-are-idempotent>true</stateless-bean-methods-are-idem
potent>
</stateless-clustering>
So I should get the automatic failover .............
2. Also I added the break statement in the catch on line around 230 in
Client .java
catch (RemoteException re) {
System.out.println(" Error: " + re);
// Replace teller, in case that's the problem
teller = null;
invoke = false;
break;
So that the client program does not loop again and again.
Now I compile and restart all my three servers and redeploy application (
just to be sure )
I start my client and I get a automatic load balancing between the server
which makes me happy.
But Failover ....?
I kill one of the managed application server in cluster at any particular
test fail point.
I expect the exception to be taken care automatically by error/failover
handler in the home/remote stub
But the client program fails and terminates.
1. What is wrong with the code ?
2. Does the automatic failover with the indempotent methods also has to be
taken care by coding the similar while loop for stateless ejb ?
Your help will be appreciated ASAP.
Let me know if you need any thing more from my system. But I am sure this
will be very easy as it is from the sample code.........
Thanks
Sorry I meant to send this to the ejb newsgroup.
dan
dan benanav wrote:
> Do any vendors provide for clustering with automatic failover of entity
> beans? I know that WLS does not. How about Gemstone? If not is there
> a reason why it is not possible?
>
> It seems to me that EJB servers should be capable of automatic failover
> of entity beans.
>
> dan
-
[原创] 有关Weblogic Connection Pool 连接恢复的问题
这是一个古老的问题,一直困扰我,这里既然碰到了,就看看能不能解决。
环境描述:
WEBLOGIC版本是8.1 SP2,数据库是SQL SERVER 2000,分别部署在两个服务器上。
第一步:
问题描述:
数据库服务器重新启动,导致WEBLOGIC 的CONNECTION POOL中的连接中断,EJB无法获得连接,导致应用出错。
解决方法:
进入WEBLOGIC ADMIN CONSOLE,
Services->JDBC->Connection Pools->Config->Connections, 点开Advanced Options.
打开 Test Reserved Connections ,Test Created Connections,Test Released Connections这三个选项。
将Test Table Name属性设置为:sysproperties(SQL Server系统表,即使自己的应用不存在,这个表也存在,而且默认的内部没有数据)
根据如下解释:
Connections that fail the test are closed and reopened to re-establish a valid physical database connection.
(You must specify a Test Table Name below.)
每次调用首先进行测试连接,如果测试失败连接将重新建立。
测试结果:
WEBLOGIC启动后,关闭数据库SQL SERVER,应用服务器前端调用此时失败。
重新启动SQL SERVER后,WEBLOGIC端略做等待,前端应用恢复正常。
第二步:
问题描述:
进一步测试,如果WEBLOGIC先启动,启动完成后再启动数据库。
在WEBLOGIC CONSOLE得到如下输出:
<2006-3-22 上午11时50分08秒 GMT+08:00> <Warning> <JDBC> <BEA-001129> <Received exception while creating connection for p
ool "MyJDBC Connection Pool": [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.>
<2006-3-22 上午11时50分10秒 GMT+08:00> <Error> <JDBC> <BEA-001150> <Connection Pool "MyJDBC Connection Pool" deployment
failed with the following error: 0:Could not create pool connection. The DBMS driver exception was: [Microsoft][SQLServe
r 2000 Driver for JDBC]Error establishing socket..>
<2006-3-22 上午11时50分10秒 GMT+08:00> <Error> <JDBC> <BEA-001151> <Data Source "MyJDBC Data Source" deployment failed w
ith the following error: DataSource(jdbc/OMSEIITxDS) can't be created with non-existent Pool (connection or multi) (MyJD
BC Connection Pool).>
Unable to deploy EJB: XXXXXXX from XXXXXXX.jar:
[EJB:011028]The DataSource with the JNDI name: jdbc/XXXXXX could not be located. Please ensure that the DataSource h
as been deployed successfully and that the JNDI name in your EJB Deployment descriptor is correct.
1、在默认初始化打开的连接一一失败以后,连接池发现可用的连接为0,郁闷的宣布自己部署失败。
2、接着数据源发现没有可用的连接池,自己也宣布部署失败。
3、下面所有的EJB发现不了数据源的JNDI名,部署也全部失败。
应用启动完成后,大部分EJB的状态为INACTIVE。前端应用无法使用,此时启动数据库,前端应用无法使用。
手动重新部署 EJB失败,错误还是找不到JNDI,前端应用无法使用。
手动重新部署 连接池,数据源后,部署EJB 依然失败。前端应用无法使用。
解决方法:
进入WEBLOGIC ADMIN CONSOLE,
Services->JDBC->Connection Pools->Config->Connections, 点开Advanced Options.
将
Connection Creation Retry Frequency 参数设置为 60。
ConnectionCreationRetryFrequencySeconds含义:
当创建数据库连接时,如果数据库不可用(如数据库没启动),隔多长时间试着重新创建该连接,
WLS8.1会每隔ConnectionCreationRetryFrequencySeconds秒重试一次.直到JDBC POOL创建成功
参考:http://dev2dev.bea.com.cn/techdoc/20030469.html,‘JDBC Connect Pool’部分。
英文解释可以直接控制台上看到,或者edocs查。
测试结果:
将数据库关闭,WEBLOGIC重新启动。
在WEBLOGIC CONSOLE得到如下输出:
打开Connection Creation Retry Frequency 参数后,连接池在第一轮尝试失败以后,就成功部署了,数据源也成功部署。
EJB部署会失败,但是提示也与先前的不同:
Unable to deploy EJB: XXXXXXX from XXXXXXX.jar:
weblogic.common.resourcepool.ResourceLimitException: No resources currently available in pool MyJDBC Connection Pool to
allocate to applications, please increase the size of the pool and retry..
每隔一段时间会看到,CONNECTION POOL不断的重新进行连接:
<2006-3-22 下午12时17分56秒 GMT+08:00> <Warning> <JDBC> <BEA-001129> <Received exception while creating connection for p
ool "MyJDBC Connection Pool": [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.>
在WEBLOGIC启动完成后,所有EJB为INACTIVE状态。
启动数据库服务器,稍后,手动重新部署所有的EJB,EJB可以部署成功,前端应用可以正常使用。
此时,此问题已经基本解决,仍需要手动部署EJB。
第三步:
问题描述:
解决方法:
有关部署次序的问题,首先查阅WEBLOGIC文档,http://edocs.bea.com/wls/docs81/faq/deploy.html#744900,得到
WebLogic Server deploys server-level resources (first JDBC and then JMS) before deploying applications.
Applications are deployed in this order: connectors, then EJBs, then Web Applications.
If the application is an EAR, the individual components are loaded in the order in which they are declared
in the application.xml deployment descriptor.
WEBLOGIC先部署服务器端资源,JDBC -> JMS....,然后部署我们的应用,EJB->WEB APPLICATION。
实际从WEBLOGIC启动日志来看,即使打开了Connection Creation Retry Frequency,如果当时数据库不是可用的,CONNECTION POOL
会不断的调度CONNECTION进行重新连接。但是此时,EJB的部署也同时在进行。个人猜测这应该是两个不同的线程(组)分别调度的任务。
现在考虑的是能不能用StartupClass截住EJB的部署过程,粗略的说是如果DATASOURCE没有连接好,或者没有可用的连接池,
就不往下进行EJB部署的过程。
参考:http://edocs.bea.com/wls/docs81/config_xml/EJBComponent.html#DeploymentOrder
DeploymentOrder:
A priority that the server uses to determine when it deploys an item. The priority is relative to other deployable
items of the same type. For example, the server prioritizes and deploys all EJBs before it prioritizes and
deploys startup classes.Items with the lowest Deployment Order value are deployed first.
There is no guarantee on the order of deployments with equal Deployment Order values.
There is no guarantee of ordering across clusters. Default: 1000 Minimum: 0 Maximum: 2N31-1
在部署同一类应用时,按照 DEPLOYMENT LOADER的数值决定,数值越小越先。(EJB的参数在ADMIN CONSOLE界面上叫做LOAD ORDER)
而且上面看来服务器是先部署EJB,再部署STARTUP CLASS,遗憾了。
好在STARTUP CLASS上有两个选项,
Run Before Application Deployments
Run Before Application Activations
这两个选项分别可以设置StartupClass分别在系统资源部署之前,以及在系统资源部署和用户应用部署之间启动。
选上Run Before Application Activations。
现在可以了,我写了一个STARTUP CLASS,思路见下:
主代码:
private void testConnection(){
while (!isTimeout() && !getConnection()){
try{
Thread.sleep(testInterval*1000);
}catch(Exception ignor){}
log("DBConnectHolder job finished with following status:");
log("Timeout:"+isTimeout +",Connection OK:"+isConnected);
测试结果:
只要配置的等待时间足够长,应用服务器先行启动的情况下,等待数据库启动后才进行EJB等等的部署。
(主要考虑如果数据库连接不OK,EJB启动了也没有太大用,还得手工重新部署。)算是比较完满的解决了问题。
另外一个思路是是否可行? 通过MBean, 在CONNECTION 建立起来以后通知一把,进行EJB的重新部署。
没来得及研究,请有经验的同学帮我补充完善。
结论:
其实也没什么结论,只是把自己遇到问题,解决问题的思路写了一下。短时间内阅读的文献有限,可能采用了一些苯方法
,或者走了弯路,也请大家拍砖。
在WL8版本上,数据库连接进行恢复和重新连接的时候,上面提出的几个参数应该是比较重要的,我再次强调一下。
Services->JDBC->Connection Pools->Config->Connections, 点开Advanced Options.
Test Reserved Connections
Test Created Connections
Test Released Connections
Test Table Name
Connection Creation Retry Frequency在第一个情景中应该只需要打开Test Reserved Connections 就可以了。
Test Created Connections表示创建连接后放到pool之前进行测试看连接是否可用
Test Released Connections表示释放连接回到pool之前进行测试看连接是否可用
I think so! -
Transaction timed out with oracle 9i
Hi,
I am working with weblogic6.1.
Sometimes (very seldom) I have a problem which I don't undserstand.
The transaction stops and and after some time I get TimedOutException.
This time it happend in the findByPrimaryKey of a CMP Entity bean.
I have this problem only with Oracle 9i. with oracle8i everything works
fine.
I'm using oracle thin driver (I put oracle12.zip at the begin of weblogic
classpath)
Is this problem of oracle?
Does WLS 6.1 support Oracle9i?
Thanks for any hints
Szymon
stack trace:
javax.ejb.FinderException: Problem in findByPrimaryKey while preparing or
execut
ing statement: 'weblogic.jdbc.rmi.SerialPreparedStatement@197155':
java.sql.SQLException: The transaction is no longer active (status = Marked
roll
back. [Reason=weblogic.transaction.internal.TimedOutException: Transaction
timed
out after 561 seconds
Xid=21550:aea95ccd7f28edb9(4655671),Status=Active,numRepliesOwedMe=0,numRepl
iesO
wedOthers=0,seconds since begin=561,seconds
left=30,activeThread=Thread[ExecuteT
hread: '14' for queue: 'default',5,Thread Group for Queue:
'default'],ServerReso
urceInfo[weblogic.jdbc.jts.Connection]=(state=started,assigned=none),SCInfo[
mydo
main+myserver]=(state=active),properties=({weblogic.jdbc=t3://172.16.0.28:70
01})
,OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorUR
L=my
server+172.16.0.28:7001+mydomain+,
Resources={})],CoordinatorURL=myserver+172.16
.0.28:7001+mydomain+)]). No further JDBC access is allowed within this
transact
ion.
java.sql.SQLException: The transaction is no longer active (status = Marked
roll
back. [Reason=weblogic.transaction.internal.TimedOutException: Transaction
timed
out after 561 seconds
Xid=21550:aea95ccd7f28edb9(4655671),Status=Active,numRepliesOwedMe=0,numRepl
iesO
wedOthers=0,seconds since begin=561,seconds
left=30,activeThread=Thread[ExecuteT
hread: '14' for queue: 'default',5,Thread Group for Queue:
'default'],ServerReso
urceInfo[weblogic.jdbc.jts.Connection]=(state=started,assigned=none),SCInfo[
mydo
main+myserver]=(state=active),properties=({weblogic.jdbc=t3://172.16.0.28:70
01})
,OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorUR
L=my
server+172.16.0.28:7001+mydomain+,
Resources={})],CoordinatorURL=myserver+172.16
.0.28:7001+mydomain+)]). No further JDBC access is allowed within this
transact
ion.
at
weblogic.jdbc.jts.Connection.checkIfRolledBack(Connection.java:498)
at weblogic.jdbc.jts.Statement.setInt(Statement.java:606)
at
weblogic.jdbc.rmi.internal.PreparedStatementImpl.setInt(PreparedState
mentImpl.java:104)
at
weblogic.jdbc.rmi.SerialPreparedStatement.setInt(SerialPreparedStatem
ent.java:137)
at
com.verdisoft.datasource.ejb.contact.Person_vjvtzf__WebLogic_CMP_RDBM
S.ejbFindByPrimaryKey(Person_vjvtzf__WebLogic_CMP_RDBMS.java:1531)
at java.lang.reflect.Method.invoke(Native Method)
at
weblogic.ejb20.cmp.rdbms.RDBMSPersistenceManager.findByPrimaryKey(RDB
MSPersistenceManager.java:171)
at
weblogic.ejb20.manager.BaseEntityManager.findByPrimaryKey(BaseEntityM
anager.java:435)
at
weblogic.ejb20.manager.BaseEntityManager.localFindByPrimaryKey(BaseEn
tityManager.java:389)
at
weblogic.ejb20.internal.EntityEJBLocalHome.findByPrimaryKey(EntityEJB
LocalHome.java:266)
at
com.verdisoft.datasource.ejb.contact.PersonBean_vjvtzf_LocalHomeImpl.
findByPrimaryKey(PersonBean_vjvtzf_LocalHomeImpl.java:144)
at
com.verdisoft.datasource.ejb.contact.PersonBean.ejbHomeGetByKey(Perso
nBean.java:504)
at
com.verdisoft.datasource.ejb.contact.PersonBean_vjvtzf_LocalHomeImpl.
getByKey(PersonBean_vjvtzf_LocalHomeImpl.java:297)
at
com.verdisoft.datasource.ejb.EJBAdapterBean.getBeanAdapter(EJBAdapter
Bean.java:872)
at
com.verdisoft.datasource.ejb.EJBAdapterBean.updateItemInternal(EJBAda
pterBean.java:834)
at
com.verdisoft.datasource.ejb.EJBAdapterBean.updateItem(EJBAdapterBean
.java:808)
at
com.verdisoft.datasource.ejb.EJBAdapterBean_s83q9a_EOImpl.updateItem(
EJBAdapterBean_s83q9a_EOImpl.java:146)
at
com.verdisoft.datasource.DataAdapterManagerBean.updateItem(DataAdapte
rManagerBean.java:144)
at
com.verdisoft.datasource.DataAdapterManagerBean_plajw8_EOImpl.updateI
tem(DataAdapterManagerBean_plajw8_EOImpl.java:614)
at
com.verdisoft.datasource.DataAdapterManagerBean_plajw8_EOImpl_WLSkel.
invoke(Unknown Source)
at
weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:282)
at
weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
ef.java:97)
at
weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
a:231)
at
weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
.java:21)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:144)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
at
com.verdisoft.datasource.ejb.contact.Person_vjvtzf__WebLogic_CMP_RDBM
S.ejbFindByPrimaryKey(Person_vjvtzf__WebLogic_CMP_RDBMS.java:1715)
at java.lang.reflect.Method.invoke(Native Method)
at
weblogic.ejb20.cmp.rdbms.RDBMSPersistenceManager.findByPrimaryKey(RDB
MSPersistenceManager.java:171)
at
weblogic.ejb20.manager.BaseEntityManager.findByPrimaryKey(BaseEntityM
anager.java:435)
at
weblogic.ejb20.manager.BaseEntityManager.localFindByPrimaryKey(BaseEn
tityManager.java:389)
at
weblogic.ejb20.internal.EntityEJBLocalHome.findByPrimaryKey(EntityEJB
LocalHome.java:266)
at
com.verdisoft.datasource.ejb.contact.PersonBean_vjvtzf_LocalHomeImpl.
findByPrimaryKey(PersonBean_vjvtzf_LocalHomeImpl.java:144)
at
com.verdisoft.datasource.ejb.contact.PersonBean.ejbHomeGetByKey(Perso
nBean.java:504)
at
com.verdisoft.datasource.ejb.contact.PersonBean_vjvtzf_LocalHomeImpl.
getByKey(PersonBean_vjvtzf_LocalHomeImpl.java:297)
at
com.verdisoft.datasource.ejb.EJBAdapterBean.getBeanAdapter(EJBAdapter
Bean.java:872)
at
com.verdisoft.datasource.ejb.EJBAdapterBean.updateItemInternal(EJBAda
pterBean.java:834)
at
com.verdisoft.datasource.ejb.EJBAdapterBean.updateItem(EJBAdapterBean
.java:808)
at
com.verdisoft.datasource.ejb.EJBAdapterBean_s83q9a_EOImpl.updateItem(
EJBAdapterBean_s83q9a_EOImpl.java:146)
at
com.verdisoft.datasource.DataAdapterManagerBean.updateItem(DataAdapte
rManagerBean.java:144)
at
com.verdisoft.datasource.DataAdapterManagerBean_plajw8_EOImpl.updateI
tem(DataAdapterManagerBean_plajw8_EOImpl.java:614)
at
com.verdisoft.datasource.DataAdapterManagerBean_plajw8_EOImpl_WLSkel.
invoke(Unknown Source)
at
weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:282)
at
weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
ef.java:97)
at
weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
a:231)
at
weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
.java:21)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:144)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
com.verdisoft.datasource.exception.DataNotFoundException: Object not found:
data
source://private_addressbook/ejbcontact/john1025100151518/12770
at
com.verdisoft.datasource.ejb.EJBAdapterBean.getBeanAdapter(EJBAdapter
Bean.java:876)
at
com.verdisoft.datasource.ejb.EJBAdapterBean.updateItemInternal(EJBAda
pterBean.java:834)
at
com.verdisoft.datasource.ejb.EJBAdapterBean.updateItem(EJBAdapterBean
.java:808)
at
com.verdisoft.datasource.ejb.EJBAdapterBean_s83q9a_EOImpl.updateItem(
EJBAdapterBean_s83q9a_EOImpl.java:146)
at
com.verdisoft.datasource.DataAdapterManagerBean.updateItem(DataAdapte
rManagerBean.java:144)
at
com.verdisoft.datasource.DataAdapterManagerBean_plajw8_EOImpl.updateI
tem(DataAdapterManagerBean_plajw8_EOImpl.java:614)
at
com.verdisoft.datasource.DataAdapterManagerBean_plajw8_EOImpl_WLSkel.
invoke(Unknown Source)Irene Ho wrote:
Dear all,
When the java application program tries to insert the data (around 300
records). Sometimes, the error occurs as "EJB Exception:
weblogic.transaction.internal.TimedOutException: Transaction timed out after
95 seconds".
When the error occurred, only one java application was running. Furthermore,
I set the JTA-->Timeout Seconds to 30 in the thr the Weblogic console. The
configuration of the server is WebLogic 7.0 with SP2 and Oracle 8.1.7.
Anyone know what happen and how to resolve the problem? The error is due to
the entity bean, Weblogic or Oracle?
Thanks a lot.
IreneOr configuration. You can set your timeout to a different value. It is likely
to be an oracle problem. We don't do anything unnecessary to delay your application
code. You may be able to check the jdbc log or jta log to see when the tx starts and
how long it takes to progress. If you note a delay, you could take a server
thread dump to see what weblogic is doing. Typically it will be waiting for
Oracle to respond from a jdbc call.
Joe -
I want to cache JNDI Look ups for Datasources/EJBs.
I am wondering if anyone would have a suggestion for me regarding speeding
up the time it takes to execute the following code snipplets:
Context context = new InitialContext();
Object objectReference = context.lookup("someEJB");
It appears that the context.lookup is always quite a bit of time, even when
the client is running local to the EJB server.
Is there any way to serialize or "save" this lookup information so that
client apps that are looking for "someEJB" can use the saved information?
Thanks to all who will respond
Regards,
Raju ([email protected])Please do not cross-post.
"Anjaneya Raju" <[email protected]> wrote in message
news:39994516$[email protected]..
>
>
I want to cache JNDI Look ups for Datasources/EJBs.
I am wondering if anyone would have a suggestion for me regarding speeding
up the time it takes to execute the following code snipplets:
Context context = new InitialContext();
Object objectReference = context.lookup("someEJB");
It appears that the context.lookup is always quite a bit of time, evenwhen
the client is running local to the EJB server.
Is there any way to serialize or "save" this lookup information so that
client apps that are looking for "someEJB" can use the saved information?
Thanks to all who will respond
Regards,
Raju ([email protected]) -
I have 9ias 903 , database 9i
I have MDB configured with OJMS, resource provider, it can dequeue message , but it always commit the transaction,, i tried to generate a exception inside onmessage, but it commits the transaction, which means the message doesn't go back to the queue..
I tried to use none-ejb datasource, ejb-datasource,, tried to configure transaction attribute to Required,, none of them succeeded.. I am so frustrated here,, such a simple thing if i do it with weblogic or any other server... can anyone point out the problem..
here are my configurations
<?xml version = '1.0' encoding = 'windows-1252'?>
<!DOCTYPE orion-application PUBLIC "-//Evermind//DTD J2EE Application runtime 1.2//EN" "http://xmlns.oracle.com/ias/dtds/orion-application.dtd">
<orion-application>
<data-sources path="./data-sources.xml"/>
<resource-provider class="oracle.jms.OjmsContext" name="etccjms">
<description>OJMS Context using thin JDBC</description>
<property name="datasource" value="jdbc/ejb/OracleDS"></property>
</resource-provider>
</orion-application>
<?xml version = '1.0' encoding = 'windows-1252'?>
<!DOCTYPE data-sources PUBLIC "Orion data-sources" "http://xmlns.oracle.com/ias/dtds/data-sources.dtd">
<data-sources>
<data-source class="com.evermind.sql.DriverManagerDataSource"
location="jdbc/OracleDS"
username="xxxxx"
password="xxxxx"
url="jdbc:oracle:thin:@xxxxxx"
xa-location="jdbc/xa/OracleDS"
connection-driver="oracle.jdbc.driver.OracleDriver"
inactivity-timeout="30" wait-timeout="5" name="tgsconnection"
ejb-location="jdbc/ejb/OracleDS">
<description>Tag Store DataSource</description>
</data-source>
</data-sources>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<message-driven>
<description>Message Driven Bean</description>
<display-name>GLPostingMDB</display-name>
<ejb-name>GLPostingMDB</ejb-name>
<ejb-class>ntta.scip.webservice.glposting.GLPostingMDBBean</ejb-class>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
</message-driven>
</enterprise-beans>
</ejb-jar>Hi Jason hu
did you try using a non-emualted datasource, something like this :
<data-source
class="com.evermind.sql.OrionCMTDataSource"
name="XADatasource"
location="jdbc/DS1"
connection-driver="oracle.jdbc.driver.OracleDriver"
username="user1"
password="pwd1"
max-connect-attempts="3"
url="jdbc:oracle:thin:@linux:1521:global92"
inactivity-timeout="30" />
Madhu -
How can I look up DataSource from one EJB to the other EJB?
Image that, I have 3 databases:
DB1
DB2
DB3,
And then, 03 DataSources is deployed in DS EJB, named DataSource1, DataSource2, DataSource3.
In the other App EJB, I have Connection Management function, as follows:
public Connection getConnection(databaseKey) {
if (databaseKey.equals("DB1")){
connection = remote.lookup("DataSource1");
}else if (databaseKey.equals("DB2")){
connection = remote.lookup("DataSource2");
}else if (databaseKey.equals("DB3")){
connection = remote.lookup("DataSource3");
return connection;
How can I access DataSource 1,2,3 from the other EJB? How to config EJB server for that?
Thanks in advance!
Now, I have the other App EJB. Some class will require one of the above DataSource from DS EJB through function getConnection(databaseKey){}I strongle suggest you to use a ServiceLocator for this . It will be very easy to identify.Go to the sun home page and look for a servicelocator pattern.You can even directly use that code for you.
-
Deploying EJB 3.0 entity beans without a Datasource
[Cross-posted from the TopLink list]
My question: Is there any way to configure the container or persistence provider to defer trying to connect to the Datasource until I make some call that involves persistence? Or any other way to deploy an app containing entity beans without having a database configured?
Background: I am working on a component that can be configured to run in either persistent or in-memory mode. For the persistent mode we would like to use EJB 3.0 entity beans; for the in-memory mode we would like the component to be deployable without having to have a database available.
However in my prototype of the application, when I try to deploy to OC4J 10.1.3, as soon as the entity beans are detected the TopLink persistence provider tries to establish a connection to the db via either the configured or default DataSource. So if the db is unavailable, deployment fails. Since this is occuring at deployment, it happens regardless of whether I am actually using any persistence features or not.Hi,
I'm experiencing same problems, is this a bug or an feature? -
Who can explain how EJB connect to Oracle9i DB with DataSource?
I have taken 4 days into this problem. I am developing EJB with J2EE1.3 and Oracle9i DB, I can connect to DB in code with DriverManager. But I want to use DataSource to connect to DB. I failed, I can not get new way to resolve it when I after try to connect with javax.sql.DataSource, oracle.jdbc.pool.OracleDataSource and oracle.jdbc.pool.OracleConnectionPoolDataSource.
I have got different Exceptions when I coding different ways:
one is:
Caught an exception.
java.rmi.ServerException: RemoteException occurred in server thread; nested exce
ption is:
java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: U
nable to connect to database. com.sun.enterprise.resource.JdbcDataSource; nested
exception is:
javax.ejb.EJBException: Unable to connect to database. com.sun.enterpris
e.resource.JdbcDataSource
java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: Unable to
connect to database. com.sun.enterprise.resource.JdbcDataSource; nested excepti
on is:
javax.ejb.EJBException: Unable to connect to database. com.sun.enterpris
e.resource.JdbcDataSource
javax.ejb.EJBException: Unable to connect to database. com.sun.enterprise.resour
ce.JdbcDataSource
<<no stack trace available>>
the Other is:
Caught an exception.
java.rmi.ServerException: RemoteException occurred in server thread; nested exce
ption is:
java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: U
nable to connect to database. makeConnection:Io Exception: Connection refused(DESCRIP
TION=(TMP=)(VSNNUM=150999297)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4)
))); nested exception is:
javax.ejb.EJBException: Unable to connect to database. makeConnection:Io
Exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=150999297)(ERR=12505)(ERROR_
STACK=(ERROR=(CODE=12505)(EMFI=4))))
java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: Unable to
connect to database. makeConnection:Io Exception: Connection refused(DESCRIPTION=(TM
P=)(VSNNUM=150999297)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4)))); nes
ted exception is:
javax.ejb.EJBException: Unable to connect to database. makeConnection:Io
Exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=150999297)(ERR=12505)(ERROR_
STACK=(ERROR=(CODE=12505)(EMFI=4))))
javax.ejb.EJBException: Unable to connect to database. makeConnection:Io Exception: C
onnection refused(DESCRIPTION=(TMP=)(VSNNUM=150999297)(ERR=12505)(ERROR_STACK=(E
RROR=(CODE=12505)(EMFI=4))))
<<no stack trace available>>
My codes related are:
private void makeConnection() throws NamingException, SQLException {
try{
InitialContext ic = new InitialContext();
OracleConnectionPoolDataSource ocpds = (OracleConnectionPoolDataSource) ic.lookup(dbName);
PooledConnection pc = ocpds.getPooledConnection();
con = pc.getConnection();
}catch(SQLException ex){
throw new SQLException("makeConnection:" + ex.getMessage());
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
con = DriverManager.getConnection(
"jdbc:oracle:thin:@172.28.200.43:1521:shcd",
"lijun", "xiaotian"); */
public void setEntityContext(EntityContext context) {
this.context = context;
try {
makeConnection();
} catch (Exception ex) {
throw new EJBException("Unable to connect to database. " +
ex.getMessage());
I believe I set JNDI and config EJB right, because I can run it with Cloudscape DB all right.
who can tell me where is my WRONG, or tell me how to connect to Oracle9i DB?Hi Jhlijun,
I am facing the same problem at the moment. However, I am not using a pooled connection. The following is my code. I am trying to connect a stateless session bean to an Oracle 9i database with result being fed back to a jsp page.
package Test;
import javax.naming.*;
import java.sql.*;
import java.util.*;
import javax.ejb.*;
import javax.sql.DataSource;
import javax.sql.*;
public class TestSessionEJBbean extends java.lang.Object implements javax.ejb.SessionBean
String q="Select NAMETITLE,NAMEFIRST,NAMELAST from People where PeopleRSN<100";
protected boolean create() throws java.lang.Exception
return true;
public TestSessionEJBbean()
{ // EJB constructors don't have a server context.
private void unhandledEvent( String listenerName, String methodName, java.lang.Object event )
// method for interface javax.ejb.SessionBean
public void ejbActivate() throws javax.ejb.EJBException, java.rmi.RemoteException
// To Do
// method for interface javax.ejb.SessionBean
public void ejbPassivate() throws javax.ejb.EJBException, java.rmi.RemoteException
// To Do
// method for interface javax.ejb.SessionBean
public void ejbRemove() throws javax.ejb.EJBException, java.rmi.RemoteException
// To Do
// method for interface javax.ejb.SessionBean
public void setSessionContext( javax.ejb.SessionContext parm0 ) throws javax.ejb.EJBException, java.rmi.RemoteException
this._sessionContext = parm0; // generated helper code
// To Do
* Test Method
public String Test() throws javax.ejb.EJBException
return "Hi! I am the SessionEjbBean.";
* Session Context of this EJB.
* Set in 'setSessionContext()' before any 'ejbCreate()' is executed.
private javax.ejb.SessionContext _sessionContext;
* ejbCreate Method
public void ejbCreate() throws javax.ejb.EJBException, javax.ejb.CreateException
try {
create(); // This 'create()' is used for internal initialization.
catch( java.lang.Exception __e) {
System.err.println( __e.toString() + " " + __e.getMessage() );
// TODO: implement
* getDBConnection Method
public sun.jdbc.rowset.CachedRowSet getDBConnection() throws javax.ejb.EJBException
String testPrint = "Starting...";//Only to check output
Connection conn;
sun.jdbc.rowset.CachedRowSet crset=null;
try {
testPrint += "before new InitialContext()....";//Only to check output
InitialContext ic = new InitialContext();
DataSource ds = (DataSource)ic.lookup("java:comp/env/jdbc/coquit");
testPrint += "before ds.getConnection()....";//Only to check output
conn = ds.getConnection("coquit","coquit");
testPrint += "before conn.createStatement()....";
Statement stmt=conn.createStatement();
testPrint += "before stmt.executeQuery(....)";
ResultSet rset = stmt.executeQuery(q);
testPrint += "before new sun.jdbc.rowset.CachedRowSet()";
crset = new sun.jdbc.rowset.CachedRowSet();
testPrint += "before crset.populate(rset)";
crset.populate(rset);
rset.close();
stmt.close();
conn.close();
} catch (NamingException ne) {
System.out.println("TestSessionEJBbean::getDBConnection Naming Exception " + ne);
}catch (Exception e){
System.out.println(testPrint+"...TestSessionEJBbean::getDBConnectionException" + e);
System.out.println("\n\n");
e.printStackTrace();
return crset; -
Can l make an instance of EJB home handler / Datasource shared by EJB objs
all ejb guru
As far as l know, it is general rule of thumb to cache the EJB home handlers and datasource object at EJB bean instance. But can l go a step further, make the same instance of EJB home handlers and datasource object shared by more than 1 EJB bean instance ?
( l checked out the methods of javax.ejb.EJBhome and javax.sql.DataSource. They are not declared as synchronized. It seems to me that EJB home handlers and datasource object are not thread safe and not suitable for being shared. Even they are thread-safe, if they are shared by 1+ EJB bean instance. Sharing EJB home handlers and datasource object may interfere the thread management of EJB container. Am l correct ? )
It is highly appreciated someone can share with me your insight in this issue.
thanks & regards
DannyOkay, you got me there. However, it's usually a better practice to start a new thread with your specific question instead of resurrecting old threads that (obviously) nobody cared enough to answer.
DataSources are retrieved from the container via JNDI. You may (generally) cache them in order to alleviate the JNDI lookup without worrying about Threads, as there is only (usually) one DataSource object per server (or node in a cluster). Do not cache (in your code) the Connection objects obtained from the DataSource - always close them in order to return them to the pool maintained by the DataSource.
Caching EJB HomeHandles is the accepted manner of avoiding repeated JNDI calls to locate EJBs. Typically, extracting the EJBHome from the HomeHandle re-initializes whatever network operations are embedded in the EJBHome object(s) by the vendor's implementation. Once again, you do not necessarily need to worry about Threads - the container and vendor implementation is already taking care of that for you, transparently.
Think about it: if there were Threading issues, even retrieving the above objects via JNDI would ensure that J2EE application servers wouldn't be Thread safe and all operations would be, essentially, blocked each time. Obviously, this is not the case since both DataSources and EJBHome objects can have multiple clients using them simultaneously. Just because there's not explicit synchronized tag on any of the methods defined in these interfaces doesn't mean they're single-Thread objects. -
Deploying ejb-jar when DataSource is defined
Hi,
I have an application that I have been deoploying to ear/ejb-jar/war files for some time. But I have found when I added a DataSource for CMP entity beans deployment of the ejb-jar failes with the following error;
WARNING: Skipping deployment step with id 'packaging-sequence' because no concrete deployer was found for platform 'JDBC'
If I remove the data source the deployment works, so it does seem to be the data source not the CMP entity bean that causes the problem.
Does anyone know what this error means and how to fix it!!!
PaulWhat does the manual for the OC4J application server have to say about it all?
-
Topic: Who can explain how EJB connect to Oracle9i DB with DataSource?
I have taken 4 days into this problem. I am developing EJB with
J2EE1.3 and Oracle9i DB, I can connect to DB in code with
DriverManager. But I want to use DataSource to connect to DB. I
failed, I can not get new way to resolve it when I after try to
connect with javax.sql.DataSource,
oracle.jdbc.pool.OracleDataSource and
oracle.jdbc.pool.OracleConnectionPoolDataSource.
I have got different Exceptions when I coding different ways:
one is:
Caught an exception.
java.rmi.ServerException: RemoteException occurred in server
thread; nested exception is:
java.rmi.RemoteException: nested exception is:
javax.ejb.EJBException: Unable to connect to database.
com.sun.enterprise.resource.JdbcDataSource; nested
exception is:
javax.ejb.EJBException: Unable to connect to database.
com.sun.enterprise.resource.JdbcDataSource
java.rmi.RemoteException: nested exception is:
javax.ejb.EJBException: Unable to
connect to database. com.sun.enterprise.resource.JdbcDataSource;
nested exception is:
javax.ejb.EJBException: Unable to connect to database.
com.sun.enterprise.resource.JdbcDataSource
javax.ejb.EJBException: Unable to connect to database.
com.sun.enterprise.resource.JdbcDataSource
<<no stack trace available>>
the Other is:
Caught an exception.
java.rmi.ServerException: RemoteException occurred in server
thread; nested exception is:
java.rmi.RemoteException: nested exception is:
javax.ejb.EJBException: Unable to connect to database.
makeConnection:Io Exception: Connection refused(DESCRIPTION=
(TMP=)(VSNNUM=150999297)(ERR=12505)(ERROR_STACK=(ERROR=
(CODE=12505)(EMFI=4)
))); nested exception is:
javax.ejb.EJBException: Unable to connect to database.
makeConnection:Io
Exception: Connection refused(DESCRIPTION=(TMP=)
(VSNNUM=150999297)(ERR=12505)(ERROR_
STACK=(ERROR=(CODE=12505)(EMFI=4))))
java.rmi.RemoteException: nested exception is:
javax.ejb.EJBException: Unable to
connect to database. makeConnection:Io Exception: Connection
refused(DESCRIPTION=(TM
P=)(VSNNUM=150999297)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)
(EMFI=4)))); nested exception is:
javax.ejb.EJBException: Unable to connect to database.
makeConnection:Io
Exception: Connection refused(DESCRIPTION=(TMP=)
(VSNNUM=150999297)(ERR=12505)(ERROR_
STACK=(ERROR=(CODE=12505)(EMFI=4))))
javax.ejb.EJBException: Unable to connect to database.
makeConnection:Io Exception: C
onnection refused(DESCRIPTION=(TMP=)(VSNNUM=150999297)(ERR=12505)
(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
<<no stack trace available>>
My codes related are:
private void makeConnection() throws NamingException,
SQLException {
try{
InitialContext ic = new InitialContext();
OracleConnectionPoolDataSource ocpds =
(OracleConnectionPoolDataSource) ic.lookup(dbName);
PooledConnection pc = ocpds.getPooledConnection();
con = pc.getConnection();
}catch(SQLException ex){
throw new SQLException("makeConnection:" + ex.getMessage());
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
con = DriverManager.getConnection(
"jdbc:oracle:thin:@172.28.200.43:1521:shcd",
"lijun", "xiaotian"); */
public void setEntityContext(EntityContext context) {
this.context = context;
try {
makeConnection();
} catch (Exception ex) {
throw new EJBException("Unable to connect to database. " +
ex.getMessage());
I believe I set JNDI and config EJB right, because I can run it
with Cloudscape DB all right.
who can tell me where is my WRONG, or tell me how to connect to
Oracle9i DB?Hi,
on small thing to check (or perhaps do):
Make sure that you are using the JDBC drivers from the Oracle9i
DB client e.g. copy the classes12.jar from the ORACLE_HOME of
the database client into OC4J_HOME lib.
Also, one thing that might help is to define an explict Oracle
datasource e.g.
- Set class to value of Oracle DataSource class
- Use only the location logical name
- Returns Oracle implementation of java.sql.Connection
<data-source
class="oracle.jdbc.pool.OracleDataSource"
name="jdbc/oracle/PooledDS"
location="jdbc/oracle/PooledDS"
username="scott"
password="tiger"
url="jdbc:oracle:thin:@<host>:<port>:<SID>"
/>
Andy -
Common lookup for datasource name in ejb-jar.xml for all EJB's??
I used <env-entry>...</env-entry> in ejb-jar.xml ...but that does not allow me to look the same entry in another EJB ...what is the right place to keep and look for such a information ?
EJBing recently !!
Thanks
AjayI am sorry friend, that is not what i am looking for.
I have datasource/connection pool and do not want to hardcode the name into all EJB's rather want to access it from xml file. If i use
<env-entry> that is for a perticular session or entity bean. and i have to write that for all 35 beans. I believe there shoule be a tag to access globaly.
thanks for considering me to reply.
Ajay -
DataSource - difference between ejb-location and location
Hi,
Does anyone know difference between ejb-location and location attribute specified in datasources.xml for an emulated datasource.
There are few connection leakage errors reported in log files though the connection and other database objects have been closed in finally block in all places.
So just wanted to find out whether specifying the same value for location as well as ejb-location is not the root cause of connection leakage errors.
Thanks in advance for any help.
Regards,
SmitaSmita,
Personally, I think you should make sure that all locations (in your "data-sources.xml" file) should be different -- although I can't tell you why.
According to the documentation, the "ejb-location" uses a connection pool and I exclusively use the "ejb-location".
Good Luck,
Avi. -
EJB calling Spring Bean with non XA Datasources causing Rollback Exception
We have an EJB CMT with Required calling a spring bean (@Transactional Propagation.NOT_SUPPORTED). This is causing an Rollback Exception saying 2 phase commit must be enabled. The EJB has to write to datasource 1, but the Spring Bean is ready only on Data Source 2. The Data Sources are set to use Non XA Driver with Support Global Transaction enabled for One phase commit. Any help is appreciated.
We have an EJB CMT with Required calling a spring bean (@Transactional Propagation.NOT_SUPPORTED). This is causing an Rollback Exception saying 2 phase commit must be enabled. The EJB has to write to datasource 1, but the Spring Bean is ready only on Data Source 2. The Data Sources are set to use Non XA Driver with Support Global Transaction enabled for One phase commit. Any help is appreciated.
Maybe you are looking for
-
I just upgraded to Leopard and was checking out Front Row. I can use the arrow keys to navigate but since I am on a Powerbook I have no remote or sensor to pickup one. I am curious if there are third-party remotes available for older Macs. I have an
-
How can I put my recently purchased iTunes movies onto my thumb drive and WD my passport external hard drive.My Mac is saying that can't be copied because it is too large for volumes format
-
My ipod is disabled and the dial pad isn't coming back up. What should i do?
My ipod is disabled so it told me to hook it up to itunes, so i did butthen itunes told me that it can read the ipod til i putthe code in and i cant do that because the dial pad is not showing up. What should i do?
-
Newb VoIP End to End Qos Questions
I'm at a site that has Layer 3 Cisco switches and routers end to end. Cisco IP phones plug directly into Layer 3 switches with various routers in the core. 1) If all connections are Layer 3 do I need to concern myself with trusing COS? I would trust
-
Missing jar - BOE XI3.1 SP3 IG Kit for PeopleSoft with client comp option
Hi Team, I have successfully installed BOE XI 3.1 SP3 in our Linux m/c and while installing Integration Kit for PeopleSoft in Windows m/c selected with Client Computer option the Kit shown the message unable to find pscafinstall.jar from BusinessObj