Understanding JIRA dependencies and package imports - java

I'm relatively new to JIRA plugin development and as I'm working through various tutorials I've run into a problem where I can only import certain JIRA java classes. For instance, when trying to compile this tutorial to create a custom search request view https://developer.atlassian.com/jiradev/jira-platform/building-jira-add-ons/jira-plugins2-overview/jira-plugin-module-types/search-request-view-plugin-module I found that I can successfully import the following packages:
import com.atlassian.jira.issue.search.SearchException;
import com.atlassian.jira.issue.search.SearchRequest;
but cannot import these packages:
import com.atlassian.jira.issue.search.SearchProvider;
import com.atlassian.jira.issue.search.SearchProviderFactory;
Both SearchProvider and SearchProviderFactory are present in the javadocs for the latest version of JIRA, yet I can't import them despite them being in a package from which I've already imported.
Why is this? I suppose it's some sort of dependency issue but I can't seem to find a way to fix it. I'm developing in Eclipse, by the way.
Any help is appreciated. Thanks!

The problem was that in the generated pom.xml for JIRA plugin projects, the jira-core dependency is commented out. To access all developer classes, the following must be enabled.
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-core</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>

Related

Add ical4j to a maven jhipster project

I have a jhipster generated application using maven with java springboot on the backend. I want to add the ical4j library to the project so under the <dependencies> tag in the pom.xml file I added the lines like explained here . However when I add import org.mnode.ical4j; the maven compiler throws an error package org.mnode does not exist .
This seems pretty trivial but I don't get what I am missing.
Thank you
From what I can see in the official GitHub repo (ical4j/ical4j) the correct package to import starts from net.fortuna.ical4j. Example:
import net.fortuna.ical4j.util.DefaultEncoderFactory;

Java 8 to openJdk 11 com.sun.org.apache.xml.internal.* types not accessible

I am migrating my project from java 8 to openJDK 11. In my code I use the classes
import com.sun.org.apache.xml.internal.dtm.DTM;
import com.sun.org.apache.xml.internal.dtm.DTMManager;
import com.sun.org.apache.xml.internal.dtm.ref.sax2dtm.SAX2DTM;
import com.sun.org.apache.xml.internal.utils.XMLStringFactory;
import com.sun.org.apache.xpath.internal.objects.XMLStringFactoryImpl
I am using eclipse. I am getting the error that the types are not accessible. I also tried this post with the last import How to tell eclipse to add-exports when compiling
But it did not work. Any idea how could we fix this? Does the error mean that the packages have become internal and should be replaced in the code?
I had a similar issue where I needed to update a reference to com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory, and found I could change it to:
import org.apache.xml.serializer.OutputPropertiesFactory;
if I included the right Xalan apache xml dependency:
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.2</version>
</dependency>
In openJdk11 you have to import xml-security.jar ( com.sun.org.apache.xml is not present so you have to)

scala not working with kafka-streams-scala and maven

Problem is that - I have a program that builds and runs fine. It is written in Scala and it uses the Kafka Streams DSL. I was to use the new kafka-streams-scala package and I am using Maven right now. I can't use SBT right now. When I add the dependency
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams-scala_2.11</artifactId>
<version>2.0.0</version>
</dependency>
I then get all kinds of errors in the code, that already runs. I can't even do the following import statement
import scala.collection.JavaConverters._.
When I do, I get the following error
object language is not a member of package org.apache.kafka.streams.scala.
Why is this happeneing and how can I fix it?
I needed to prefix _root_ to all the Scala core packages like for example
import _root_.scala.collection.JavaConverters._

Import custom lib Java

Trying to import the "custom" library "Htmlunit" in my project. I use the IDE Netbeans and have done the following:
Right click "Library"
Clicked "Add Library"
Created the Library and added it
I then want to import the jar "htmlunit-2.15" but Netbeans tell me the following:
'.' expected
I have tried the following formatting:
import htmluni-2.15;
import htmlunit-2.15.*;
import Htmlunit;
import Htmlunit.*;
I have read other threads here, but do not understand to the fullest how I accomplish this.
Image: [http://s8.postimg.org/7ru7csh5h/import.png][1]
It doesn't work that way, you import in your code actual classes, not jars. I suggest you reading more about classpath, since it's a basic topic.
Probably you need to open the jar archive and see it's internal directory structure. When a class you are interested in a class is located, say, under file.jar -> com/example/Utils.class, you need to import it using:
import com.example.Utils
Create new project Maven->Java Appliacation. Find file pom.xml, and add this
<dependencies>
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
Maven automatically download the library and add them to project.

Cannot resolve files when importing them Google API's

I'm developing a Glassware for Google Glass. I'm trying to import these files:
import com.google.api.client.json.jackson.JacksonFactory;
import com.google.api.services.oauth2.Oauth2;
import com.google.api.services.oauth2.model.Userinfo;
but I'm getting errors on them. They are below:
The import com.google.api.client.json.jackson cannot be resolved
The import com.google.api.services.oauth2 cannot be resolved
The import com.google.api.services.oauth2 cannot be resolved
I'm not sure why I'm getting these errors. I'm building off of the quickstart java project. My Maven Dependencies are below:
C:\Users\Family3\.m2\repository\com\google\apis\google-api-services-mirror\v1-rev20-1.16.0-rc\google-api-services-mirror-v1-rev20-1.16.0-rc.jar
C:\Users\Family3\.m2\repository\com\google\api-client\google-api-client\1.16.0-rc\google-api-client-1.16.0-rc.jar
C:\Users\Family3\.m2\repository\com\google\oauth-client\google-oauth-client\1.16.0-rc\google-oauth-client-1.16.0-rc.jar
C:\Users\Family3\.m2\repository\com\google\http-client\google-http-client-jackson2\1.16.0-rc\google-http-client-jackson2-1.16.0-rc.jar
C:\Users\Family3\.m2\repository\com\google\http-client\google-http-client\1.16.0-rc\google-http-client-1.16.0-rc.jar
C:\Users\Family3\.m2\repository\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar
C:\Users\Family3\.m2\repository\org\apache\httpcomponents\httpclient\4.0.1\httpclient-4.0.1.jar
C:\Users\Family3\.m2\repository\org\apache\httpcomponents\httpcore\4.0.1\httpcore-4.0.1.jar
C:\Users\Family3\.m2\repository\xpp3\xpp3\1.1.4c\xpp3-1.1.4c.jar
C:\Users\Family3\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.1.3\jackson-core-2.1.3.jar
C:\Users\Family3\.m2\repository\org\mortbay\jetty\jetty\6.1.14\jetty-6.1.14.jar
C:\Users\Family3\.m2\repository\org\mortbay\jetty\servlet-api-2.5\6.1.14\servlet-api-2.5-6.1.14.jar
C:\Users\Family3\.m2\repository\org\mortbay\jetty\jetty-util\6.1.14\jetty-util-6.1.14.jar
C:\Users\Family3\.m2\repository\org\mortbay\jetty\jetty-plus\6.1.14\jetty-plus-6.1.14.jar
C:\Users\Family3\.m2\repository\geronimo-spec\geronimo-spec-jta\1.0.1B-rc4\geronimo-spec-jta-1.0.1B-rc4.jar
C:\Users\Family3\.m2\repository\org\mortbay\jetty\jsp-2.1\6.1.14\jsp-2.1-6.1.14.jar
C:\Users\Family3\.m2\repository\org\eclipse\jdt\core\3.1.1\core-3.1.1.jar
C:\Users\Family3\.m2\repository\ant\ant\1.6.5\ant-1.6.5.jar
C:\Users\Family3\.m2\repository\org\mortbay\jetty\jsp-api-2.1\6.1.14\jsp-api-2.1-6.1.14.jar
C:\Users\Family3\.m2\repository\org\apache\commons\commons-lang3\3.1\commons-lang3-3.1.jar
C:\Users\Family3\.m2\repository\org\codehaus\jackson\jackson-core-asl\1.9.11\jackson-core-asl-1.9.11.jar
C:\Users\Family3\.m2\repository\org\codehaus\jackson\jackson-mapper-asl\1.9.11\jackson-mapper-asl-1.9.11.jar
C:\Users\Family3\.m2\repository\javax\servlet\servlet-api\2.5\servlet-api-2.5.jar
C:\Users\Family3\.m2\repository\commons-logging\commons-logging\1.1.2\commons-logging-1.1.2.jar
C:\Users\Family3\.m2\repository\commons-codec\commons-codec\1.7\commons-codec-1.7.jar
C:\Users\Family3\.m2\repository\com\google\guava\guava\14.0.1\guava-14.0.1.jar
Why am I getting these errors? Am I not importing a .jar? I can't find any .jar's that aren't included that should be, but there could be one. Thank you for your help.
Add the client libraries to the project.
See download and setup instructions for google-api-java-client.
try adding:
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-oauth2</artifactId>
<version>{version}</version>
</dependency>

Categories

Resources