-
1. Re: Reset client InitialContext after server restart
mikefinn Nov 21, 2002 11:39 PM (in response to sieroka)So, the client lives through a cycle of JBoss, and anything looked with a InitialContext fails, even if the InitialContext is new?
In your source, it looks like you do 2 JNDI lookups - one of pLookupName, and one (I suspect) buried in your ResourceLoader class of AuditLogCRUD. Are you saying that neither works? Is the object from the lookup call actually always null?
Also - a version of JBoss would be nice... :-)
Mike -
2. Re: Reset client InitialContext after server restart
sieroka Nov 22, 2002 1:34 AM (in response to sieroka)It's the latest, 3.0.4. We use this class for all lookups. We cache any lookups and InitialContexts. If the use of the cached ejb reference fails, we try to look it up with the existing InitialContext. If that fails, we call the following code to load the InitialContext again, and then the ejb again. This does return a different InitialContext object (I verfied this with some temporary log statements, ie. different hashcode), but then when we look up any ejb, we get the behaviour describes in the previous posting (NPE every time).
One interesting thing. I was connecting over a VPN, and disconnected the VPN connection, reconnected, and everything worked as expected. ie. got a valid new InitialConext. It seems that only when the JBoss server is restarted that this occurs.
try
{
lInitialContext = new InitialContext( pHashtable );
lOldInitialContext = (InitialContext)sInitialContextHashMap.put( pHashtable, lInitialContext );
if ( lOldInitialContext != null ) {
try
{
lOldInitialContext.close();
}
catch( Exception e )
{
// do nothing
}
}
}
catch( Throwable e )
{
sLog.error( "Unable to load InitialContext" ); -
3. Re: Reset client InitialContext after server restart
sieroka Nov 25, 2002 12:19 PM (in response to sieroka)Any thoughts here? Is there any way I can clear the InitialContextFactory's cache? Get it to reset somehow? Any pointers of where to look in the JBoss source code would be helpful as well, maybe I could hack it up for our use... Thanks.
-
4. Re: Reset client InitialContext after server restart
sgturner Nov 26, 2002 9:12 AM (in response to sieroka)Is it a matter of time? I mean, when Jboss restarts, you got to give it some time before trying to get the new Initialcontext. I have some similar code as you. In my code I configure 2 variables. 1-the number of milli seconds to wait until client tries again and 2-the max number od tries. Seems to work OK.
-
5. Re: Reset client InitialContext after server restart
sieroka Nov 26, 2002 9:18 PM (in response to sieroka)I've waited quite a long time. What properties are you using with your InitialContext? Are you using 3.0.4? Any other ideas?
-
6. Re: Reset client InitialContext after server restart
sgturner Nov 26, 2002 11:22 PM (in response to sieroka)I don't know if I tested against 3.0.4.
My wait interval is 3000 milliseconds with a max of 10 intervals.
Your post makes me think I need to do a more formal test of my code to make sure. I'll do that and post results here. -
7. Re: Reset client InitialContext after server restart
sgturner Nov 27, 2002 9:18 AM (in response to sieroka)I did not do a formal test, but here is what I did. Changed my wait interval to 5000 milliseconds and change the max number of intervals to 12.
Then I ran my client program and it did what it was suppose to do - try and get InitialContext every 5000 milliseconds.
While that was happening, I started up JBoss without my Ejbs being deployed. After JBoss was up, I deployed my Ejb jar file.
After the Ejb jar got deployed, the client side was able to continue successfully.
This was using JBoss 3.2 -
8. Re: Reset client InitialContext after server restart
sieroka Nov 27, 2002 8:27 PM (in response to sieroka)These are the properties I use to connect. Am I missing anything?
Looking up InitialContext: {java.naming.provider.url=192.168.50.99, java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces} -
9. Re: Reset client InitialContext after server restart
sgturner Nov 27, 2002 9:55 PM (in response to sieroka)Here is what I do:
Properties props = new Properties();
props.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
props.put("java.naming.provider.url","jnp://<your_id_address>:1099");
props.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
Context ctx = new InitialContext (props); -
10. Re: Reset client InitialContext after server restart
sieroka Dec 6, 2002 6:59 PM (in response to sieroka)Has anyone tested something like this with 3.0.4? I noticed you used jnp://ip:port, where I only had ip. I tried this, but had the same results. Our client application must be restarted after the server is restarted.