Sib Pete

Greenhorn
+ Follow
since Apr 27, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
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 Sib Pete

I have a JEE EAR application deployed on 2 clusters (with 2 instances each) in a GlassFish v3.1 application server loadbalanced by an apache server with mod_jk. One of the issues that I am currently facing is that every morning I have almost 100 users accessing the application at 8 am when they start their work and then they access it on a regular basis through the rest of the day. The performance on a normal one person usage scenario is pretty consistent with less than 5 second response time for loading the main page. However, the performance in the mornings when there is a mass hit is pretty bad. Can you advise me on what I can do to improve this?
12 years ago
Joe, thats a very good link for a quick intro on EJBs. I was about to start typing out a long winding post on what EJBs are, the different types, when they should be used, etc., but thankfully I decided to take a quick look at the wiki link and it pretty much did a much better job than I could of answering the question. Thanks for the link
I find Manning Publications EJB 3 In Action to be very informative and helpful in learning EJB 3. A book specific to DI is Dependency Injection by Dhanji R. Prasanna
0 down vote favorite


I am trying to create a web application with ICEFaces 2.0 as front end on GlassFish v3 with Hibernate 3.6 as JPA 2 provider talking to DB2 v9 on the Mainframe. I am using NetBeans 6.9.1 IDE for this.

I was able to successfully test and configure JDBC connection pool on GlassFish using the DB2 jdbc drivers (db2jcc4.jar and db2jcc_license_cu.jar). I was also able to successfully query DB2 from a standard java application using RESOURCE_LOCAL in persistence.xml.

However, I am not able to query DB2 using Glassfish datasource even though I am able to ping it from the Admin Console. I keep getting the following exception:


Any help would be truly appreciated. I am going nuts trying to figure this thing out. I tried the default EclipseLink that comes with NetBeans and get the same result.

Here is my persistence.xml

If you are using Remote interface then use the attribute mappedName="something" with the @Stateless annotation and then for invocation, use the attribute mappedName="something" with @EJB annotation.

On the other hand, if you are using the Local interface then use the attribute name="something" with the @Stateless annotation and then for invocation, use the attribute beanName="something" with @EJB annotation

To summarize:
For Remote:
@Stateless(mappedName="ejb/bean") ...
@EJB(mappedName="ejb/bean") ...

For Local:
@Stateless(name="bean") ...
@EJB(beanName="bean")....

Hope that clears things up.
Hmm .. further investigation revealed the following in the imq logs:

[17/Nov/2009:10:27:57 CST] ERROR sendMessage: Sending message failed. Connection ID: 427038234214377984:
com.sun.messaging.jmq.jmsserver.util.BrokerException: transaction failed: [B4303]: The maximum number of messages [1,000] that the producer can process in a single transaction (TID=427038234364096768) has been exceeded. Please either limit the # of messages per transaction or increase the imq.transaction.producer.maxNumMsgs property.



So what would I do if I needed to send more than 5000 messages at a time?

What I am trying to do is to read all the records in a table and update a particular field of each record based on the corresponding value of that record in a legacy table to which I have only read only access. This table has more than 10k records in it. As of now, I am sequentially going through each record in a for loop, getting the corresponding record from the legacy table, comparing the field values, updating the record if necessary and adding corresponding new records in other tables.

However, I was hoping to improve performance by processing all the records asynchronously. To do that I was thinking of sending each record info as a separate message and hence requiring so many messages.
14 years ago
I am guessing you could set the "rendered" property to some method of the backing bean that reads the hidden field. So you would have something like:

<jsf:component id="someId" rendered="#{ManagedBean.methodThatReadsHiddenField}"/>
14 years ago
JSF
I have used Quartz in the past and I find that it works really well for my needs. I especially like the fact that I can use cron expressions to schedule tasks. Besides that, there are also other features that I can see as being very beneficial such as the JDBC store, where you can use a database to persist the scheduled tasks which helps in scaling, clustering, high availability, etc., a default Quartz Initializer Servlet which I can just use as is, easily configurable tasks via xml or properties and so on.

Granted, I havent worked with EJB timers, so I am really not sure what its pros and cons are and how it compares to the Quartz scheduler.

It took me a little while to figure out the whole Quartz scheduler api, configuration and how to get it up and running, but going through all the documentation and samples helped me to easily figure it out.
I am currently using Glassfish v2.1 and I have set up a queue to send and receive messages from with Sesion beans and MDBs respectively. However, I have noticed that I can send only a maximum of 1000 messages to the queue. Is there any reason why I cannot send more than 1000 messages to the queue? I do have a "developer" profile setup for the glassfish domain. Could that be the reason? Or is there some resource configuration setting that I need to modify?

I have added the following configuration properties in the sun-resources.xml file for glassfish:


14 years ago

Do we call @Resource Annotations as Method Level Annotations . and @Stateless as Class Level Annotations .



The @Stateless annotation marks that the class is a 'Stateless' session bean implementing some local/remote interface and that should it be handled accordingly by the container.

The @Resource annotation on the other hand can be either a method level annotation if its used on a setter method or also a field level annotation if used on a declaring field statement. What this annotation does is that it lets the ejb container know that the particular resource needs to be injected and set via dependency injection on invocation.
How have you mapped the session bean, implementing the NewSessionRemote interface, jndi name, 'endpoint.NewSessionRemote' ? Are you using annotations or are you using the ejb-jar or web.xml to map to jndi?
I added the following annotation to enable cache to one of my EJB3 entities to test caching where I use Hibernate as the persistence provider:



I added the following to persistence.xml :



And when I try to compile I get the following error:

/persistence/F.class): warning: Cannot find annotation method 'usage()' in type 'org.hibernate.annotations.Cache': class file for org.hibernate.annotations.Cache not found
An exception has occurred in the compiler (1.6.0_16). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for org.hibernate.annotations.CacheConcurrencyStrategy not found



Can anyone help me out here and let me know what I need to do or am doing wrong currently ?

Thanks.
Things are starting to make more sense. So in my case, I definitely need to use the EntityManager.getReference() method. But the issue still remains that it returns an instance of a proxy class, i.e., when I do a getClass() method call on the object returned by the getReference() method, the object's class is of type, $$EnhancerByCGLIB$$.
I do have the FetchType.Eager setting on the object.

I think the problem is that when I am calling the getReference() method, I am using the input parameter entity object's getClass() method which is actually a proxy class as returned by the earlier getReference() invocation. If use the static LClass.class instead, then it works fine.

So: LObj = EntityManager.getReference(LObj.getClass(), LObj.getId());

now becomes : LObj = EntityManager.getReference(L.class, LObj.getId());



I have come across a situation (which I think is weird but is possibly quite normal) where I use the EntityManager.getReference(LObj.getClass(), LObj.getId()) to get a database entity and then pass the returned object to be persisted in another table.

So basically the flow was like this:



I was getting the following exception "java.lang.IllegalArgumentException: Unknown entity: com.my.persistence.L$$EnhancerByCGLIB$$3e7987d0"

After looking into it for a while, I finally figured out that it was because I was using the EntityManager.getReference() method that I was getting the above exception as the method was returning a proxy.

This makes me wonder, when is it advisable to use the EntityManager.getReference() method instead of the EntityManager.find() method?

EntityManager.getReference() throws an EntityNotFoundException if it cant find the entity being searched for which is very convenient in itself. EntityManager.find() method merely returns null if it cant find the entity.

With regards to transaction boundaries, sounds to me like you would need to use the find() method before passing the newly found entity to a new transaction. If you use the getReference() method then you would probably end up in a situation similar to mine with the above exception.

ps.
I am using Hibernate as the JPA provider.