problem with import in jython postfunction script Jira

MUNTEANU CATALINTIBERIU November 18, 2014

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
Answer accepted
Alex Shchagin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 20, 2014

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

MUNTEANU CATALINTIBERIU November 20, 2014

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

MUNTEANU CATALINTIBERIU November 21, 2014

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

0 votes
MUNTEANU CATALINTIBERIU November 20, 2014

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
TAGS
AUG Leaders

Atlassian Community Events