Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

pasquale vitale

+ Follow
since Aug 22, 2008
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 pasquale vitale

Thank you Stephan,
your solution is great, but I cannot start N thread at same time.
Anyway, I used my solution and in the Task thread class I'm using a synchronized clause on param 'i' (object = Integer),
so I'm sure that the next thread waits the end of previous task.
In the run() method I'm using also List<Integer> completed to jump all next task(i)
Thanks a lot for replay, guys.
To be honest, here my requirements (for example N=2, i=3, X=3):
1. start N process in parallel with different 'i' param; so I need to run 3 tasks starting form 1 to i: task(1), task(2), task(3)
2. execute any tasks X times
3. if an instance finishes sooner, it can proceed to the next task

I've used Executors.newFixedThreadPool(N) and my params are i*X = 9, i.e. [1,2,3,1,2,3,1,2,3].
At this point my test was ok. I run 9 tasks, and only N=2 threads at time.

The problem is when I've added a new requirement: if a task(i) is ok then it's not necessary to run again for that 'i' but If it fail, I can run again, of course, until 3 times.
I tried to add in my Task a list of 'i' param (List<Integer> completed) where the execution is OK; so I check, in the run method, if that 'i' param is in the list to jump the execution.
But in this case there is the possibility to run 2 tasks with same 'i' param if that 'i' is not in the completed list, and I want to avoid this, for example I want to wait this execution.

Now I don't know if this approach is fine after this new requirement or I have to change approach.
Thanks for replay,
I don't want to run 2 threads that use the same 'i' param; for example 2 thread: task(3) and task(3)
Hi all,
I have to start N tasks in parallel. Any tasks must use a parameter (i) to perform some executions and they take few seconds or a lot of minutes, it depends on 'i' param.
In my tasklist, I can have also multiple values of 'i' to repeat the same task; for example [1,2,3,1,2,3].
Of course, if a task finishes sooner the execution, it can proceed to the next task.
Any tasks return true or false to define if execution is ok or not. If task(x) is ok I can run the next task (and jump all next tasks with x param because x is ok)
Let suppose to use N=2 (2 thread), with task 1 and task 2 are fast, and task 3 takes a lot of time;
there is this possibility that more thread can run on the same task(i) because they are running, and I want to avoid this.
For example the thread1 is running the task(3) and the thread2 can run also task(3) (after task(1) and task(2) are ok and fast) because for param 3 there isn't OK yet.  

Is it correct to use newFixedThreadPool?
Could you help me?
Thank you in advance.
Hi all,

I've this Rest service class with annotation:

and I'm using this code to call the service:

It works, but the response is json. If I remove the annotation MediaType.APPLICATION_JSON in the @Produces, I get the XML response.
How can I get the XML response from above code whitout change @Produces?

Thank you and regards

8 years ago
Thank you,

I've resolved my issue; I've used

and I need to xml in header:
headers.put("Content-Type", "application/xml");

8 years ago
Hi everyone,
I'm new in Rest Assured.
I have my Rest service like this:

Now, I want to use RestAssured to call my "hello" service but I don't know how can I do it.
In the first example, I had a GET method and I've used:

Please note that my hello method takes a name parameter.
Could you help me?

8 years ago
Hi all,
I am newbie in Restful services.

I'm using jersey, I've just created a "HelloWorldService" class with annotations, and I've deployed it on tomcat 7.
To get the WADL I've just clicked on link http://localhost:8080/RESTfulServer/rest/application.wadl. It works.

My question is this:
is there a way to get the WADL file using only annotation java class without deploy it under tomcat?

Thank you

8 years ago
Hi all,
I'm preparing the OCPJWCD exame. Here is the question

Which annotation specifies the metadata as a javax.servlet.http.HttpSessionListener?

Answer: A

But I think that it is B.

Thank you
Hi all,
I have a problem; "OutOfMemoryError : java heap space" while I uploading.
If I use a file with size smaller 2MB, then it's works, else I have OutOfMemory Error.

I'm using tomcat server 6 under eclipse and jdk 6, richfaces 3.3 and hibernate 3.

Can you help me?

My error is:

java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Unknown Source)
at java.lang.AbstractStringBuilder.expandCapacity(Unknown Source)
at java.lang.AbstractStringBuilder.append(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at java.util.AbstractMap.toString(Unknown Source)
at org.hibernate.pretty.Printer.toString(
at org.hibernate.pretty.Printer.toString(
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(
at org.hibernate.impl.SessionImpl.flush(
at org.hibernate.impl.SessionImpl.managedFlush(
at org.hibernate.transaction.JDBCTransaction.commit(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
at Source)
11 years ago
Thank Mill,
I have created a my filter (that extends org.ajax4jsf.Filter) and into init() method I read my maxRequestSize param and it put in session.
In my bean I get my maxRequestSize param from session.
It's works

11 years ago
Hi all,
I'm using rich:fileUpload component in my app.
To restrict file size for upload, I have setting into web.xml the maxRequestSize param in the filter tag. It's works.

When I use for upload a file with size greater than maxRequestSize param, it is display out "File size restricted".

Now I have a properties file with internalization and in my bean (that uses rich:fileUpload component) I use a resourceBundle to change all label in fileUpload component:

<rich:fileUpload ... sizeErrorLabel="#{resourceBundle.msgSizeLimited}" .... />

Can I modify this message (msgSizeLimited) using maxRequestSize param?
I wish to get: "Use file size smaller than 'maxRequestSize param'".
If it is possibile, how can I do it?

Also I can to use my bean to format sizeErrorLabel:
<rich:fileUpload ... sizeErrorLabel="#{bean.stringSizeLimited}" .... />
but I don't know how to read a maxRequestSize param into web.xml.

Finally, only for info, can I to use a label as "Use file size smaller than {0}", and to use a <f:param ... /> into rich:fileUpload component?


11 years ago
Hi all,
I have a question: wss4j 1.5.4 implements a WS-I Basic Security Profile Version 1.0.

I see in the readme.txt file of wss4j 1.5.4 API that:

and in the WS-I Basic Security Profile Version 1.0 spec. (go to there are reference to OASIS Standard 200401, but I don't know if wss4j (version 1.5.4) implements WS-I Basic Security Profile Version 1.0 spec?
Can anyone tell me if that is true?

13 years ago
Hi all, I'm new with spring framework.

I have a bean AddExameForm with this parameters:

private String esame;
private String descrizione;
private List<Domanda> domande;

and the costructor is:
//initilize ArrayList with objects domanda
domande = new ArrayList<Domanda>(10);
for (int i=0;i<10;i++){
domande.add(new Domanda());

... setter and getter methods;

and bean Domanda is a bean with:

private String domanda;
... setter and getter

Now I want to populated my bean AddExameForm (with domande) and I using a binding; in the other words I want a form with 10 input (type=text) where I want to write my 10 strings (text) and then when I push a submit button I want to initialize my bean (my List domande) with my 10 strings.

My jsp code is:

<c:forEach varStatus="i" var="domande" items="${addExameForm.domande}">
<td class="blank"><cut value="${i.count}" /></td>
<td class="blank">
<spring:bind path="addExameForm.domande[${i.index}].domanda">
<input type="text" name="<cut value="${status.expression}"/>" value="<cut value="${status.value}"/>">
<font color="red"><cut value="${status.errorMessage}" /></font>

when I submit form I have this error:

javax.servlet.ServletException: org.springframework.beans.InvalidPropertyException : Invalid property 'domande[0]' of bean class [springweb.form.admin.AddExameForm]: Index of out of bounds in property path 'domande[0]'; nested exception is java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

Can you help me?
Thanks Pasquy
13 years ago