How to install a plugin in Jira? - jira-plugin

I wanted to create a sample servlet as a Jira-plugin according to a tutorial.
I have built the code as it is and I used the following pom.xml to build the code.
When I run the servlet URL I'm getting the following issue about class cast.
[INFO] [talledLocalContainer] ERROR - 13:41:52,368 - com.atlassian.plugin.servlet.DefaultServletModuleManager - [http-bio-5990-exec-4] - Unable to create new reference LazyLoadedServletReference{d
escriptor=com.atlassian.plugins.tutorial.refapp.adminUI:test (null), servletContext=org.apache.catalina.core.ApplicationContextFacade#2829d93e}
[INFO] [talledLocalContainer] com.atlassian.util.concurrent.LazyReference$InitializationException: java.lang.ClassCastException: com.atlassian.plugins.tutorial.refapp.MyPluginServlet cannot be cast to javax.servlet.http.HttpServlet
[INFO] [talledLocalContainer] at com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:149)

This is possibly a dependency issue in your pom.xml. Check to make sure you are not bundling resources into your plugin that already exist in the environment that is hosting your plugin.
In your case, you might want to check for this:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
With the key part here being <scope>provided</scope> indicating this resource is needed for compilation but does not need to be bundled with the plugin as it is already provided by the runtime environment. If this line doesn't exist or the scope is anything other than provided, then try adding/changing it.
See this page for more info: Dependency Issues during Plugin Initialisation

Related

Unable to run a simple cucumber feature file in intelliJ

I've just installed the community edition of IntelliJ and the Cucumber integration. When I try to run a feature, I get the error below. How do I fix this? I have cucumber-core 4.7.2 and gherkin 7.0.4.
Feature: OrangeHRM Login
Scenario: Logo presence on OrangeHRM home page
Given I launch chrome browser
When I open orangeHRM homepage
Then I verify that the logo present on page
And close the browser
Error :
WARNING: You are using deprecated Main class. Please use io.cucumber.core.cli.Main
Exception in thread "main" java.lang.NoClassDefFoundError: gherkin/IGherkinDialectProvider
at io.cucumber.core.options.CommandlineOptionsParser.parse(CommandlineOptionsParser.java:24)
at io.cucumber.core.options.CommandlineOptionsParser.parse(CommandlineOptionsParser.java:29)
at io.cucumber.core.cli.Main.run(Main.java:29)
at cucumber.api.cli.Main.run(Main.java:28)
at cucumber.api.cli.Main.main(Main.java:15)
Caused by: java.lang.ClassNotFoundException: gherkin.IGherkinDialectProvider
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 5 more
Process finished with exit code 1
As stated by #mpkorstanje, you are using the wrong version of Gherkin with this version of Cucumber.
You don't need to add a Gherkin dependency yourself; this can be managed by your build tool (Maven/Gradle).
As stated in the docs, you only need the cucumber-java or cucumber-java8 dependency. Which one you need, depends on whether you want to write annotated methods or lambdas, respectively:
If you are going to use the lambda expressions API (Java 8) to write the step definitions, add the following dependency to your pom.xml:
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java8</artifactId>
<version>4.7.1</version>
<scope>test</scope>
</dependency>
Otherwise, to write them using annotated methods, add the following dependency to your pom.xml:
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.7.1</version>
<scope>test</scope>
</dependency>

org.jibx: maven-jibx-plugin:1.2.1 - Error reading path

I am trying to execute a goal using maven-jibx-plugin version 1.2.1, but I am getting the following error:
[ERROR] Failed to execute goal org.jibx:maven-jibx-plugin:1.2.1:bind (default) on project XoXcertExIm: Error loading class java.lang.CharSequence: Error reading
path java/lang/CharSequence.class for class java.lang.CharSequence -> [Help 1]
I am using Maven 3.2.5, Java versions 1.8.0_11, and windows 7 as the OS.
There is an issue on Jibx to support Java 8 see Issue here
There is a Workaround in this comment that you can try.
I had the same problem...
Workaround was as easy as include newer "bcel" dependency to the plugin "maven-jibx-plugin":
<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.2.6</version>
<dependencies>
<!-- Workaround to avoid error compiling with JDK 1.8 -->
<dependency>
<groupId>org.apache.bcel</groupId>
<artifactId>bcel</artifactId>
<version>6.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
You should include a new Maven repository definition in your "settings.xml" to get the new dependency:
<repository>
<id>apache-snapshots-repo</id>
<url>https://repository.apache.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
Regards

Exception in deserializing avro object in map reduce

I am trying to run a map reduce job which takes an avro file as input and does some processing. I followed the sample program apache has given us here
http://avro.apache.org/docs/1.7.6/mr.html
But I keep on running into this exception
java.lang.Exception: java.lang.NoSuchMethodError: org.apache.avro.generic.GenericData.createDatumWriter(Lorg/apache/avro/Schema;)Lorg/apache/avro/io/DatumWriter;
at org.apache.hadoop.mapred.LocalJobRunner$Job.runTasks(LocalJobRunner.java:462)
at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:522)
Caused by: java.lang.NoSuchMethodError: org.apache.avro.generic.GenericData.createDatumWriter(Lorg/apache/avro/Schema;)Lorg/apache/avro/io/DatumWriter;
Any idea on what I may be doing wrong? I have specified my pom configs in the bottom. Also I am using MapR version 4.
<repositories>
<repository>
<id>MapR</id>
<url>http://repository.mapr.com/maven/.</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro-mapred</artifactId>
<version>1.7.6</version>
<classifier>hadoop2</classifier>
</dependency>
</dependencies>
Common cause of such errors is this:
Your software was compiled against 1.7.6 version of avro, but in runtime, classes from older version were probably loaded.
Make sure that 1.7.6 is the actual version of your avro artifacts in your runtime classpath. Print out the classpath at the start of your mapper. If you're using oozie, the classpath jars are listed in launcher job output.
The first avro jar you see in the classpath is the one that will be used to load the classes, so if it isn't 1.7.6, that's the problem.
You can force your classpath artifacts to come first in the task's classpath by setting mapreduce.job.user.classpath.first configuration property to true.
Also you have another error in your pom that may very well cause you problems, maybe the very ones you're seeing. You are using avro-mapred artifact compiled for hadoop2 while the hadoop artifact you're depending on is that of hadoop1. These should not be compatible. If you're using hadoop1, loose the hadoop2 classifier on avro-mapred, and if you're using hadoop2, remove hadoop-core and put hadoop-mapreduce-client-core instead.
I have solved this by injecting the right Avro jar in bootstrap action, as described here:
https://stackoverflow.com/a/40235289/3487888

Problem with JBoss dependencies in Maven

I have code dependant on some JBoss provided libraries. I have added to my POM following dependency:
...
<repository>
<id>jboss</id>
<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
</repository>
...
<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-client</artifactId>
<version>6.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
And I receive following error
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: org.jboss.aspects:jboss-transaction-aspects
Reason: Failed to build model from file 'C:\Users\User\.m2\repository\org\jboss\
aspects\jboss-transaction-aspects\1.0.0.GA\jboss-transaction-aspects-1.0.0.GA.po
m'.
Error: 'no more data available - expected end tags </dependency></dependencies><
/project> to close start tag <dependency> from line 48 and start tag <dependenci
es> from line 45 and start tag <project> from line 1, parser stopped on END_TAG
seen ...<groupId>org.jboss</groupId>\n ... #50:5' for project org.jboss.aspec
ts:jboss-transaction-aspects
I couldn't "google" it out. Any ideas?
It seems either your dependencies tags are not matching, or you don't have them.

Maven - how to put the build dependance jar files?

I run a simple CXF maven project http://cxf.apache.org/docs/using-cxf-with-maven.html, and get error below
[INFO] [cxf-codegen:wsdl2java {execution: generate-sources}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] org/springframework/core/io/support/ResourcePatternResolver
org.springframework.core.io.support.ResourcePatternResolver
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: org/springframework/core/io/support/ResourcePatternResolver
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
I don't know how to put the springframework-core dependance ?
I tried below like most of answers
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>2.5.6</version>
</dependency>
</dependencies>
but it didn't help, I also don't know why it depends on springframework
It works if I put the jar file under $M2_HOME/lib, but is it correct way ? since when I solve this, it requires to add more lib there, can I put it into pom.xml somewhere ?
I tried to put <dependencies/> inside <build> tag, it doesn't work
my maven is 2.2.1 on windows
It works if I put the jar file under $M2_HOME/lib, but is it correct way ?
No, definitely not. To add a dependency, you need to declare it in your pom.xml, something like this:
<project>
...
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>???</version>
</dependency>
...
</dependencies>
</project>
But I don't understand why you would have to add this dependency, spring-core is a dependency of cxf, you should get it transitively. You're not providing enough context information for a more precise answer though.
You have to define it in the pom.xml
Read the docs at http://maven.apache.org/pom.html#Dependencies
You'll need to add this to your Maven pom.xml file in the <dependencies> section:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>???</version>
</dependency>
The version number will depend on which version of spring you're using. (I'm using 2.0 as the version #, along with spring 2.0.8).
Finally I found it by myself, it is due to the error of my springframework-2.5.5 package from local repository. The jar file is not correct. I notice this later in eclipse
Pascal's answer is also correct.
The springframework-2.5.5 is automatically download by maven, unfortunately it is broken, so it still complain the class, and if I put springframework-2.5.6 inside, even it will be downloaded, it will not be used, maven still think it loaded the springframework-2.5.5 into its classpath.
And if I put into %M2_HOME%/lib, surely it will be maven's classpath, and it is wrong to use it.
Since I met this kind of problem before, now I know what it is.
Summary: checking your dependance files to see whether the package is correct
BTW: Thanks for all especially pascal