Read resources in annotation processor with kotlin and kapt - kotlin

I want to use an annotation processor that needs to read files from src/main/resources during the processing. It works fine with the following configuration when using java as a source:
tasks.withType<JavaCompile> {
options.sourcepath = files("src/main/resources")
}
I´m now trying to use the same annotation processor with kotlin and kapt, it however always fails with a file not found exception.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':cap-crd:kaptKotlin'.
...
Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
...
Caused by: java.lang.reflect.InvocationTargetException
...
Caused by: java.lang.reflect.InvocationTargetException
...
Caused by: com.sun.tools.javac.processing.AnnotationProcessingError: java.lang.RuntimeException: java.io.FileNotFoundException: resource-operation.vm
...
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: resource-operation.vm
at io.sundr.transform.internal.VelocityTransformationProcessor.process(VelocityTransformationProcessor.java:128)
at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt)
at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:147)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:972)
... 47 more
Caused by: java.io.FileNotFoundException: resource-operation.vm
at jdk.compiler/com.sun.tools.javac.processing.JavacFiler.getResource(JavacFiler.java:586)
at io.sundr.transform.internal.VelocityTransformationProcessor.readTemplate(VelocityTransformationProcessor.java:223)
at io.sundr.transform.internal.VelocityTransformationProcessor.process(VelocityTransformationProcessor.java:124)
... 50 more
So far I did not find the equivalent configuration for options.sourcepath with kotlin/kapt in order for the annotation processor to be able to access the files.
Thanks!

I got it working with the following kapt config
kapt {
javacOptions {
option("--source-path", file("src/main/resources").absolutePath)
}
}

If you have resource-operation.vm under src/main/resourcesmake sure to reference it using /resource-operation.vm

Related

Error while deploying with MP config in TomEE 9.0.0 SEVERE: CDI Beans module deployment failed with No ConfigProviderResolver implementation found

SEVERE: CDI Beans module deployment failed
org.apache.webbeans.exception.WebBeansDeploymentException: Error while sending SystemEvent to a CDI Extension! org.apache.webbeans.portable.events.discovery.AfterDeploymentValidationImpl#4cc26df
at org.apache.webbeans.event.NotificationManager.onWebBeansException(NotificationManager.java:1075)
at org.apache.webbeans.event.NotificationManager.doFireSync(NotificationManager.java:1026)
at org.apache.webbeans.event.NotificationManager.doFireEvent(NotificationManager.java:952)
at org.apache.webbeans.event.NotificationManager.fireEvent(NotificationManager.java:928)
at org.apache.webbeans.container.BeanManagerImpl.fireEvent(BeanManagerImpl.java:495)
at org.apache.webbeans.container.BeanManagerImpl.fireLifecycleEvent(BeanManagerImpl.java:490)
at org.apache.webbeans.config.BeansDeployer.fireAfterDeploymentValidationEvent(BeansDeployer.java:900)
at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:386)'
Caused by: org.apache.webbeans.exception.WebBeansException: java.lang.IllegalStateException: No ConfigProviderResolver implementation found!
at org.apache.webbeans.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:377)
at org.apache.webbeans.event.NotificationManager.invokeObserverMethod(NotificationManager.java:1146)
at org.apache.webbeans.event.NotificationManager.doFireSync(NotificationManager.java:1009)
... 59 more
Caused by: java.lang.IllegalStateException: No ConfigProviderResolver implementation found!
at org.eclipse.microprofile.config.spi.ConfigProviderResolver.loadSpi(ConfigProviderResolver.java:138)
at org.eclipse.microprofile.config.spi.ConfigProviderResolver.instance(ConfigProviderResolver.java:124)
at org.eclipse.microprofile.config.ConfigProvider.getConfig(ConfigProvider.java:85)
at org.apache.tomee.microprofile.health.MicroProfileHealthReporterProducer.reporter(MicroProfileHealthReporterProducer.java:38)
==============================================================================
Other error in log
Caused by: org.apache.openejb.OpenEJBRuntimeException: org.apache.webbeans.exception.WebBeansDeploymentException: Error while sending SystemEvent to a CDI Extension! org.apache.webbeans.portable.events.discovery.AfterDeploymentValidationImpl#4cc26df
at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:200)
at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:260)
... 51 more
Caused by: org.apache.webbeans.exception.WebBeansDeploymentException: Error while sending SystemEvent to a CDI Extension! org.apache.webbeans.portable.events.discovery.AfterDeploymentValidationImpl#4cc26df
at org.apache.webbeans.event.NotificationManager.onWebBeansException(NotificationManager.java:1075)
at org.apache.webbeans.event.NotificationManager.doFireSync(NotificationManager.java:1026)
at org.apache.webbeans.event.NotificationManager.doFireEvent(NotificationManager.java:952)
at org.apache.webbeans.event.NotificationManager.fireEvent(NotificationManager.java:928)
at org.apache.webbeans.container.BeanManagerImpl.fireEvent(BeanManagerImpl.java:495)
at org.apache.webbeans.container.BeanManagerImpl.fireLifecycleEvent(BeanManagerImpl.java:490)
at org.apache.webbeans.config.BeansDeployer.fireAfterDeploymentValidationEvent(BeansDeployer.java:900)
at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:386)
at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:196)
... 52 more
Caused by: org.apache.webbeans.exception.WebBeansException: java.lang.IllegalStateException: No ConfigProviderResolver implementation found!
at org.apache.webbeans.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:377)
at org.apache.webbeans.event.NotificationManager.invokeObserverMethod(NotificationManager.java:1146)
at org.apache.webbeans.event.NotificationManager.doFireSync(NotificationManager.java:1009)
... 59 more
Caused by: java.lang.IllegalStateException: No ConfigProviderResolver implementation found!
at org.eclipse.microprofile.config.spi.ConfigProviderResolver.loadSpi(ConfigProviderResolver.java:138)
at org.eclipse.microprofile.config.spi.ConfigProviderResolver.instance(ConfigProviderResolver.java:124)
at org.eclipse.microprofile.config.ConfigProvider.getConfig(ConfigProvider.java:85)
at org.apache.tomee.microprofile.health.MicroProfileHealthReporterProducer.reporter(MicroProfileHealthReporterProducer.java:38)
when Checked with tomee team they are saying this can be related to the Microprofile config impl shifting from geronimo to smallrye https://issues.apache.org/jira/browse/TOMEE-4184
but if the jar's are already in class path dont know why we see this
No ConfigProviderResolver implementation found! error

Self contained Kotlin/Gradle project produces java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics

Can anyone help me please? I need to setup a completely offline IntelliJ project with gradle and kotlin for our constrained school environment (No Kotlin installed, No Gradle installed, No Internet).
I packed all kotlin dependencies into libs/kotlin but it still tells me, that kotlin.jvm.internal.Intrinsics is not found. You can find the repo here:
Could not perform incremental compilation: Could not connect to Kotlin compile daemon
Could not connect to kotlin daemon. Using fallback strategy.
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler$Companion.main(K2JVMCompiler.kt)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.main(K2JVMCompiler.kt)
Caused by: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
... 2 more
Caused by: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics
You can checkout the repo here:
https://github.com/emign/kotlinOfflineTest

spark.read.parquet not working in Colab

Py4JJavaError: An error occurred while calling o188.parquet.
: java.lang.RuntimeException: java.lang.ClassNotFoundException: Class org.apache.hadoop.fs.s3a.S3AFileSystem not found
I tried adding the missing hadoop-aws jar file using spark-submit to the classpath but was unable to add it. This is what I tried:
!spark-submit --jars /content/hadoop-aws-2.7.1.jar
Exception in thread "main" java.lang.IllegalArgumentException: Missing application resource.
os.environ['PYSPARK_SUBMIT_ARGS'] = "--packages=org.apache.hadoop:hadoop-aws:2.7.3 pyspark-shell"

Error while using JUnit5 with spring boot 2

I am getting following error while running JUnit5 with SpringBoot.
Here is the stack trace that I get when I run
./gradlew clean test
:junitPlatformTest
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/log4j/util/ReflectionUtil
at org.apache.logging.log4j.jul.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:34)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
at org.apache.logging.log4j.jul.LogManager.getLogger(LogManager.java:89)
at java.util.logging.LogManager.demandLogger(LogManager.java:551)
at java.util.logging.Logger.demandLogger(Logger.java:455)
at java.util.logging.Logger.getLogger(Logger.java:502)
at org.junit.platform.commons.logging.LoggerFactory$DelegatingLogger.<init>(LoggerFactory.java:62)
at org.junit.platform.commons.logging.LoggerFactory.getLogger(LoggerFactory.java:49)
at org.junit.platform.launcher.core.DefaultLauncher.<clinit>(DefaultLauncher.java:44)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:59)
at org.junit.platform.console.tasks.ConsoleTestExecutor.executeTests(ConsoleTestExecutor.java:61)
at org.junit.platform.console.tasks.ConsoleTestExecutor.lambda$execute$0(ConsoleTestExecutor.java:57)
at org.junit.platform.console.tasks.CustomContextClassLoaderExecutor.invoke(CustomContextClassLoaderExecutor.java:33)
at org.junit.platform.console.tasks.ConsoleTestExecutor.execute(ConsoleTestExecutor.java:57)
at org.junit.platform.console.ConsoleLauncher.executeTests(ConsoleLauncher.java:85)
at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:75)
at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:48)
at org.junit.platform.console.ConsoleLauncher.main(ConsoleLauncher.java:40)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.util.ReflectionUtil
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 18 more
The github url for above code is github link
This is caused by mixing different versions of Log4J on the test runtime classpath. Spring Boot pulls in 2.10.0, your build.gradle declares 2.6.2.
If you remove the version from your dependency definition, Spring Boot will define the version and it will work.
So, please replace these two lines
testRuntime("org.apache.logging.log4j:log4j-core:${log4jVersion}")
testRuntime("org.apache.logging.log4j:log4j-jul:${log4jVersion}")
with these:
testRuntime("org.apache.logging.log4j:log4j-core")
testRuntime("org.apache.logging.log4j:log4j-jul")
Alternatively, you can delete the logManager property from the junitPlatform extension and remove both dependencies.

MobileFirst8.0- Unable to delete Adapters and Applications form Application Console

I am unable to delete adapters/applications from the console, it is continuously showing:
RuntimeException: Synchronization failure
Screenshot attached
Messages.log
[10/26/16 17:59:34:790 IST] 00000021 com.mfp.adapter.SecurityAdapterApplication I Adapter initialized!
[10/26/16 17:59:34:797 IST] 00000021 rnal.connectivity.synchronization.RuntimeSynchronizationBean E FWLSE0324: Runtime synchronization failed. Caused by: java.lang.RuntimeException: No resource classes found for adapter 'SecurityAdapter'
com.ibm.mfp.server.core.shared.deployment.DeploymentException: java.lang.RuntimeException: No resource classes found for adapter 'SecurityAdapter'
at com.ibm.mfp.server.java.adapter.internal.deploy.JaxRsSandboxDeploymentHandler.deploy(JaxRsSandboxDeploymentHandler.java:131)
at com.ibm.mfp.server.java.adapter.internal.deploy.JaxRsSandboxDeploymentHandler.deploy(JaxRsSandboxDeploymentHandler.java:47)
at com.ibm.mfp.server.core.internal.deployment.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:187)
at com.ibm.mfp.server.core.internal.deployment.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:484)
at com.ibm.mfp.server.core.internal.deployment.DeploymentManagerImpl.changeDeploymentState(DeploymentManagerImpl.java:360)
at com.ibm.mfp.server.mgmt.internal.connectivity.synchronization.RuntimeSynchronizationBean.sync(RuntimeSynchronizationBean.java:207)
at com.ibm.mfp.server.mgmt.internal.connectivity.synchronization.RuntimeMBeanExporterListener.mbeanRegistered(RuntimeMBeanExporterListener.java:71)
at org.springframework.jmx.export.MBeanExporter.notifyListenersOfRegistration(MBeanExporter.java:1055)
at org.springframework.jmx.export.MBeanExporter.onRegister(MBeanExporter.java:1029)
at org.springframework.jmx.support.MBeanRegistrationSupport.onRegister(MBeanRegistrationSupport.java:301)
at org.springframework.jmx.support.MBeanRegistrationSupport.doRegister(MBeanRegistrationSupport.java:229)
at org.springframework.jmx.export.MBeanExporter.registerBeanInstance(MBeanExporter.java:670)
at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:615)
at org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExporter.java:550)
at org.springframework.jmx.export.MBeanExporter.afterSingletonsInstantiated(MBeanExporter.java:432)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:775)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:663)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:629)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:677)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:548)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:489)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:332)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadOnStartupCheck(ServletWrapper.java:1423)
at com.ibm.ws.webcontainer.webapp.WebApp.doLoadOnStartupActions(WebApp.java:1180)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinally(WebApp.java:1148)
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:1054)
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:6448)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApp(DynamicVirtualHost.java:446)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApplication(DynamicVirtualHost.java:441)
at com.ibm.ws.webcontainer.osgi.WebContainer.startWebApplication(WebContainer.java:981)
at com.ibm.ws.webcontainer.osgi.WebContainer.startModule(WebContainer.java:805)
at com.ibm.ws.app.manager.web.internal.WebModuleHandlerImpl.deployModule(WebModuleHandlerImpl.java:102)
at com.ibm.ws.app.manager.module.internal.DeployedAppInfoBase.deployModule(DeployedAppInfoBase.java:870)
at com.ibm.ws.app.manager.module.internal.DeployedAppInfoBase.deployModules(DeployedAppInfoBase.java:830)
at com.ibm.ws.app.manager.module.internal.DeployedAppInfoBase.deployApp(DeployedAppInfoBase.java:817)
at com.ibm.ws.app.manager.war.internal.WARApplicationHandlerImpl.install(WARApplicationHandlerImpl.java:66)
at com.ibm.ws.app.manager.internal.statemachine.StartAction.execute(StartAction.java:139)
at com.ibm.ws.app.manager.internal.statemachine.ApplicationStateMachineImpl.enterState(ApplicationStateMachineImpl.java:1168)
at com.ibm.ws.app.manager.internal.statemachine.ApplicationStateMachineImpl.run(ApplicationStateMachineImpl.java:781)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: No resource classes found for adapter 'SecurityAdapter'
at com.ibm.mfp.server.java.adapter.shared.JAXRSSandbox.produceSwaggerDoc(JAXRSSandbox.java:241)
at com.ibm.mfp.server.java.adapter.shared.JAXRSSandbox.init(JAXRSSandbox.java:165)
at com.ibm.mfp.server.java.adapter.internal.deploy.JaxRsSandboxDeploymentHandler.deploy(JaxRsSandboxDeploymentHandler.java:119)
... 45 more
[10/26/16 17:59:34:802 IST] 00000021 connectivity.synchronization.AdminSynchronizationInterceptor I Runtime service is blocked, current state: synchronization required
[10/26/16 17:59:34:804 IST] 00000067 com.mfp.datamatics.IntegrationAdapterStubApplication I Adapter destroyed!
It's unclear how you managed to get to this error:
FWLSE0324: Runtime synchronization failed. Caused by: java.lang.RuntimeException: No resource classes found for adapter 'SecurityAdapter'
On the surface, this error likely means that you deleted the resource .java file from your adapter, but kept the JAXRSApplicationClass definition of the resource in the adapter.xml file.
To better understand the problem, please upload your .adapter file somewhere so it could be debugged.
As for what you can do in the meanwhile to clear the database, I tried various ways but looks like only a re-install of the devkit currently works...