Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Is there a procedure to be followed to add external jars to a custom confluence plugin development environment

angela simmons July 9, 2012

Hi All,

My custom plugin will require consumption of web service methods to realise certain events. As a result i have a few essential jar files which i easily configure in Java.

package com.atlassian.myorg;

import org.tempuri.FreewayAuthLocator;
import org.tempuri.FreewayAuthSoap;

import com.atlassian.confluence.core.ConfluenceActionSupport;
import com.atlassian.confluence.pages.AbstractPage;
import com.atlassian.confluence.pages.actions.PageAware;
import com.opensymphony.xwork.Action;
 
/**
 * The simplest action possible
 */
public class FreewayProjectAction extends ConfluenceActionSupport
{
    @Override
    public String execute() throws Exception
    {
    	String logonResult = "";
		try {

			FreewayAuthLocator freewayAuth = new FreewayAuthLocator();						
			FreewayAuthSoap freewayAuthSoap = freewayAuth.getFreewayAuthSoap();			
			logonResult = freewayAuthSoap.logon("freeway.username", "Password");
			System.out.println("LogonResult >> " + logonResult);

		} catch (javax.xml.rpc.ServiceException ex) {
			// TODO handle ServiceException
			ex.printStackTrace();
		} catch (java.rmi.RemoteException ex) {
			// TODO handle remote exception
			ex.printStackTrace();
		} catch (Exception ex) {
			// TODO handle custom exceptions here
			ex.printStackTrace();
		}
        return Action.SUCCESS;
    }
 
}

This is how my java class looks like .The 'FreewayAuthLocator' class are referenced from the jar files i have added via 'Configure Build Path'. And even in eclipse i am able to see the auto suggestions on the object of that class (By which i assumed that the class is available). How ever when i run this plugin using atlas-run the action trigerring this class results in a "No Class Def" found error.

Is there a compulsion to add the dependencies in pom.xml ?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Julien Hoarau
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.
July 9, 2012

You must add the dependency in your pom.xml, otherwise the jar won't be bundled and you'll get a NoClassDef error.

<dependencies>
  ...
  <dependency>
    <groupId>XXX</groupId>
    <artifactId>YYY</artifactId>
    <version>ZZZ</version>
  </dependency>
  ...
</dependencies>

If the jar is not in a maven repository, you can install it manually in your local repository using this command:

mvn install:install-file -Dfile=your-artifact-1.0.jar -DgroupId=XXX -DartifactId=YYY -Dversion=ZZZ -Dpackaging=jar

angela simmons July 10, 2012

Hi Julien,

I added this dependency chunk in my pom.xml

<dependency>
            <groupId>freeway</groupId>
            <artifactId>axis</artifactId>
            <version>1.0</version>
        </dependency>


I have placed my jar file in the folder C:\jarhost\axis-1.0.jar
And i ran the command

mvn install:install-file -Dfile= "C:/jarhost/axis-1.0.jar" -DgroupId=freeway -DartifactId=axis -Dversion=1.0 -Dpackaging=jar


And this is the error i get is this

http://imageshack.us/f/580/cmdimage.png
I also stumbled upon this https://confluence.sakaiproject.org/display/DOC/Adding+JARs+to+an+Application and tried it too. But it was unable to 'download' dependencies.

What am i missing ?

Looking for your help on this.

Julien Hoarau
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.
July 10, 2012

Could you try again without the space between "file=" and "C:/jarhost/axis-1.0.jar" like this:

mvn install:install-file -Dfile="C:/jarhost/axis-1.0.jar" -DgroupId=freeway -DartifactId=axis -Dversion=1.0 -Dpackaging=jar

ijawaid August 4, 2016

i am having issue with this as well can anyone help with adding a external jar to my custom plugin.

 

ijawaid August 12, 2016

I followed tutorial to create applet module by following this link:

https://developer.atlassian.com/docs/getting-started/learn-the-development-platform-by-example/convert-component-to-servlet-module

Whenever i add any external jar to the POM.xml it starts giving me error

These are lines I am adding to the pom.xml 

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.4</version>
</dependency>

This is the error i get: It has something to do with osgi.wiring I have no clue about it

The project works fine without the jar though.

Screen Shot 2016-08-12 at 1.55.35 PM.png

0 votes
Julien Hoarau
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.
July 10, 2012

Could you try again without the space between "file=" and "C:/jarhost/axis-1.0.jar" like this:

mvn install:install-file-Dfile="C:/jarhost/axis-1.0.jar"-DgroupId=freeway -DartifactId=axis -Dversion=1.0 -Dpackaging=jar

ijawaid August 12, 2016

I followed tutorial to create applet module by following this link:

https://developer.atlassian.com/docs/getting-started/learn-the-development-platform-by-example/convert-component-to-servlet-module

Whenever i add any external jar to the POM.xml it starts giving me error

These are lines I am adding to the pom.xml 

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.4</version>
</dependency>

This is the error i get: It has something to do with osgi.wiring I have no clue about it.

 Screen Shot 2016-08-12 at 1.55.35 PM.png

ijawaid August 12, 2016

The project works fine without the jar though.

TAGS
AUG Leaders

Atlassian Community Events