nikola petanjak

Greenhorn
+ Follow
since Apr 01, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
3
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 nikola petanjak

Paul Anilprem wrote:

Ramy Diab wrote:Hello All,



I need to know until which point exactly the extended persistence context is exist ?

Is it exist until the EntityManager instance is closed , or until all transactions invoked by the EntityManager ?

Thanks in advance



As per Section 7.7 of JPA 2.0 specification:


The extended persistence context exists from the point at which the entity manager has been created
using EntityManagerFactory.createEntityManager until the entity manager is closed by means of EntityManager.close.



You should go through chapter 7 of the specification. It will solve all your doubts.
HTH,
Paul.



This is true for application-managed persistence context, but for container-managed persistence context (section 7.6. in specification), i quote:

"A container-managed extended persistence context can only be initiated within the scope of a stateful
session bean. It exists from the point at which the stateful session bean that declares a dependency on an
entity manager of type PersistenceContextType.EXTENDED is created, and is said to be bound
to the stateful session bean. The dependency on the extended persistence context is declared by means
of the PersistenceContext annotation or persistence-context-ref deployment descrip-
tor element.
The persistence context is closed by the container when the @Remove method of the stateful session
bean completes (or the stateful session bean instance is otherwise destroyed)."

?
Hello,

today i passed with 76%. 70% was minimum, out of 87 questions.

1. ~5 questions are about security - HttpServletRequest + web.xml configuration
2. ~10 questions about composite components
3. 2 questions about custom components, without taglib descriptors
4. ~6 non-trivial facelets templating questions
5. ~4 questions about packaging JSF application, including taglib descriptors in WEB-INF
6. 10-15 questions about converters and validators - all you can think of
7. ~4 questions about GET requests (viewParams, h:link, h:outputLink etc.)
8. ~5 questions about navigation, simple and bit harder ones
9. ~10 questions with Ajax and/or some simple JavaScript - not too complicated IMHO
10. One question about PhaseListener, one about <h:graphicImage>, one exclusively about @Inject (WTF?), one about ui:debug
11. Few about Locale, some combined inside questions about converters
12. 10,15,20 questions "What is best practice" or "What scope would you use" - not that easy!
13. ~5 questions about actionListeners
14. 0 (zero) questions about ManagedProperty and ViewScope
15. 3 questions about datatables
16. few questions about <h:selectOneMenu> and <h:selectManyMenu>
17. few questions about lifecycle - "in what phase would you do this", "what phases are skipped if you do this" etc.
18. There were no questions about JSF 2.2 stuff (flowscope, statless view, HTML5 passthrough etc.)

At least half questions were verbose. I tried to follow advise from some people here who said, read answers first - it didn't help me much, maybe with 1 or 2 questions.
With few questions, i didn't realy understand what they wanted to ask, to be honest.

I learned from Core JSF, Java EE6 tutorial, BalusC @ stackoverflow + blog, and JSF 2.0 specification.

7 years ago
I forgot to mention - i think you should stop task that you are about to create when application start because if applicition don't stop "normaly" task will "live on" so when you start application you will have 2 tasks actualy.
Hi

Me neither have a lot of experience but i'll do my best to explain.

Context listener is in Web part of application, so in my web.xml file i register it (controller is a name of package, ContextListener is name of a class):



Also, your class must implement javax.servlet.ServletContextListener interface. ServletContextListener has two methods, one when application start and other when applicaiton stops:

Hello,

unfortunately i was forced to find another solution for automatic calling EJB method. I done it via WAS 7.0 Scheduler.

Short tutorial is on this link:

Calling EJB bean with WAS 7.0 Scheduler
Hello everyone,

considering the circumstances i was forced to find another solution for automatic calling EJB method. Unfortunately this was, for my opinion, less elegant and more limited solution.
I'll write short tutorial for how set WebSphere scheduler for all of you who got need to use it.

So here it is, using EJB 3.0 and WebSphere 7

1) Set scheduler in WebSphere console (you'll need database connection set as well, because scheduler automaticly creates few tables for managing tasks)

Go to resources -> schedulers -> new

Set JNDI name by which you'll call Scheduler from your application (in this example, it will be sched/testScheduler), and ofcourse choose database conneciton.

Poll interval - i'm not sure what is purpose of it because i set interval for tasks in application, but anyway i set it to 30min.

Table prefix - i guess choose whatever you prefer

Now after you created new Scheduler, select it in table (resources -> schedulers) and click 'Create tables'.

2) EJB part - i created stateless session bean and implemented com.ibm.websphere.scheduler.TaskHandler with all it's methods. Then i removed @Override annotations from implemented methods, and removed "implements com.ibm.websphere.scheduler.TaskHandler" part of code.

Before:



After:



Ofcourse, now i had to tell in ejb-jar.xml that my bean will implement com.ibm.websphere.scheduler.TaskHandler (as remote) and com.ibm.websphere.scheduler.TaskHandlerHome (as remote home):



Finally, here is code for setting and canceling tasks for particular scheduler (i call it in contextListener when application starts/stops)



So as you can see, taskInfo.setTaskHandler(home) is telling what bean will execute every time task is called.

Method to cancel all tasks with same name:





Hello,

i can't access test environment that easy so i'll just have to wait couple of more days...But i can tell you that timer was set properly after application was deployed (here's the original log):



1st println is 1st line in contextInitialized method.
2nd println is after setting Calendar to next day in 3 A.M. in contextInitialized method.
3rd println is from EJB in method setNewTimer, when called from contextInitialized, after createTimer method.

I think i'll try to set interval to 5 minutes to see how it goes...And update to 7.0.0.21 as soon as possible.

Also, i get this XA exception every now and then in logs (on test env.)...maybe that could be reason for timer not working, who knows.





Hi Jaikiran, and thanks for your reply.

Yes i printed cal.getTime(), the date and time are as it should be. The problem is very similar, it seems to me, to this one:

http://www-01.ibm.com/support/docview.wss?uid=swg21388449

so i hoped newer fix pack will solve it, but then i realized that my version is 7.0.0.9, and they
recommend upgrading to 7.0.0.3...
Hello everyone.

I am using contextListener to set EJB timer when application starts. Then, @Timeout method should be executed every 24 hours. On application stop timers are canceled.
I'm working with EJB3.0 and WebSphere Application server 7.0.0.11.

On my developing environment everything works fine, but on test environment @Timeout method is not called altough timer IS set in contextListener. I have exactly nothing in my logs at the timeout (test environment is on 7.0.0.9).

Any suggestions what could be reason for this behaviour besides different versions? I checked differences between these two versions but i haven't noticed anything related to EJB timers.

The overall code is rather simple:

ContextListener:



EJB timer:



EJB timer interface:



Thank you all in advance.

Nikola
Hi Tim, and thank you for your reply.

The problem is, our customer would like fancy solution. I would like to know is it possible to do that kind of refreshing/updating?
In my actual problem, i'd need to update few tables on page after new database update. Can i use ajax with jsf1.2?
12 years ago
JSF
Hello everyone,

can someone give me clue how to refresh JSF 1.2 page when database table gets updated? Alternative is also, that onMessage method in message bean trigger page refresh.

Thanks in advance.
12 years ago
JSF
I'm sorry but that's best advice i can give, as beginner.

Good luck.
12 years ago
JSF
I know my suggestion mind be trivial but,

have you tried value="#{simpleLogin.loginName}" (without capital S)?
12 years ago
JSF
Hi

Maybe you can get useful information from WebSphere trace.log?

Have you tried, in WebSphere console,

Troubleshooting -> Logs and trace -> /server_name/ -> Diagnostic Trace -> Change Log Detail Levels ?

There you can set, for instance,

openjpa.* -> (left click) -> Message and trace levels -> (fatal,severe,warning,info,...)

P.S. watch out for hard disk space
12 years ago
JSF