problem with import in jython postfunction script Jira

Hi

I'm trying to migrate from JIRA 4.2.4 to JIRA 6.2.7

Among other problems that I encountered, now it came out another

I have many post function with jython script

I also use JIRA rpc in those scripts

In JIRA 6 rpc plugin is bundled (as difference from 4.2.4 where i had to put it in /lib)

Now my jython script gives me error on import:

/secure/CreateIssueDetails.jspa [jira.plugin.workflow.JythonValidator] Unrecognized exception while executing Jyphon script: null

Traceback (most recent call last):

  File "<string>", line 2, in <module>

ImportError: No module named rpc

    at org.python.core.Py.ImportError(Py.java:290)

at line : "from com.atlassian.jira.rpc.soap import JiraSoapService"

The plugin shows that is enabled in JIRA

Please Help me to resolve that import so that my scripts continue to work

 

Thank you

MCTibi

 

 

 

 

 

2 answers

1 accepted

0 votes
Accepted answer

Hi!

As I said, this is an OSGi issue. This is not a JSS bug and thus can not be fixed.

To get a Class a class (e.g. DB driver) from a system classloader: 

from com.atlassian.jira.component import ComponentAccessor
drv = ComponentAccessor.getClassLoader().loadClass("org.postgresql.Driver").newInstance()
print drv

 

To get a class from another OSGi plugin - actually any v2 JIRA plugin - you need to have an access to that plugin classloader. As I said, I do not have a solution for that out of hand.

 

Alex

thanks Alex At least I now know that I have to look in other directions.. you saved me some time thanks again MCTibi

Hi again.. one more little thing.. It now gives me java.sql.SQLException: java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@xxx:1540:xxx the code is: from com.atlassian.jira.component import ComponentAccessor from java.sql import DriverManager drv = ComponentAccessor.getClassLoader().loadClass("oracle.jdbc.OracleDriver").newInstance() url = "jdbc:oracle:thin:@xxx:1540:xxx" db_user = "user" password = "pass" dbconn = DriverManager.getConnection(url, db_user, password) please help thanks MCTibi

In additional to the problem above I have also a: Error creating issue: root cause: Traceback (most recent call last): File "<string>", line 91, in <module> at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:772) at org.apache.felix.framework.ModuleImpl.access$200(ModuleImpl.java:73) at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1690) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) java.lang.ClassNotFoundException: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver Can you tell me how can I make it work? In there any possibility to acces these external classes from Jython? I use jss-2.3.0 in jira 6.2.7 Please help.. we're stuck with Jira migration because of that Thank you MCTibi

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 31, 2018 in Marketplace Apps

Marketplace Spotlight: Zephyr

Hello Atlassian Community! Each month, we run a series of Spotlights to highlight Marketplace vendors and apps that our team thinks this Community would find valuable. In last month's Spotlig...

413 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you