atlassian-plugin.xml contains a definition of component-import. This is not allowed when Atlassian-Plugin-Key is set - jira-plugin

This is what I get when I run atlas-create-jira-plugin followed by atlas-create-jira-plugin-module selecting option 1: Component Import.
The problem is that all tutorial examples appear to have plugin descriptor generated by old SDK version (that won't deploy with newer versions of SDK/Jira at all), which do not feature Atlassian-Plugin-Key, so I can't find my way to import a component.
I'm using SDK 6.2.3 and Jira 7.1.1.
Any hint - how to get this sorted out?

anonymous is correct. The old way of doing things was to to put the <component-import> tag in your atlassian-plugin.xml. The new way and also recommended is to use Atlassian Spring Scanner. When you create your add-on using atlas-jira-create-plugin and your pom.xml has the <Atlassian-Plugin-Key> tag and the dependencies atlassian-spring-scanner-annotation and atlassian-spring-scanner-runtime then you are using the new way.
If you have both the dependencies, you are using Atlassian Spring Scanner version 1.x. If you only have atlassian-spring-scanner-annotation then you are using version 2.x.
You don't have to omit/comment out Atlassian-Plugin-Key in your pom.xml and you don't have to put component-import in your atlassian-plugin.xml.
For example, you want to add licensing for your add-on and need to import the component PluginLicenseManager. You just go straight to the code and your constructor might look like this:
#Autowired
public MyMacro(#ComponentImport PluginLicenseManager licenseManager) {
this.licenseManager = licenseManager;
}
And your class like this:
#Scanned
public class MyMacro implements Macro {
If memory serves me right, be sure to check for null because sometimes Atlassian Spring Scanner can't inject a component. I think on version 1, writing an #EventListener, it could not inject a ConversionContext. But when writing a Macro, it was able to inject a ConversionContext.

According to
https://bitbucket.org/atlassian/atlassian-spring-scanner
component-import is not needed. You can replace it by #ComponentImport annotation in your Java.

Found answer here: https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins
It looks like I've somehow been missing that Atlassian-Plugin-Key can be omitted, and it must be done when you need to import components.
This key just tells spring not to 'transform' plugin's Spring configuration, which must happen as part of components import process..

Related

How can I build an Agroal connection at runtime with native support

I'm trying to build a dynamic database connection via Agroal inside a native image. It's not possible to use the default config params because I don't know the connection params at compile time. Is that even possible right now?
The connection is built like this at runtime:
AgroalDataSource.from(
AgroalDataSourceConfigurationSupplier()
...)
I'm currently seeing this error:
Class io.agroal.pool.ConnectionHandler[] is instantiated reflectively but was never registered.
Register the class by using org.graalvm.nativeimage.hosted.RuntimeReflection
The installed features include: [agroal, cdi, jdbc-h2, jdbc-mysql, jdbc-postgresql, kotlin, narayana-jta, resteasy, resteasy-jackson]
It runs fine on the JVM, but not using Graal. It feels like it should be possible and I'm probably missing something here. I was hoping adding agraol extension would be sufficient but obviously isn't picked up correctly.
The current situation is that we configure Agroal for native images only if you have a datasource defined using Quarkus configuration.
Thus for your use case, for now, you will have to do what we do automatically manually. What we do being registering some classes for reflection and including some resources in the native image.
See https://github.com/quarkusio/quarkus/blob/master/extensions/agroal/deployment/src/main/java/io/quarkus/agroal/deployment/AgroalProcessor.java#L91 and https://quarkus.io/guides/writing-native-applications-tips#using-a-configuration-file.
Obviously, that's not ideal. Could you open an issue on our GitHub so that we can discuss it internally and see if we should/can improve the situation?
In the end, you would still need some reflection registration for your JDBC driver though.

_$UserSerializerMixin do I need it?

I was struggling with serializations when I found this guide
https://flutter.io/json/
In it I found:
import 'package:json_annotation/json_annotation.dart';
part 'user.g.dart';
#JsonSerializable()
class User extends Object with _$UserSerializerMixin{
final String name;
final String email;
User(this.name, this.email);
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
}
I followed the guide (also run the flutter packages pub run build_runner watch command) and everything is good except for _$UserSerializerMixin. It says: classes can only mixin other classes. What should I do?
The error is because _$UserSerializerMixinclass isn't in the built user.g.dart.
The example at https://flutter.io/json/#serializing-json-using-code-generation-libraries is old and only runs using package versions shown in the example pubspec.yaml on that page.
If you use latest packages, see example here instead: https://pub.dartlang.org/documentation/json_serializable/latest/
Note that one no longer needs to extend their class with _$UserSerializerMixin. with v1.x of the packages, _$UserToJson is created instead. Changes to your class are now simpler.
(I struggled for quite a while myself as I had used latest package versions in pubspec.yaml but the old example.)

SQLite.Net-PCL in Metro App using VB.NET - missing classes

I have included SQLite.Net-PCL v2.3.0 in my Metro app but it seems some classes are missing.
Dim MyPlatform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT()
Using connection = New SQLiteConnection(MyPlatform , _dbPath)
End Using
**SQLite.Net.Platform.WinRT.SQLitePlatformWinRT** class is not recognized.
Tried adding SQLite.Net.Platform.WinRTfirst but no success. IT says:
"To use this package you will need to install one of the platform packages or write your own implementation of ISQLitePlatform." (taken from https://www.nuget.org/packages/SQLite.Net.Platform.WinRT/)
What does it mean to implement my own interface ? I know my platform is WinRT, why can't I just use that version?
Any sample code or solution for this ?
You have to download and copy the sqlite3.dll in all the projects. See the following documentation:
https://sqlitepcl.codeplex.com/documentation
It will explain for each type of project

REST Assured: NoSuchMethodError org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType

I have REST Assured working in one of our JAR projects. Now I'm trying to add a similar test class in our WAR project.
I added REST Assured to the WAR project:
<dependency conf="test->default" org="com.jayway.restassured"
name="rest-assured" rev="1.8.1"/>
I have also ASM on the test classpath (asm-4.0, asm-analysis-4.0, asm-commons-4.0, asm-tree-4.0, asm-util-4.0); mentioning this since the only search results on my problem suggested a relationship with ASM.
When I run my test, it gives the following error:
java.lang.NoSuchMethodError: org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;
at com.jayway.restassured.internal.ResponseParserRegistrar.<init>(ResponseParserRegistrar.groovy)
at com.mycompany.testSomething(SomethingTest.java:50)
I've minimized my test to the following:
#Test
public void testSomething() {
ResponseParserRegistrar r = new ResponseParserRegistrar();
}
Obviously I have no direct need to create a ResponseParserRegistrar, but this is what REST Assured does and fails on when I use REST Assured.
Your help would be much appreciated!
Have a look at FAQ #2 at https://code.google.com/p/rest-assured/wiki/FAQ, that would solve your classpath issues. Also I would encourage you to upgrade to a newer version since 1.8.1 is really old.
There is possibility server can't read your method or it will require a some parameters.
NoSuchMethodError is being thrown when program tries to call a class method that doesn’t exist. The method can be static or it can be an instance method too

ServiceLoader issue in WebLogic12c

I have been trying to refactor our Activiti implementation into using CDI but ran into a number of problems. I've spent way too much time trying to resolve this already, but I just can't let it go...I think I've pinned the problem down now, setting up a clean structured war without involving Activiti and have been able to reproduce what I think is the main problem.
Basically I have jar1 and jar2, both CDI enabled by including META-INF/beans.xml. Both jars specify a class in META-INF/services/test.TheTest pointing to implementations local to respective jar. jar1 depends on jar2. Also, both jars point to an implementation of javax.enterprise.inject.spi.Extension, triggering the scenario. In each implementation of Extension, I have a method like:
public void afterDeploymentValidation(
#Observes AfterDeploymentValidation event, BeanManager beanManager) {
System.out.println("In jar1 extension");
ServiceLoader<TheTest> loader = ServiceLoader.load(TheTest.class);
Iterator<TheTest> serviceIterator = loader.iterator();
List<TheTest> discoveredLookups = new ArrayList<TheTest>();
while (serviceIterator.hasNext()) {
TheTest serviceInstance = (TheTest) serviceIterator.next();
discoveredLookups.add(serviceInstance);
System.out.println(serviceInstance.getClass().getName());
}
}
Now, my problem is that the ServiceLoader does not see any implementations in either case when running WebLogic12c. The same code works perfectly fine in both Jboss 7.1.1 and Glassfish , listing both implementations of the test.TheTest interface.
Is it fair to assume that this is indeed a problem in WebLogic 12c or am I doing something wrong? Please bare in mind that I am simply trying to emulate the production setup we use when incorporating Activiti.
Regards,
/Petter
There is a Classloader Analysis Tool provided with WLS, have you seen if this will help with the diagnosis of your issue.
You can access this tool by going to ip:port/wls-cat/index.jsp
Where port will be the port of the managed server where your application is deployed.