Sachin Deokar

Ranch Hand
+ Follow
since May 09, 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 Sachin Deokar

I am using Spring's DAORowmapper to populate the TO from resultset which I believe cloeses the resultset as well.
10 years ago
Hi,

I have a pdf file stored in Oracle DB as a Blob and trying to retrieve using a TO. I have copied below the setter and getter method from the TO and also the logs.

Could you please help me try to figure out why am I getting a NullPointerException.

As you can see in the logs the setter method stores the blob object and prints the size as 30. The getter method passes the null check and prints the object.toString() but when it comes to this.docBlob.length() an exception is thrown.

Also, to add flex calls a servlet which calls a spring service to get the pdf from the database. The TO with pdf populated from DB is returned by the service method to the servlet.

Thanks in advance.


Logs:


Regards,
Sachin Deokar
10 years ago
Welcome. Thanks for being here on ranch answering our questions.
10 years ago
Hi,

I am a complete beginner to EJB, trying to debug an issue for an application I recently started to work on.

I am getting this error "Security Error: java.lang.ClassCastException: com.security.SecurityManagerEJB_2ym79a_EOImpl_CBV cannot be cast to com..security.SecurityManagerRemote" at the first line in the code. I have also copied the ejb-jar.xml and ResourceLocator method. This is EJB 2.0

Would appreciate your help.


Thanks,
Sachin
If I populate the data as static members of the class on application startup, how do I make sure that the object stays alive as long as the application is up? Any kinda cache mechanism?

- Sachin

David O'Meara wrote:firstly don't use load-on-startup for anything that isn't related to bootstrapping the SErvlet. If you want to do it then use a ContextListener instead
Secondly, if you load and store the values, why hardcode it? Sure it can be hardcoded in the generated file from the build script, but on startup you can create an instance of a class for managing this information and then read and populate the data.
No need for dynamically creating and loading a class at runtime.

10 years ago
Hi,

I am working on restructuring and migrating an old J2EE app to our new unix environment(deployed in Weblogic server). As part of the ant build process we have a target that calls a GenerateDBMetadata.java file which creates a DBMetadata.java class by connecting to the database and getting a list of all procedures and storing them in a hashmap. This class is then compiled as part of the build process. I am trying to take this out of the build script and was wondering if i could call the class GenerateDBMetadata.java in a Servlet on application startup in weblogic server and then create and compile DBMetadata.java class. Will <load-on-startup> element in web.xml work for this requirement? I have never done this before and would greatly appreciate your inputs.

Thanks in advance for your help. Please accept my apologies if I have posted this in wrong forum.

Regards,
Sachin
10 years ago
I gave my exam yesterday and passed ... Yay !!! not too happy about the score though.

The # of questions were 60 and had 4 questions on Serialization which per revised syllabus should not be there on the exam. Is there a way to notify Oracle/Sun or Prometric about the testing centre and have them updated to the new questions set?

And a big thanks to Bert Bates and Kathy Sierra for writing such a wonderful book and making our learning process easier.

Regards,
Sachin Deokar
Hope this helps.


Prints 1 1
First "1" is the id for Main thread.
Second "1" is the Id for Main thread which is passed as argument to go(1) in run method which is executed as normal method call.

Compilation error. There is no start() method in Starter class

Prints 1 1
same explanation as 1. Calling run() directly just executes the code synchronously (in the same thread), just like a normal method call.
System.out prints the id for Main thread

Prints 1. A new Thread is created but never started (no call to start method)

Prints 1 8
"1" is the id for Main thread.
"8" is the id for new Thread that runs as a result of the call to start method.

Jesper Young wrote:
It's better to use class names that reflect the "is a" relationship. For example, make a class Animal, and a class Cat that extends Animal. A Cat is an Animal.



Thanks Jasper. I agree with you. My naming convention doesn't reflect the "is a" relationship and would be more mindful of that concept while naming my classes in future..

Thank you all for your comments and helping me clear my confusion.

Simran Dass wrote:
One which is closest in the inheritance hierarchy. Grandson extends Son , Son extends Dad.
So printObj(Son) is the closest one.



Thanks Simran.
How would you define "specific"?

Simran Dass wrote:
Hi ,

THis is bec the compiler looks for the most specific method. Among printObj(Son)
and printObj(Dad) method printObj(Son) is the most specific one. So the compiler gives
no error. But when you also have printObj(intrf) together with these two methods compiler
cannot find the most specific method and hence the error.

Thanks Sumit.

I do understand now that at runtime jvm gets confused between those two methods as they both pass IS A relationship and hence the runtime ambiguous error. Also, it maybe coz both are its immediate parents (Son is extended and Intfc is implemented by GrandSon).

But still trying to find the reason why the code works when I remove printObj(Intfc o) and just keep the two methods mentioned below? Out of these two options it chooses printObj(Son o). Is it coz Son is the immediate parent of Grandson and it is closer in hierarchy compared to Dad?



Harpreet Singh janda wrote:Hi Sachin,

As there is not exact match for a method printObj with a parameter "GrandSon". So the compiler will check for any other method which can be used in a polymorphic way, means any overloaded version which can be used by passing "GrandSon" object. Candidate methods are those which accepts the parent class of "GrandSon". In your code there are three such methods :



All of these three methods can be called by passing "GrandSon" as an argument. So compiler will be confuse because of multiple eligible methods and will not be able to conclude any single method to call, Hence throws an exception regarding ambiguous methods.


I agree Harpreet. But the code just works fine if i delete

If the option is between

It chooses 1st. Is it coz Son is the immediate parent of Grandson?

Thanks for your comments.

Sachin
Please refer to the code below. I am getting compiler error "The method printObj(Son) is ambiguous for the type GrandSon". Just want to better undertand reason for this error and also what are the other possibilities where i might get this error.

* This is my own code. Trying to understand Overloading and Overriding from Kathy Sierra/Bert Bates SCJP book pg 99


Thank you for your help.
Thanks Larry and Prithvi. I agree with you both about learning everything that's included in K&B. I just wanted to be sure if nothing new was added.