It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Answer accepted

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 in Marketplace Apps & Integrations

Join our Webinar: 5 use cases to supercharge Jira with apps

G’day Atlassian Community! We’re excited to announce that we’ll be doing a new webinar on 5 use cases to supercharge Jira Cloud. The Atlassian Marketplace offers customers thousands of apps and int...

99 views 1 4
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you