How to use AtlassianWikiRenderer in jira - java

In jdoc 8.0.1 I see com.atlassian.jira.issue.fields.renderer.wiki.AtlassianWikiRenderer
But I can't import it:
import com.atlassian.jira.issue.fields.renderer.wiki.AtlassianWikiRenderer;
> .... package com.atlassian.jira.issue.fields.renderer.wiki does not exist
How can I use AtlassianWikiRenderer.render(...) in my own render?
The same with com.atlassian.jira.issue.fields.renderer.text.DefaultTextRenderer

Works for me. You need to have jira-core uncommented out in your pom.xml file

Related

Migrating com.vividsolutions.jts to org.locationtech.jts still complaining about lack of com.vividsolutions package

I'm trying to upgrade dependencies for a java application that uses com.vividsolutions.jts. I have removed all the references to this library from pom.xml and replaced them by the ones from org.locationtech.jts.
I have updated all the imports to use org.locationtech version. However, in my function I'm still getting an error related to com.vividsolutions object not being imported.
import org.locationtech.spatial4j.context.jts.JtsSpatialContext;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.LinearRing;
import org.locationtech.spatial4j.shape.jts.JtsGeometry;
// ... other stuff
public static myFunc() {
GeometryFactory gf = new GeometryFactory();
LinearRing linear = gf.createLinearRing(coordinates);
JtsGeometry poly = new JtsGeometry(fact.createPolygon(linear), JtsSpatialContext.GEO, true, true);
}
Here's the error that I get for the last line of the above code: [ERROR] cannot access com.vividsolutions.jts.geom.Geometry [ERROR] class file for com.vividsolutions.jts.geom.Geometry not found
I'm clearly importing JtsGeometry from the new library at org.locationtech, however, it's still thinking the old library should be used.
The old library isn't in the dependency tree or the code anymore, as the followings don't return anything:
mvn dependency:tree | grep vivid
rg vivid
Any idea what I'm missing here or how I should troubleshoot this?
I'm not too sure what was wrong with the vividsolutions library inclusion. However, I was able to resolve my issue by including both of these in pom.xml:
<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
<version>1.18.2</version>
</dependency>
<dependency>
<groupId>org.locationtech.spatial4j</groupId>
<artifactId>spatial4j</artifactId>
<version>0.8</version>
</dependency>
Initially I didn't have the second dependency in the pom.xml file.

How to import java's #Plugin annotation?

I am attempting to use the #Plugin annotation. Am following the example of FileAppender here.
However, java does not recognize it and instead I get
error: package org.apache.logging.log4j.plugins does not exist
Is there some jar I need to include? I already have the log4j jars log4j-api-2.14.0.jar and log4j-core-2.14.0.jar (as well as log4j-slf4j18-impl-2.14.0.jar).
How do I get the import working in order to use #Plugin?
It turned out the import line was different than it was for all the example code I was referencing.
I searched within the jar to check whether any Plugin classes were there, and noticed they had a different path than the import line in the examples.
> jar -tf .\log4j-core-2.14.0.jar | rg Plugin
org/apache/logging/log4j/core/config/plugins/util/PluginRegistry$PluginTest.class
org/apache/logging/log4j/core/config/plugins/util/PluginManager.class
org/apache/logging/log4j/core/config/plugins/visitors/PluginAttributeVisitor.class
org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor$PluginAliasesElementVisitor.class
org/apache/logging/log4j/core/config/plugins/processor/PluginCache.class
org/apache/logging/log4j/core/config/plugins/util/PluginBuilder.class
org/apache/logging/log4j/core/config/plugins/PluginBuilderAttribute.class
org/apache/logging/log4j/core/config/plugins/visitors/PluginElementVisitor.class
org/apache/logging/log4j/core/config/PropertiesPlugin.class
org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor$1.class
org/apache/logging/log4j/core/config/plugins/visitors/PluginConfigurationVisitor.class
org/apache/logging/log4j/core/config/plugins/processor/PluginEntry.class
org/apache/logging/log4j/core/config/plugins/visitors/PluginBuilderAttributeVisitor.class
org/apache/logging/log4j/core/config/plugins/visitors/AbstractPluginVisitor.class
org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor$PluginElementVisitor.class
org/apache/logging/log4j/core/config/plugins/PluginNode.class
META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat
org/apache/logging/log4j/core/config/plugins/visitors/PluginVisitor.class
org/apache/logging/log4j/core/config/plugins/PluginAttribute.class
org/apache/logging/log4j/core/config/plugins/PluginValue.class
org/apache/logging/log4j/core/appender/FailoversPlugin.class
org/apache/logging/log4j/core/config/plugins/PluginBuilderFactory.class
org/apache/logging/log4j/core/config/plugins/util/PluginType.class
org/apache/logging/log4j/core/config/plugins/util/PluginRegistry.class
org/apache/logging/log4j/core/config/plugins/Plugin.class
org/apache/logging/log4j/core/config/plugins/PluginAliases.class
org/apache/logging/log4j/core/config/plugins/PluginVisitorStrategy.class
org/apache/logging/log4j/core/config/AppendersPlugin.class
org/apache/logging/log4j/core/config/plugins/visitors/PluginVisitors.class
org/apache/logging/log4j/core/config/LoggersPlugin.class
org/apache/logging/log4j/core/config/plugins/visitors/PluginValueVisitor.class
org/apache/logging/log4j/core/config/plugins/visitors/PluginNodeVisitor.class
org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.class
org/apache/logging/log4j/core/config/plugins/PluginConfiguration.class
org/apache/logging/log4j/core/config/plugins/PluginFactory.class
org/apache/logging/log4j/core/config/plugins/PluginElement.class
org/apache/logging/log4j/core/config/ScriptsPlugin.class
I changed the import line from
import org.apache.logging.log4j.plugins.Plugin;
to
import org.apache.logging.log4j.core.config.plugins.Plugin;
and then the annotations were recognized.

UnsatisfiedLinkError when calling new World()

My error:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.UnsatisfiedLinkError: org.jbox2d.common.Timer.now()D
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:130)
Caused by: java.lang.UnsatisfiedLinkError: org.jbox2d.common.Timer.now()D
at org.jbox2d.common.Timer.now(Native Method)
at org.jbox2d.common.Timer.reset(Timer.java:35)
at org.jbox2d.common.Timer.<init>(Timer.java:31)
at org.jbox2d.dynamics.World.<init>(World.java:587)
at org.jbox2d.dynamics.World.<init>(World.java:158)
at org.jbox2d.dynamics.World.<init>(World.java:154)
at org.jbox2d.dynamics.World.<init>(World.java:145)
at com.badlogic.gdx.physics.box2d.World.<init>(World.java:61)
at com.example.blockbunny.states.Play.<init>(Play.java:22)
at com.example.blockbunny.handlers.GameStateManager.getState(GameStateManager.java:36)
at com.example.blockbunny.handlers.GameStateManager.pushState(GameStateManager.java:46)
at com.example.blockbunny.handlers.GameStateManager.<init>(GameStateManager.java:20)
at com.example.blockbunny.main.Game.create(Game.java:33)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:146)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:123)
And this occurs when I do this:
world = new World(new Vector2(0, -9.81f), true);
I have looked online, and some solutions included using this:
import com.badlogic.gdx.utils.GdxNativesLoader;
GdxNativesLoader.load();
However, I don't know where to put this function, and if it even works (I tried putting it in several different places)
How can I fix this issue?
Help will be appreciated, thanks!
As requested, here are my imports:
import static com.example.blockbunny.handlers.B2DVars.PPM;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World;
import com.example.blockbunny.handlers.GameStateManager;
import com.example.blockbunny.main.Game;
I used Box2d several time with libgdx and i never encountered such a problem :
here what i propose t you :
GdxNativesLoader.load();
should be put on the create() method, but that doesn't seem to work with you
also try call it in a static way like this :
static {
GdxNativesLoader.load();
}
but i thin your problem is the extension of the library that you are using
verify that you are using gdx-box2d and not gdx-box2d-gwt which is used only for Html project
Verify that you are using the right (jar file) /(extension library) : gdx-box2d.jar and gdx-box2d-natives.jar (also verify the build path)
also try :
upgrade the box2d version that you're using
those were all the arrows i had ! hope one of it will work
Good luck !!
I came across the same issue, was using the gwt libraries. Updated the Maven dependency artifact from
gdx-box2d-gwt
to
gdx-box2d
and it fixed the error.

Drools 6.0 dynamically load rules at runtime

I want to load a drl file at runtime. The posts I've found including this one work for version 5.0 but I can't figure out how to do it for drools version 6.0.
In Drools 6, your rules packages are deployed to Maven. A KieScanner is provided, which you can attach to your KieContainer. This polls your repository at a defined interval to see whether a package has been updated and downloads the latest if that's the case.
A full explanation of how to define a KieScanner (including code samples) is provided in the Drools documentation here:
https://docs.jboss.org/drools/release/latest/drools-docs/html/ch04.html
I used info taken from those two docs:
https://docs.jboss.org/drools/release/6.0.1.Final/drools-docs/html_single/#d0e109
https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/CommonTestMethodBase.java
I've came out with this snippet that loads rules defined in the /drl/file/path file into the stateful session you obtain at the last line.
File path = new File("/drl/file/path");
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newFileResource(path), ResourceType.DRL);
if (kbuilder.hasErrors()) {
throw new RuntimeException("Errors: " + kbuilder.getErrors());
}
kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
Some methods are deprecated, so, don't expect this solution to be valid in the following releases.
Please, double check the imports, they are all from org.kie, not from drools packages. I admit those imports are too much, but I'm pasting the code from an example I'm trying to develop, so I have more things on my code, sorry for that.
import java.io.File;
import org.kie.api.KieServices;
import org.kie.api.builder.KieBuilder;
import org.kie.api.builder.KieFileSystem;
import org.kie.api.builder.KieScanner;
import org.kie.api.builder.ReleaseId;
import org.kie.api.builder.model.KieBaseModel;
import org.kie.api.builder.model.KieModuleModel;
import org.kie.api.builder.model.KieSessionModel;
import org.kie.api.conf.EqualityBehaviorOption;
import org.kie.api.conf.EventProcessingOption;
import org.kie.api.io.Resource;
import org.kie.api.io.ResourceType;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.conf.ClockTypeOption;
import org.kie.internal.KnowledgeBase;
import org.kie.internal.KnowledgeBaseFactory;
import org.kie.internal.builder.KnowledgeBuilder;
import org.kie.internal.builder.KnowledgeBuilderFactory;
import org.kie.internal.io.ResourceFactory;
import org.kie.internal.runtime.StatefulKnowledgeSession;
Hope it helps.

Jetbrains IDEA, How to make IDEA to create new import for each partial class in the same package

For example, I have class A with such imports:
import some.package.Class1
import some.package.Class2
When I put reference to some.package.Class3 in my class IDEA turns all inputs into such line of code:
import some.package.*
How can I make IDEA create new import for each class and do not replace them with '.*'?
Regards, Evgeniy
IDE settings -> Code Style -> Java -> select "import" tab.
Change the value of "Class count to import with '*'".
(Note: this is for 12.x, but it should not differ too much for older versions)

Categories