Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

[Closed]SOAP Service Plugin : Missing class: com/atlassian/jira/rpc/exception/RemoteException

xu zhijian April 10, 2012

Hi, all

I've written a soap service plugin for jira, and it works in JIRA-4.4.3, however, after i upgrage jira to JIRA5.0.1 , the plugin can't be enable because some error like this:

There was an error loading the descriptor 'Extension SOAP Service' of plugin 'com.mycompany.jira.plugin.ChangeHistorySoap'. Disabling.

com.atlassian.plugin.PluginParseException: Error retrieving dependency of class: com. mycompany.jira.plugin.rpc.soap.ExtensionSoapServiceImpl. 

Missing class: com/atlassian/jira/rpc/exception/RemoteException

actually, i do have import the class com/atlassian/jira/rpc/exception/RemoteException in the ExtensionSoapServiceImpl file. Does anybody know what happened?

PS:in jira-4.4.3, I add a dependency like below into pom.xml :

<dependency>
    <groupId>com.atlassian.jira.plugins</groupId> 
    <artifactId>atlassian-jira-rpc-plugin</artifactId>
    <version>4.4.1</version>
    <scope>provided</scope> 
</dependency>

Should I change the dependency to

<dependency>
   <groupId>com.atlassian.jira.plugins</groupId> 
   <artifactId>atlassian-jira-rpc-plugin</artifactId>
   <version>5.0.5</version>
   <scope>provided</scope> 
</dependency>

1 answer

1 accepted

2 votes
Answer accepted
Dieter
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.
April 10, 2012

Did you read

Changes to the RPC Plugin

at https://developer.atlassian.com/display/JIRADEV/Preparing+for+JIRA+5.0 ?

You need to import all the components that you inject in your constructor.

EDIT: Actually the found solution i found now is to "inline" the original rpc plugin jar into the the plugins META-INF/lib which avoids the class loading problems caused by trying to use the service interface TokenManger from the original rpc plugin in thevplugin. This solution also avoids problems with overwriting tokens when clients access both the original rpc service and the one provided the plugin. Hopefully this works in your environment as well
xu zhijian April 10, 2012

Thanks for your resource. you mean i need to add a component-import xml node in atlassian-plugin.xml ?

<component-import key="helloWorldService">
        <interface>com.myapp.HelloWorldService</interface>
 </component-import>
<component>
 ...
</component>

And what about the dependency about rpc plugin in pom.xml file ?

Dieter
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.
April 10, 2012
Yes, please first change version to 5.0.5 AND the value of element scope from provided to compile. Rebuild your plugin and deploy it. This should work well unless you use the interfaces provided by the original rpc plugin
xu zhijian April 11, 2012

I use " com.atlassian.jira.rpc.auth.TokenManager" to manager the "login/logout" actions, It seems still not work .

my atlassian-plugin.xml is like below :

<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
    <plugin-info>
        <description>${project.description}</description>
        <version>${project.version}</version>
        <vendor name="${project.organization.name}" url="${project.organization.url}" />
    </plugin-info>
	 
	<component key="extension-soap-component" name="Extension SOAP Component" class="com.mycom.jira.plugin.rpc.soap.ExtensionSoapServiceImpl">
        <interface>com.mycom.jira.plugin.rpc.soap.ExtensionSoapService</interface> 
    </component>
	<rpc-soap key="extension-soap-service" name="Extension SOAP Service" class="com.mycom.jira.plugin.rpc.soap.ExtensionSoapServiceImpl">
        <description>Extension SOAP Service.</description>
        <service-path>extensionsoapservice</service-path>
        <published-interface>com.mycom.jira.plugin.rpc.soap.ExtensionSoapService</published-interface>
    </rpc-soap>
	
</atlassian-plugin>

In ExtensionSoapServiceImpl.java, I import some class like this:

import com.atlassian.jira.rpc.auth.TokenManager;
import com.atlassian.jira.rpc.exception.RemoteAuthenticationException;
import com.atlassian.jira.rpc.exception.RemotePermissionException;
import com.atlassian.jira.rpc.exception.RemoteException;

After i enable the plugin, it always give the log "Missing class: com/atlassian/jira/rpc/exception/RemoteException"...

xu zhijian April 11, 2012

I change the component to component-import node as you said and modify the scope to compile, the plugin is enabled success, however, it can't generate the wsdl xml file in /extensionsoapservice?wsdl.

Dieter
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.
April 11, 2012
I still would first try not to share the TokenManager module with the original rpc service but just "borrow" the implementation of TokenManager. So in the constructor of ExtensionSoapServiceImpl you could add tokenManager = new TokenManagerImpl(permissionManager, loginService, authenticationContext, userManager) If this doesn't help please show us the constructor of ExtensionSoapServiceImpl
Dieter
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.
April 11, 2012
If you try to inject the TokenManager interface into your constructor you actually say that you want to use the existing implementation class instance of this interface which is provided by the original rpc service. Even if you got that working this might cause problems when users use both web services since the internal map would be changed from two sides. So if a user logs on to eebservice 1 it overwrites the token that is used to access webservice 2. This might create strange and hard to debug errors. So it's better to have a private token map and thus your own TokenManger object for your web service.
xu zhijian April 11, 2012

Thanks for your remind . I've considered this risk before. Now i want to upgrate a SOAP plugin(to fetch the issue change history) which can work in JIRA4.4.3 to make sure i can work in JIRA 5/5.0.1. After that i'll try to fix this token risk . But it always give me error info shows like " Error retrieving dependency of class: com.intel.jira.plugin.rpc.soap.ExtensionSoapServiceImpl. Missing class: com/atlassian/jira/rpc/auth/TokenManager" . It seems there is something wrong about the original RPC Plugin in dependency (pom.xml).

Dieter
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.
April 11, 2012
If you change the scope to compile in pom.xml you should have the TokenManager interface in your plugin jar file. please check that first. Then you should not have any module in your plugin that injects TokenManager in the constructor or tries to get the interface using ComponentManager. Do not yet use component-import in your plugin but first try to eliminate all references to the original rpc plugin.
Dieter
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.
April 11, 2012

To be more precisa about MyRpcImpl.java

package com.test.jira.rpc;

import com.atlassian.jira.bc.security.login.LoginService;
import com.atlassian.jira.rpc.auth.TokenManager;
import com.atlassian.jira.rpc.auth.TokenManagerImpl;
import com.atlassian.jira.rpc.exception.RemoteException;
import com.atlassian.jira.security.JiraAuthenticationContext;
import com.atlassian.jira.security.PermissionManager;
import com.atlassian.jira.user.util.UserManager;
import com.test.jira.rpc.MyRpc;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MyRpcImpl implements MyRpc{
    private static final Logger log = LoggerFactory.getLogger(MyRpcImpl.class);

    TokenManager tokenManager;
    
    public MyRpcImpl(PermissionManager permissionManager, LoginService loginService, JiraAuthenticationContext authenticationContext, UserManager userManager) {
    	tokenManager = new TokenManagerImpl(permissionManager, loginService, authenticationContext, userManager);    	
    }

	@Override
	public String echo(String s) {
		return s;
	}

	@Override
	public String login(String username, String password) throws RemoteException {
		return tokenManager.login(username, password);
	}

	@Override
	public boolean logout(String token) {
			return tokenManager.logout(token);
	}

}

Dieter
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.
April 11, 2012

I just created a test project with this atlassian-plugin.xml which works

<?xml version="1.0" encoding="UTF-8"?>

<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
  <plugin-info>
    <description>${project.description}</description>
    <version>${project.version}</version>
    <vendor name="${project.organization.name}" url="${project.organization.url}"/>
  </plugin-info>
  <component name="My Rpc Component" i18n-name-key="my-rpc.name.component" key="my-rpc-component" class="com.test.jira.rpc.MyRpcImpl" public="false">
    <description key="my-rpc.description.component">Component For My Rpc</description>
    <interface>com.test.jira.rpc.MyRpc</interface>
  </component>
  <resource type="i18n" name="i18n" location="atlassian-plugin"/>
  <rpc-soap name="My Rpc" i18n-name-key="my-rpc.name" key="my-rpc" class="com.test.jira.rpc.MyRpcImpl">
    <description key="my-rpc.description">The My Rpc Plugin</description>
    <service-path>myrpc-v1</service-path>
    <published-interface>com.test.jira.rpc.MyRpc</published-interface>
  </rpc-soap>
</atlassian-plugin>

The service interface MyRPC.java is

package com.test.jira.rpc;
...
public interface MyRpc {
	String echo(String s);
	
	String login(String user, String password) throws RemoteAuthenticationException, RemoteException;
	
	boolean logout (String token);
...	

The implementation class MyRpcImpl.java is
package com.test.jira.rpc;
...
	public String echo(String s) {
		return s;
	}

	public String login(String username, String password) throws RemoteException {
		return tokenManager.login(username, password);
	}

	public boolean logout(String token) {
			return tokenManager.logout(token);
	}
..

and the pom.xml is
<?xml version="1.0" encoding="UTF-8"?>
...
<dependency>
      <groupId>com.atlassian.jira.plugins</groupId> 
      <artifactId>atlassian-jira-rpc-plugin</artifactId>
      <version>5.0.5</version>
      <scope>compile</scope> 
    </dependency>
...
</project>

xu zhijian April 12, 2012

Thanks for your examples very much. There is a similar solution with yours in https://answers.atlassian.com/questions/12512/how-to-authenticate-security-token-inside-custom-jira-plugin . Both two solutions work for me . Thank you again .

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events