cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot lookup LogicalLockingFactory from custom SFTP Adapter

Former Member
0 Kudos

Hi,

We developed an SFTP Adapter on a clustered Advanced Adapter Engine.

When we try to lookup the LogicalLockingFramework, we get a ClassCastException and the proxy Class is missing the Interface LogicalLockingFactory.

We use the following code for the lookup:

LogicalLockingFactory lockingFactory = null;				
lockingFactory = (LogicalLockingFactory) new InitialContext().lookup(
		LogicalLockingFactory.JNDI_NAME);

Does anybody have an idea, wht the problems could be?

Thanks in advance,

Gernot

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Hi Gernot,

i think you are right in this forum.

You receive this ClassCastException probably because the class loader which tries to load the class is not application classloader. I suggest change the class where you change the classloader.

So you should change the source like this

ClassLoader oldClassLoader =                                                                   
Thread.currentThread().getContextClassLoader();                                                
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoa                       
der());                                                                                
try {                                                                                
//Perform the lookup here                                                                                
} finally { // this step is very important!                                                    
   Thread.currentThread().setContextClassLoader(oldClassLoader);                                  
}

It is very important to return back the original contextClassLoader when the lookup finishes.

Best regards,

Martin

0 Kudos

Dear Martin,

Thank you SO MUCH! I´ve been struggling with this for many days and your solution works just fine. Thank you!!!

Answers (1)

Answers (1)

JoelTrinidade
Active Contributor
0 Kudos

Hi Gernot,

You are asking the wrong question at the wrong place. SFTP comes under the purview of Microsoft Biztalk and this is a SAP PI forum.

Regards

joel

0 Kudos

The place is Ok. This is a PI custom adapter, not related to Microsoft Biztalk but to J2ee and PI development.