views:

21

answers:

1

I have performance problem while doing first API call to my J2EE applications. So I wanted to do Class.forName to preload the classes while doing application initialization. But I heard that it is prohibited by J2EE standard/BEA implementation (I might be completely wrong). Is it so? Are there any other limitation of doing forName in J2EE container.

+1  A: 

I have performance problem while doing first API call to my J2EE applications. So I wanted to do Class.forName to preload the classes while doing application initialization.

So basically, you just want to move the overhead :) I don't see the difference (user experience maybe) but ok, why not.

But I heard that it is prohibited by J2EE standard/BEA implementation (I might be completely wrong). Is it so? Are there any other limitation of doing forName in J2EE container.

The context is a bit unclear but, to my knowledge, it isn't. And that's actually something that the Pet Store app is/was doing. Quoting EJB Restrictions:

Why all the restrictions on creating class loaders and redirection of input, output, and error streams?

Class loading is allowed, but creating custom loaders is not, for security reasons. These restrictions exist because the EJB container has responsibility for class loading and I/O control. Allowing the EJB to perform these functions would interfere with proper operation of the Container, and are a security hazard.

The Java Pet Store has code that loads classes from inside an enterprise bean class using Class.forName(), in StateMachine.

But why don't you just try it?

Reference

Pascal Thivent
Regarding "So basically, you just want to move the overhead :) I don't see the difference (user experience maybe) but ok, why not.", my API takes around 1 min - 5 min, when first time I call it.. so timeout occurs for most of the time; when i bounce weblogic server
j2eehacker
@j2eehacker Ok, I see. But where are you going to make that call if you move it?
Pascal Thivent