Dhiren Lodhia

Greenhorn
+ Follow
since Mar 05, 2008
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 Dhiren Lodhia

I have a JComboBox wiith name of countries in it.i want it to be editable.when the use will type initial few letters the items in JCombobox will get filtered.
i have managed to write the filtering code.
following code does the filtering of items as the user types in to the JCombobox it works fine.


my only problem is after selecting some item from popup menu when i press Enter it does not get set in the JComboBox ???

can i do it without making the my simple code too complicated??

Thanks in advance...
12 years ago
My Friends along with their students are actually doing a project on Bluetooth for Blind. The Project coding uses Netbeans IDE. Specifically MIDlets. The project is simple.

This is Lengthy I know. But I am helpless. So please spend some time to read and try to answer.

It is this: We would like to play an audio in Blind person's mobile phone when he reaches a specific point (ie., audio about the information of the place). We were able to develop a code which searches the mobile phone and we have TX unit which transmits an audio containing info about the fllor or building to the Blind person mobile.

But the problem starts here:

The Folder in which the files get stored are different in different mobile phones. Say in Nokia it goes to received folder. In sony ericson some where else. We should actually know where it is getting stored to play it. In Sony we where able to retrieve the path and play . But when we try the same logic with Nokia. The Receieved folder is not accessible. It shows the whole path along with all the folderes except this one.

Do you know any way of solving this specific problem?

2. One more problem is every time whether it is TX or RX to access the files it asks for an YES or NO to send or receive file. We do not want this option. We want it to happen automatically. The reason is We cannot expect a Blind person to press an YES or NO to receive and Play. We also found a solution But it is disabled. ie. We have an option called allow always. So we surfed Net. And we found that The problem could be solved with Midlet signing. We tried in Netbeans but we could not understand.Can any one tell me something about Midlet signing? What is the use of it? or Is there any alternative to solve this.

PLEASE HELP . WE ARE BADLY IN NEED OF HELP.
13 years ago
Hi all,

I m preparing for SCWCD EE5(310-083) and while preparing came across sessions management.
i also understood listeners of all types.
including 'HttpSessionActivationListener '

i did all practicals regarding all other listeners and its all working great

but HttpSessionActivationListener is where i am not really clear.

first of all it defines two metods

public void sessionWillPassivate(HttpSessionEvent e) &
public void sessionDidActivate(HttpSessionEvent e)

now from whatever i read it stats that above both methods will get called by container when a session moves from one JVM TO ANOTHER JVM.

i guess it means to different web containers (2 tomcat severs running on localhost on different port)

So i tried testing this practically on my system with two different tomcat running (tomcat5.5 & tomcat6.0)
i created a Session through servlet and then once session is created i try to transfer the request to the other JVM(tomcat) hoping that the session will also get transferred but it does not get moved to second JVM.

following is code what i thought will work :
Simple HTML form

web.xml

Implementing Class

First Servlet

Second Servle


now i had deployed this entire web application on two server on local machine
Tomcat 6 :8085
Tomcat 5 :8080

and i was hoping that after creating session on Tomcat 6 :8085 when i will move to Tomcat 5 :8080 by link (i also did encoding for that) my session should also move from JVM1 Tomcat6 to JVM2 Tomcat5.

it didnt work on did not get my old session on other server.

is this a correct way to test this concept??
am i doing something stupid with all of this??
i was just trying to test it ??

please help . sorry for making you all read so much.......
13 years ago
Hi all,

We all know that there are two steps of running a java program

[1] convert your .java file to bytecode using javac [called compilation] so you get .class file
[2] run your .class file using java [called interpretation] so you get your output.

I know that .java file is compiled only once using javac & we get .class file i.e bytecode i agree

Now when we want to run the file JRE which has java will run the file and give us the output.

now earlier days in java (may be in jdk1.1 or so) JRE used to interpret the byte code line by line and execute
which had one problem of performance compared to compiled languages like c & c++

so to solve that problem and improve performance now a days JRE includes apart from interpreter also one compiler called JIT(also called HotSpot Compiler) which compiles the byte code(instead of interpreting to native platform) hence improving performance.

first of all is my above understanding correct so far about JIT??

then i have a question?
this directly means that now a days a JRE is capable of both interpreting as well as compiling the byte code.
so question is how it will decide compile or interpret ?

Please s Note when i say compiling the byte code i do know we actually compile .java file ony once,i am not saying compiling .class file with javac again [its not possible] i am saying it in context of running the .class file.

i hope i have made my self clear!!

Please let me know if so far things are correct .

Thanks in advance
13 years ago
Hi all,
I am trying to use JPA entity class to insert and update records in to Java Durby Database and i am using @Version.

I m using NetBeans 6.1,Java Durby as a database

following is my table in database :

create table STUDENT
(
RNO int primary key,
FNAME varchar(20) ,
LNAME varchar(20),
M1 int,
M2 int,
AVEG double,
RES varchar(20),
VERSION int
)

Following is my Entity calass :


I am using Oracle Toplink as Persistance Provider :

Following is my Persistance Unit's persistence.xml file :


Following is a Client code i am using to Insert a Record :



The above code works completely fine and it inserts a record in to database with VERSION = 1

but wen i try to update the same record by following code i m getting an error :
Update code :



when i run the above program i ger following error in output window :

While updating the version should become 2 but instead i get the above error.

I m getting the same problem while using the same entity class in EJB also with glassfish server & Durby DB
I have no idea from where this java.lang.NullPointerException is coming from

IF I REMOVE @Version FROM ENTITY CLASS THE CODE WORKS FINE it then updates the record.

please let me know if i have made any mistakes .

Thanks

Mark Garland wrote:Hi Kengkaj,

Thank you for your reply.

What I meant by my original question, is how is a client identified by the container?
i.e. a 2nd request comes in from a client - how does the container know which object is theirs?
There must be some id somewhere.

Thanks,

MG



Hi Mark,

I think i can explain your quey.
First thing to remember when using Stateful SessionBean [SFSB] is that there will be unique ONE SFSB for each client.

Now while implementing SFSB there are actually 2 ID that work togather.
First in web containr you create Session and you add the reference to SFSB in the session .
so 1st you have Session id in web container.
now for each session id in web container your EJB container will create a uniwue SFSB and it will also be given some id
and this both Session id & SLSB id are bound togather
so from next time onwards if you come come with same session id you will be given same corresponding SFSB.

try this if your session expires in Web container you will also loose your SFSB.

jim li wrote:in a application or container managed entity manager with persistenctype = extended, if a entity is deleted, is it detached? if it is dettached, is there a way to reattached it back



If we go by the LIFE CYCLE of an Entiry Instance then when you delete an entity it goes from 'Managed' State to 'Removed' state (you will use remove methond ).
it does not go to 'Detached ' State.
and again according to the LIFE CYCLE if an Entity is in 'Removed' State you can restore it by again Calling persist method.


I think LIFE CYCLE Should be same regardless of which scope you use(normal or extended)
So i THINK it applies to your question also.

if a entity is deleted, is it detached? No I think it is in Removed state.
f it is dettached, is there a way to reattached it back YES You could have had done that using merge method again but if it would have in DETACHED remember it is in Removed State.

You may try this practically........

Hi all,

i just wanted know that where MDBs are used in real life ??
I know that it has to do with deciding synchronous & asynchronous communication ...........

but i could not really understand its real use and advantage in real life.

so can any one please answer following doubts regarding MDB?

1) Why to use MDB?
2) Where to use MDB?
3) what are advantages of using MDB?
4) where exactly MDBs are used in real life?
5) can any one give any simple small demo of proper use of MDB with code?

I will really appreciate if any one can give any simple MDB application demo with code .

Regards,
Dhiren

Jerwin Louise Uy wrote:Hi Dhiren,

Yes. That will cause the error because the deployment descriptor is wrong.

Here is the modified ejb-jar.xml



Regards.



Thanks a ton Jerwin,
it finally worked for me.
have no words to thank you,
will keep in touch with you .......
Regards Dhiren

Jerwin Louise Uy wrote:Hi,

I will try to answer your questions the best as I can.

1. The default name of a session bean is the fully qualified class that it implements, i.e. SessionBean implements Foo.SomeRemoteInterface then that name attribute of SessionBean is bound to Foo.SomeRemoteInterface
2. mappedName bounds that session bean to a global variable in the RMI registry, but not all application server vendors are required to support this functionality
3. See #2 Assigning a mappedName may break portability across different application server vendors
4. See #1 - You can perform that following (assuming no ejb-jar.xml is used and default annotation values), then you can do the following



5. ejb-ref is that bound name for the session bean

For the purpose of SessionContext, you do not need to access this directly. If you really want to, the you can to modify the ejb-jar.xml to include the following information -



This deployment descriptor simply injects a session bean that implements the remote interface, bind to the the value of ejb-ref-name. Therefore, you can do the lookup on the SessionContext. I should note that the SessionContext is not aware of any global variables except for the ones declared in the ejb-jar.xml

I hope this information helps.




Thanks alot Jerwin
i did get some of doubts cleared specially about mappedName,i had thought it will be good to for ejb to give mappedName and will make ejb universally accessible from any where,didn't know that it is not in J2EE SPEC .
but i had a reason to believe that let me tell you one scenario ,
one i was trying to look up an EJB from remote standalone java POJO client and i kept getting the error of name not found till i gave the EJB mappedName.then it worked fine.

btw regarding SessionContext look up of EJB from EJB ,
i know that we don't need to do that we have many other ways but till i need to do it because its mentioned in Sun's EJB course FJ310 and hence i m required to show it practically to students.
i did read your post carefully and tried all you said but still it didn't work
i m posting here the code of mini project that i have made
please have a look at the code and let me know if any mistake is there ..........

i have made this Enterprise Application in NetBeans 6.1 and Glassfish AS
code of calling Second EJB from First using SessionContext is as follows :


please let me know if any thing more can be done..........

Mohammad Rezwan wrote:I got really puzzled about JNDI lookup for local interface in Glassfish2u2.

Whenever I call remote interface like

InitialContext ctx = new InitialContext(); TestingRemote testingBeanJndi = (TestingRemote) ctx.lookup(TestingRemote.class.getName());

It works fine.........

But

InitialContext ctx = new InitialContext(); String strLookUp = ""java:comp/env/ejb/TestingBean"; TestingLocal testingBeanJndi = (TestingLocal) ctx.lookup(strLookUp);

It doesn't work...
I tried
strLookUp = ""java:comp/env/TestingBean";

I also tried like
@Stateless(name="ejb/TestingBeanLocal") // previously I didn't overwrite 'name'
public class TestingBean implements TestingRemote, TestingLocal { }

AND

strLookUp = ""java:comp/env/ejb/TestingBeanLocal";

Not working as well.


Could anyone please help me?

And could I get list for all JNDI env by using any command?

PS -- I am packing in the Beans in ear file.



Where are you putting this look up code??
in which component (Servlete or app client ......)

Dhiren

Hi all,
We all know that in EJB3.0 we can use @EJB annotaton to lookup the EJB either from Web Tier or application client or from another EJB also.all of these is working fine.

but EJB3.0 says that while calling EJB from another EJB it could also be done like following from one EJB3.0 :

@Resource private javax.ejb.SessionContext context;
public void myMethod() {
BankMgr bankMgr = (BankMgr)context.lookup(“ejb/BankMgr”);
}

Using SessionContext.
but when i try doing it i get an error saying NameNotFound for the 2nd EJB from 1st EJB??
no idea why???

apart from that how many names a EJB can have & if it has many then by what name should we look up??
for e.g
1)what is the name of EJB if we dnt give any name at all (nither JNDI nor mappedName)
2)what is mappedName (used with @Stateful & @Stateless)(after giving it can we lookup using old name)
3)what are implications of giving mappedName?
4)what is JNDI name for EJB?
5)how & where to give JNDI name to an EJB?(after giving it can we lookup using old name)
6)what is reference name for an EJB?(used in web tier in web.xml in <ejb-ref> element?
:roll: ops: :twisted:
Please help..............
I m using NetBeans6.5.10 & Glassfish V2

Thanks in advance.....................
Hello all,

I know EJB 2.0 as well as EJB 3.0,Hence i know that tat in 2.0 in Stateful EJB we were used to pass the param to create() & ejbCreate() which is how we were used to get the same Bean instance from Bean Pool or in other words we could maintain the state of user & hence make EJB really statefull!!
We could have seen the piratically in 2.0 !!!

Now in EJB3.0 we first of all do not Pass the parameters to Statefull EJB method its Just @Stateful annotation tats it!!!
I m just not able to understand how J2EE server will give the same instance of ejb from EJB pool to that user & even if it will happen how can i store user's state specific data in tat EJB.

I have tried simples examples to see the difference practically but i cant get the out put as required!!

can any one help??
if possible please give the simplest example of two EJBs one stateful and one stateless (3.0) in which we can see the out put practically when we run them !!!

I m using NetBeans 6.1 & glassfish V2 .

Thanks in advance!!!
(Please give code example)
Hi every one,

i want to know how can we use disconnected database architecture using JDBC in java. i.e what i mean is something like DataSet in .Net.
when we take data in ResultSet & when i want to take data from ResultSet the database connection has to be OPEN else it gives error.
i want to take data from database onces and then close Connection then use data!!!
I have Heard about class called CachedRowSet,What is that exactly & how to use it??
please give a small & simple example if possible...........

Thanks in Advance