I was running a snippet of code in one of my Jython libraries which is being built to create and manage JDBC provider’s, Data Sources and J2C aliases; when I came across this error:

Looking at the code around the line number reported, I found code similar to the following:


#-------------------------------------------------------------------------------------
#Modify Method...
#-------------------------------------------------------------------------------------
def modify(self) :
logger.debug( "ENTER modify()")
logger.debug( "EXIT modify()")
#endDef

#-------------------------------------------------------------------------------------
#Create Method...
#-------------------------------------------------------------------------------------
def create(self) :
logger.debug( "ENTER create()")
#Setup the instance vars
self.setProviderBeanIds()
if(self.wmqCFExists()==0) :
logger.info( "create: self.__providerBeanObjectId: " + self.__providerBeanObjectId)
logger.info( "create: Generate attributes: " + self.getAttributes())
AdminTask.createJDBCProvider( self.__providerBeanObjectId, self.getAttributes())
logger.info( "create: Saving configuration after setting new attributes")
AdminConfig.save()
logger.info( "created successfully")
else :
logger.warn("JDBC Provider [" + self.__name + " ] for scope [" + self.__scope + "] already exists, modifying exiting entry")
self.modify()
#endElse
logger.debug( "EXIT create()")
#endDef

Reasons for Error: Well as you can see above the code snippet (ie a piece of a larger Jython library file) has a method called “modify” but it has no local code, and Jython does not like a declared function with no internal/local code defined.

Solution:

Either don’t call the “modify()” method or if you want to call it, but have not yet coded the implementation, then just add some log statements for print statement to create some local placeholder code. For example.


#-------------------------------------------------------------------------------------
#Modify Method...
#-------------------------------------------------------------------------------------
def modify(self) :
logger.debug( "ENTER modify()")
logger.debug( "EXIT modify()")
#endDef

Facebooktwittergoogle_plusredditpinterestlinkedinmail

Leave a Reply