shikhar singh

Ranch Hand
+ Follow
since Oct 02, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by shikhar singh

Thanks for the response Edy,
My main aim is to remove the Information messages getting logged in the log files as mentioned in my original message.

As per my understanding the utility jar is not creating a datasource but instead using the Name Space Binding to get the reference to the Datasource created by J2ee Server, to create the DB connection. may be i am wrong in my understanding.

It works perfectly, If I do a direct lookup for the Datasource. But that results in the following informational message:
J2CA0122I: Resource reference jdbc/DSPPP could not be located, so default values of the following are used: [Resource-ref settings]

res-auth: 1 (APPLICATION)
res-isolation-level: 0 (TRANSACTION_NONE)
res-sharing-scope: true (SHAREABLE)
res-resolution-control: 999 (undefined)

I read a lot about this topic to resolve this issue. IBM docs says that depending on the place where Datasource need to be used, local resource reference should be created (in web.xml or ejb deployment descriptor)and binded to the actual datasource JNDI name.
This approach will remove the above annoying messages.

I did the same thing only to find that this approach does not work if the class performing the datasource lookup is in a jar under WEB-INF/lib. in another words the local resource refernce seem to be not visible to this class.

It will be very helpful if somebody can answer atleast one of the following question:
1. How to do the lookup to the local reference created in web module from a class which is in a Jar under Web-INF/lib?
2. How to configure the websphere server to supress the informational messages in the Log file.

Thanks a lot.
shikhar
20 years ago
We have a web module which uses a jar file added in Web-INF/lib folder. This jar file has a utility class written by us, which is used by our application to get DB connection.
This class is a simple one which does a lookup for the datasource, fetches the connection and returns it to the caller for use.
Everything works fine, except that we are getting following 'Informational' message in Websphere SystemOut.log file :
J2CA0122I: Resource reference jdbc/DSPPP could not be located, so default values of the following are used: [Resource-ref settings]

res-auth: 1 (APPLICATION)
res-isolation-level: 0 (TRANSACTION_NONE)
res-sharing-scope: true (SHAREABLE)
res-resolution-control: 999 (undefined)

I read in lot of articles (thanks to you guys) that a local reference should be used instead of directly looking up for the datasource name. So i followed this:
1. Created a Resouce Reference (datasource) in web.xml pointing to the JNDI Name : jdbc/DSPPP (jndi name of the datasource).
2. Used this Resource reference in the code to do lookup :
Properties p = new Properties();
//get local jndicontext
p.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory" );
p.put("com.ibm.websphere.naming.jndicache.cacheobject", "none");
javax.naming.Context jndiContext = new InitialContext(p);
DataSource ds = (DataSource) jndiContext .lookup ("java:comp/env/datasource");
Connection con = ds.getConnection();

The above code is in the Utility class i mentioned above, which is packaged in Jar and put under Web-INF/lib folder of web module.

Problem is : Seems like local reference created in web module is not visible to this utility jar. We get following error :
method.javax.naming.NameNotFoundException: Name "comp/env/datasource" not found in context "java:".

PS : If i put the above code in one of the class, directly under javasource of web module or in the JSP, it works beautifully, without logging the annoying Informational message.

So is there anybody who can give me some pointers about :
1. What is the way to access reference created in web.xml in the utility class added as a jar in web module?
2. Is there any other way of coding to get rid of this message?
3. if nothing works, is there any setting in Websphere server, tweaking which we can supress the 'informational messages' in log files.

thanks a bunch.
Shikhar
20 years ago
As we all know search in Oracle are case sensitive.
But how will somebody extract something like "java" when the actual value stored in db is "JaVa".
Is there any way to achieve this.
Any help would be appreciated..
Thanks
Shikhar
greetings!
I have a business problem where I need to store a list of values in a sequence associated with a key, in db. Let me explain in detail.
In my application, there is are different workflows defined in a company. Any proposal entered by anyone follows one of the workflow which is basically the sequence of the Approvers.
Proposal is accepted when all the approvers in sequence approves it. Whole of the proposal lifetime should follow the sequence of the approvers.
Now, in my database design, I have a table where I will be storing workflowID(primarykey to identify a workflow) and approvers(approverIDs) related to the workflow. But there should be a sequence for these approvers.
following are the options I looked into:
If there is a way in sql to store array, my job will be easy, because I just need to add the approvers in the array with proper sequence and store it in db as single record. But there is no datatype which can support this.Can blob do this?? If yes how do i retrive the value?
Other way is to store the user in a sequence as comma delimited string as one record but disadvantage is parsing and creating the string for every read/write.
One more way is to maintain a seperate column for sequence number. But the biggest problem in this approach is when the user modifies this sequence drastically and in that case i need to take care of sequence number.
I will be thankful, if somebody could advice me on this.
Shikhar
Hi,
Working on a code where I will provide a class to read/update some attributes.
Options with me are:
Store in DB
Store in Property File
Store in an Interface.
I decided to go for the Property File.
I thought I will make a singleton class and will read the attributes during the loading of class. Because there will be a silgle instance every call (read or update) will go through it.
Everything going fine. But hey!! In distributed env where we can have more then more then one JVM, how this is going to work.
Is there any work around?
Then I thought, drop the idea of singleton class, I will read the attributes from the property file and everytime somebody trys to read a attribute, I'll check the timestamp of the file. If it is different from the previous one, Update the properties.
Is this the right approach? Isn't this going to be performance overhead. I know this might be a common problem.
Is there any alternate or better way to go about this.
Would appreciate your response..
Shikhar
23 years ago
Vaibhav, Peter, Jason
Thanks a ton for these suggestions. I learned a lot from your adivices. I've gone thru each words of yours and we have already started fixing this.
By the way I have following queries:
1.(As Vaibhav said) How do i explicitly kill my session variable and session itself?
2.(As Peter said :inspections by a J2EE guru.)How can i get a external java Guru who can inspect my application's architecture?
3.(As Jason asked me oes this mean you guys embedded all your code in jsps)
No not exactly. Actually we ported ASP/C product to JSP/Java. So basically we inherited this thing from previous product. Java code is heavily embedded in our JSPs. Still we are using javabeans, which just routes the call to server classes. I know the advantages of MVC model but its too late to implement this. Can you suggest some place(site), where I can get information about, better ways to design and write JSP driven applications.
Thanks a lot again.
23 years ago
I have just completed a big project on E-CRM, but in the end stage of our project we realized that there was flaw in our approach, which is turning out to be very dangerous. My JSPs are not threadsafe and global variables are declare in most of the jsps moreover jsps are included with global functions (within <%! %> tag). These global functions as well as service method accesses these variables.
We deployed our application at customers site but now under heavy loads we are facing synchronization problems. Like entry of one user sometimes interchanges with the entry by other user. This happens when both the operations are done at the same time and there is heavy load on the server. This is obviously a very serious bug.
I can follow two approaches:
1. make all the jsps threadsafe by synchronizing the service method: but this will reduce the performance (i am using weblogic server).
2. make all global variable declarations with in the service method and pass the same in whichever global functions it is required : but over project is a huge one (around 700 Jsps), this will involve a huge amout of changes, which we can't afford at this time.
So, point 2 is out of question.
Brecause this seems to be a very common problem, can somebody tell me what is the best solution to deal with this. Is there any other way other then above two points..
This will be a very very big help to me..
Thanks a lot in advance..
23 years ago
Hi
I want to achieve a simple functionality but in a very efficient way. let me ask using an example:
I want to update the department of first 20 employees where employee manager is 'Ramesh'(say). And there are 500 employees under Ramesh and 5000 employees in the company.
And employees table have following fields:
Employee ID(PK), Manager name, department.
How can I meet this goal without firing minimum number of queries.?
I don't want to use batch statements.
Actually making the batch of different SQL statements and submitting it to database will avoid the number of calls made to the database. But the number of queries will be the same.
Your view will be very helpful
Thanks
Hi,
I am working on a CRM project and facing a problem, which needs to be fixed, urgently.
In my application there is a Mailbox and there is a owner of the mailbox. At the time of loading attributes of all emails (to, bcc, cc, content, subject....etc etc) are fetched from the DB and populated in an java object(this object contains a Vector further containg the above fields), at app server. In JSP this object is converted to a string containing the detail and is send to the JavaScript. Now here it(java object) is converted to a javascript variable and stored in the browser. This object is used to pl remember this object contains information about all the emails in the mailbox)
1.update the User interface and
2. to cache the details of the emails to improve client speed and minimize the server trips.
My first purpose is solved but the second case is posing problems. This is due to the corruption of this huge javascript variable over a period of time.
Now i am planning to pass the emails information in XML format and storing the same in DOM object instead of javascript variable, but I don't know how to access XML tags from Javascript.
This is required because my code for updation of UI and cache implementation lies in the Javascript.
So can somebody tell me:
1. How to access XML tags from javascript code.
2. whether my approach to the problem is correct.
Thanks for your time and looking for help...
Shikhar
Hi all,
I'm not sure whether this is the right forum to place this problem.
I have developed a mail management system. In this the mail coming from the customer can be routed to different agents(employees), by the mail administrator(or by some service). Agents have to give reply to these mails. So customer emails will be routed to the different agents.
According to my design, while loading my application on agents machine (client), I use to get the 'from', 'subject,'date' field of all the emails in the mailbox(just a microsoft outlook).
Agent(user) can click on any email to see the details of a mail.
So in brief, While loading the application I gets the summary of all the emails and I use this summary till the user logs-in again or presses 'refresh button again.
But the problem is, more then one agent can work on a same mailbox. So the agent can be working on the email which is alredy replied by the other agent.
My question is:
Is there any way to intimate the client that something is changed in the 'mailbox' table in the database. I don't know much about DB, but can the concept of triggers help here.
Thanks in advance
shikhar
Hi
Thanks for reply..
but if you run my program, you will notice that the result is very consistent. According to my program ,everytime it shows that memory difference(memory taken by instance of vector) is 1376 bytes. Does this mean that Vector instance takes 1376 bytes for my JVM.
Also can somebody tell me ,approximately how much is the memory taken by a vector instance.
Thanks for the help so far
Shikhar
Hi everybody,
can somebody tell me whether this program will give me the exact memory taken by the Object created.
import java.util.Vector;
class testmem
{
public static void main(String[] args)
{
Runtime rt = Runtime.getRuntime();
long start, end;
rt.gc();
start = rt.freeMemory();
Vector j = new Vector();
end = rt.freeMemory();
System.out.println("That took " + (start-end) + " bytes.");
}
}
If this program does not, can somebody tell me how we can find how much memory is taken by an object.
Thanks in advance
Shikhar
Hi all,
I've an application where on the IE browser, I loads various JSP files in different frames. When I checks the memory consumption (in Task Manager of windows NT), it takes 25MB after loading the application on browser. If I work on the browser, this memory taken varies between 25 - 30 MB.
But the strange thing is if I minimizes the browser and maximizes it again memory taken by the browser reduces to 5MB(???). And after that it varies between 5-15MB.
This looks to be very strange to me. Is this because when I minimizes the browser, it runs Garbage collector, which releases the memory taken by my javascript objects.
FYI, I use to load many(10-12) Javascript files while loading the application. Also I'm using .png files to display pictures.
If anyboby has idea about this pl help me, because this can help me to improve the memory consumption of my application.
thanks
Shikhar
Hi,
please can anybody tell me how I can find the memory taken by a JavaScript object.
I mean is there command or function which i can use o find the memory taken by my object?
Thanks
Shikhar
Hi all
Thanks for yor precious advices..
I am trying to implement Maha Ana's suggestion.
Aaron, you asked why I want to display all the emails at a time. Actually, It is just like Microsoft Outlook, where the summary (date, subject, sender's address..etc ) is displayed to the user.
Now whent eh first time the user logs in I use to fetch all these summaries in a object and pass it to client. So, my problem is, if the client wants to sort the tickets(you can imagine it as an email), should I do it in JavaScript.
I already implemented this thing in JavaScript by using Quick Sort algorithm. I tried this with 100 tickets/emails, and it the speed is acceptable.
According to Aaron's idea, I've decided to display few emails at a time(in our case 100-150).
Can anybody tell me that is this a bad approach or this can cause some problem of any sort.
I'll also try Maha Ana's idea to POST the string to JSP, sort it and send it back to the client.
Moreover I don't want to fire a query to the database(to get sorted data), coz I'm already holding this data on client side and useing this for other operations (like caching the content of the email).
Thanks again all of you for your precious time and advices...
shikhar
23 years ago