Prateek Kumar Singh

Ranch Hand
+ Follow
since Jan 21, 2011
Prateek Kumar likes ...
Hibernate Eclipse IDE Oracle
Pune India
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Prateek Kumar Singh

I have created a PDF using iText and set the total number of copies to 2 using

when I'm printing the PDF by default 2 copies are printing. But when I select the paper tray using below step

Then the number of copies is set back to 1 in Adobe print pop up. I'm using Adobe reader XI.

Is it possible to set to 2 when I select the the tray using iText? What could be solution for that ?
Hi Experts,

I want to know to know the step by step operation perform by java if we are going to add duplicate value in Set.
6 years ago
Hi Ranganathan,

Here idea behind singleton session bean in EJB is We will have a pool of bean instances and that pool will maintain only one bean instance.On each request that bean instance will return to user and get back to pool once job completed. all requests to the singleton will be routed to the single instance of the Singleton bean instance.
A singleton EJB ensures there is only one instance of an EJB in a application. There will be many instances of a stateful session bean (one per session) in a n application.

To maintain the concurrency in your application If you are using container managed concurrency the container may lock on read or write access (or both). So for synchronization programmer need to implement there own logic in application.

In Jboss 6.0 we can create a pool of instance by using @pool annotation. -

this annotation can be applied to a stateless or message driven bean class.

Pool in JBOSS 6.0
Hope this link will help you.


I have implemented a simple jaas application and getting tired by the exception

java.lang.ArrayIndexOutOfBoundsException: 10
at Method)
at com.jaas.auth.LoginModuleTest.main(

I have override the initialize method.
Please help.
Hi guys,

I have a requirement to implement Singleton session bean with EJB3.0 and JBOSS6.0. (please post with an example) ?
Hi Guys,

The wait(), notify(), and notifyAll() methods are used to provide an efficient way for threads to communicate with
each other. This communication solves the ‘consumer-producer problem’. This problem occurs when the
producer thread is completing work that the other thread (consumer thread) will use.

Example: If you imagine an application in which one thread (the producer) writes data to a file while a second
thread (the consumer) reads data from the same file. In this example the concurrent threads share the same
resource file. Because these threads share the common resource file they should be synchronized. Also these
two threads should communicate with each other because the consumer thread, which reads the file, should wait
until the producer thread, which writes data to the file and notifies the consumer thread that it has completed its
writing operation.

Let’s look at a sample code where count is a shared resource. The consumer thread will wait inside the
consume() method on the producer thread, until the producer thread increments the count inside the produce()
method and subsequently notifies the consumer thread. Once it has been notified, the consumer thread waiting
inside the consume() method will give up its waiting state and completes its method by consuming the count (i.e.
decrementing the count).

Hi Nam Ha Minh,

I am interested in Java Technical Writing, I have 2+ years of experience as a Java Developer.
I have hands on Core Java, JPA,JSF,EJB 3.0, Hibernate.

Thanks & Regards,
Prateek Singh
7 years ago
Hi Guys,

The actual answer of this question is
The h:panelGrid tag is used to represent an entire table. The h:panelGroup tag is used to represent rows in a table.

The columns attribute defines how to group the data in the table and therefore is required if you want your table to have more than one column. The h:panelGrid tag also has a set of optional attributes that specify CSS classes:columnClasses, footerClass, headerClass, panelClass, and rowClasses.

A pannel group is set of row in table.

7 years ago
Hi, Finally i got the solution behind this issue.

1. Check your faces config.xml file for JSF version.

2. The reason of the JSF components not being parsed at all indicates that the FacesServlet hasn't run. This will happen when the request URL doesn't match the url-pattern of the FacesServlet as definied in web.xml. This would mean that the actual url-pattern of the FacesServlet isn't *.xhtml at all. so you can add like -

and access your page like loginPage.jsf .

Hope it helps someone.
7 years ago

Case 1. When we are using + operator then like StringBuilder is used to concatenate. After concatenation the resultant StringBuffer or StringBuilder is changed to String.Its take following steps

1. A StringBuffer object is created
2. string1 is copied to the newly created StringBuffer object
3. The “*” is appended to the StringBuffer (concatenation)
4. The result is converted to back to a String object.
5. The string1 reference is made to point at that new String.
6. The old String that string1 previously referenced is then made null.

Case 2. In case of string concatenation
str1.concat(str2) simply makes a new string that's the concatenation of str1 and str2, which is less expensive for a small number of concatenated strings .

Prateek Singh

7 years ago
After some r&d i find some interesting reasons for why String class is immutable .

there are following point which makes String class immutable -
1. automatically thread-safe and have no synchronization issues
2. do not need a copy constructor
3. do not need an implementation of clone
4. allow hashCode to use lazy initialization, and to cache its return value
5. do not need to be copied defensively when used as a field
6. make good Map keys and Set elements (these objects must not change state while in the collection)
7. have their class invariant established once upon construction, and it never needs to be checked again

Prateek Singh
8 years ago
can any body elaborate that what is use of Backed Collection in java.

Prateek Singh
The problem occurs because of the JVm has run out of memory ,so you should run garbage collector operation on your JVM until the VM gets deallocated of unused memory .

When you get OutOfMemoryError, it means that (so obvious) your application doesn't have enough memory to go on. But the rest of the message, wants to inform you that it's not the common object heap space that it's lacking, but only the memory space for the binary code of classes and methods is lacking.
you can increase your heap size by following example command

here you can easily define Permanent Size(Permsize) and Maximumum permanent size(maxpermsize).

you can also try a solution to increase the total Ram size of your machine.

hope it helps.
8 years ago
actually you are going wrong here that define named query in bean class and creating it in same class
your named query should be in entity class and named query for example

if you want to create named query in bean class then follow this example

hope it help you.

when i am using

its stuck in error :

javax.faces.view.facelets.TagException: /enter.xhtml @21,72 <p:defaultCommand> Tag Library supports namespace:, but no tag was defined for name: defaultCommand
at com.sun.faces.facelets.compiler.CompilationManager.pushTag(

i am using primefaces3.2 jar and namespace

anybody have solution of it?

thanks in advance
8 years ago