Devaki Nihar

Greenhorn
+ Follow
since Apr 30, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Devaki Nihar

I am using Orion2.0 App Server
I am trying to call entity bean's remove method from session bean

Now the situation is like this
I get collection of Test1 remote interfaces by a finder method as like findById1
Now in the iteration i get the Test1 Data object by getXXX method of remote interface
I get one of the key from the data object
And depending upon that key i want to call finder method of Test2Home,It returns remote interface of Test2(and not a collection as the relation is 1-1)
And want to delete both that is Test1 and Test2 (in iteration).
My code is like -
try{
Test1Home test1Home = (Test1Home)initialContext.lookup("Test1");
Collection test1Coll = test1Home.findById1(id1);
Iterator test1CollItr = test1Coll.iterator();
Test2Home test2Home = (Test2Home) initialContext.lookup("Test2);
if(test1Coll.size() > 0){
while(test1CollItr.hasNext()){
Test1 test1 = (Test1)test1CollItr.next();
Test1Data test1Data = test1.getTest1Data();
float id2 = test1Data.getid2();
Test2 test2 = test2Home.findById2(id2);
test2.remove(); // here it gives remove exception
test1.remove()
}
}
} catch(FinderException f){
} catch(RemoveException r){
}
Here test2 get removed (record get deleted) but test1 remains in database
Is there is any concurrency problem?
There is no any config file such like 'orion-cmp-rdbms-jar.xml'
And already i have mapped all the cmp fields in deployment descriptor.
THE APPLICATION IS WORKING FINE but i am getting the warning at server startup.
I am using Orion2.0 App server.I used CMP entitybeans.I have written one finder method
My code is like this
1) in TestUserHome home interface of entity beans
public Collection findByFirstName(String firstName)throws FinderException , RemoteException;
2) in ejb-jar.xml
<entity>
<display-name>TestUser</display-name>
<ejb-name>TestUser</ejb-name>
<home>myPackage.TestUserHome</home>
<remote>myPackage.TestUser</remote>
<ejb-class>myPackage.TestUserEJB</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>myPackage.TestUserPK</prim-key-class>
<reentrant>False</reentrant>
<abstract-schema-name>TestUser</abstract-schema-name>
<cmp-field>
<field-name>UserID</field-name>
</cmp-field>
<cmp-field>
<field-name>firstName</field-name>
</cmp-field>
<cmp-field>
<field-name>lastName</field-name>
</cmp-field>
<!------ And more other -->
<resource-ref>
<description></description>
<res-ref-name>jdbc/MyDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<query>
<query-method>
<method-name>findByFirstName</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>
SELECT OBJECT(u) FROM TestUser AS u WHERE u.firstName=?1
</ejb-ql>
</query>
</entity>

3) I am calling the finder method from session bean as
///////Other required stuff here
Collection testUsers =testUserHome.findByFirstName(name);
////////other stuff

And when i execute the application then it gets all the records regardless of the finding by the passed name
But when i do entry in server specific orion-ejb-jar.xml as

<entity-deployment name="TestUser" location="TestUser" wrapper="TestUserHome_EntityHomeWrapper2"
table="TestUser" data-source="jdbc/MyDS" isolation="uncommitted" max-tx-retries="2">
<finder-method query="$firstName = $1">
<method>
<ejb-name>TestUser</ejb-name>
<method-name>findByFirstName</method-name>
<method-params>
<method-param>String</method-param>
</method-params>
</method>
</finder-method>
</entity-deployment>

IT RUNS OK
but both cases i get one warning when i start my server as
WARNING: Unused <query> tag found in <entity> 'TestUser', method name 'findByFirstName(java.lang.String)'
what is the difference between '=' and '*=' when we establish relationship between tables
because when i execute

Select e.name as Name, e.address as Address,d.deptname as Department
from emp e ,dept d
where e.deptid *= d.deptid
and ( e.name like 'a%' )

then along with the records where name starts with 'a' , i also get the records with name blank
But ,when i execute the following sql command ,i only get the records where name starts with 'a'

Select e.name as Name, e.address as Address,d.deptname as Department
from emp e ,dept d
where e.deptid = d.deptid
and ( e..name like 'a%' )
18 years ago
In case of web server,to run a servlet on browser we have to specify as /myPackage/servlet/MyServlet in <url-pattern>
But how come in application server i can access the servet just as /myPackage/MyServlet.
I mean why we have to tell the web container explicitly the servlet???And why it is not needed in case of Application server which contain web container?
Please can any body explains me how to generate the primary key in case of entity bean without using any third party tool(IDGenerator).
Role of the EJB Container/Client/Bean for it.
If the primary key is a composite key having one field of integer type and other of string
What will be the hashcode() method in the primary key class?
Does concat will do the job?
Through a simple java application when we want a connection we often do as-
new sun.jdbc.odbc.JdbcOdbcDriver();
what it exactly does mean?
creating Driver's instance if yes then where is the instance variable here?
I have read somewhere that service() method shd not overriden.
I have written a simple servlet which extends HttpServlet and overriden service() method there.
It works .
Then which is the correct practice? why ?
18 years ago
Thats the spirit Navin.
Believe me this forum is the best amoung all the java forums.
I learned a lot from this forum.
18 years ago
CV
Just explain me in short
18 years ago
CV
I am a J2EE developer.I have 1.6 yrs Exp.
I want to update my CV .Can anyone tell me format of CV.
Like regarding the project profile how much shd i mention (aprox in how many lines?)
And regarding the technologies used how shd i list each e.g.
Database -
IDE -
J2EE Technologies -
Application Server -
??? What more?
Shd I also 3rd party tools used in my project like counter.jar/itex.jar ? if yes ,under which section ?
Also shd I write previous exp as a trainee?(6 months)
Regarding personal info???
18 years ago
I suggest u to use an open source application server like orion or jboss.
Database like postgress/mssql
I am new to MDB
I am using orion1.5 application server
I tried a simple MDB

import javax.ejb.EJBException;
import javax.ejb.MessageDrivenBean;
import javax.ejb.MessageDrivenContext;
import javax.jms.JMSException;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import com.sun.corba.se.internal.iiop.Message;

public class MDBExample implements MessageDrivenBean,MessageListener {
private MessageDrivenContext ctx = null;
public MDBExample() { }
public void setMessageDrivenContext(MessageDrivenContext ctx)throws EJBException {
this.ctx = ctx;
}
public void ejbCreate() {}
public void ejbRemove() {ctx=null;}
public void onMessage(javax.jms.Message message) {
try {
if (message instanceof TextMessage)
System.err.println("Text Message arrvied");

}catch (JMSException e) {
System.err.println("Communication Exception: " + e.getMessage());
}
}

}

and did the changes in deployment descriptor as
in <enterprise-bean> tag

<message-driven>
<description>Test MDB</description>
<ejb-name>MDBExample</ejb-name>
<ejb-class>MDBExample</ejb-class>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Topic</destination-type>
<subscription-durability>NonDurable</subscription-durability>
</message-driven-destination>
<resource-ref>
<description></description>
<res-ref-name>jms/theTopic</res-ref-name>
<res-type>javax.jms.Topic</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description></description>
<res-ref-name>jms/theTopicConnectionFactory</res-ref-name>
<res-type>javax.jms.TopicConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</message-driven>

and in assembly-descriptor tag

<container-transaction>
<method>
<ejb-name>MDBExample</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Supports</trans-attribute>
</container-transaction>

in application.xml

<display-name>Message Driven Bean</display-name>
<module>
<ejb>MDBPack.jar</ejb>
</module>

I have not written client class yet ,but my server gives me error at start up as
----Unable to link resource MDBExample, no JMS server running ---
Have i done some wrong or yet it is incomplete???When i start Application Server isn't JMS server get started automatically??