Selenium Java (ATUReporter)- Getting java.lang.NullPointerException error while running the testng suite with ATUReporter - selenium

I am getting java.lang.NullPointerException error while running my project which has Testng framework configured with ATUReporter
Things I have done:
Added the ATU jars in the project
Added the #Listeners({ ATUReportsListener.class, ConfigurationListener.class, MethodListener.class }) in my baseclass
Added the line System.setProperty("atu.reporter.config", "path\\ATU.properties");
Added this line to my testng file:
<listeners>
<listener class-name="atu.testng.reports.listeners.ATUReportsListener" />
<listener class-name="atu.testng.reports.listeners.ConfigurationListener" />
<listener class-name="atu.testng.reports.listeners.MethodListener" />
</listeners>
My ATU.properties file also is in the correct directory as mentioned in the Systemproperty line.
Please suggest !
Base class Sample:
#Listeners({ ATUReportsListener.class, ConfigurationListener.class, MethodListener.class })
public class test {
{
System.setProperty("atu.reporter.config", "path\\ATU.properties");
}
#Test(priority=0)
public void login()
{
OpenUrltest();
}
}
Error StackTrace:
java.lang.IllegalStateException: java.lang.NullPointerException
at atu.testng.reports.listeners.ATUReportsListener.onStart(Unknown Source)
at org.testng.SuiteRunner.invokeListeners(SuiteRunner.java:210)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1284)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1209)
at org.testng.TestNG.runSuites(TestNG.java:1124)
at org.testng.TestNG.run(TestNG.java:1096)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
Caused by: java.lang.NullPointerException
at atu.testng.reports.utils.Directory.init(Unknown Source)
at atu.testng.reports.utils.Directory.verifyRequiredFiles(Unknown Source)
... 12 more

The error occured because the ATU Reports directory was manually created for the output reports generation. After deleting this directory the error got wiped out clean, so i think ATU autocreates this directory when you try to run the suite for the 1st time.

Related

ByteBuddy reset fails when running with Eclipse (EclEmma/JaCoCo) Code Coverage

I am redefining classes with ByteBuddy within a unit test. I am resetting the class after each test to ensure no cross-talk between tests.
ByteBuddy works as expected when simply running the tests in the Eclipse IDE or when running with maven command line. But if it run in Eclipse with coverage, resetting the class results in the following exception:
java.lang.UnsupportedOperationException: class redefinition failed: attempted to change the schema (add/remove fields)
Bellow is a sample test which passes in the default JUnit runner but fails when run with Code Coverage in Eclipse. Below that is the full stack trace of the failure.
I am using ByteBuddy version 1.8.22 and the EclEmma Java Code Coverage Package version 3.1.0.201804041601.
I am assuming this issue is due to a conflict between ByteBuddy class modifications and EclEmma code instrumentation. It there an alternate approach to restoring class definitions that would work around this issue?
Fails under Coverage:
import static net.bytebuddy.matcher.ElementMatchers.named;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import net.bytebuddy.ByteBuddy;
import net.bytebuddy.agent.ByteBuddyAgent;
import net.bytebuddy.dynamic.loading.ClassReloadingStrategy;
import net.bytebuddy.implementation.FixedValue;
public class ByteBuddyEclEmmaTest {
#Test
public void recreateEclEmmaByteBuddyResetIssue() throws Exception {
ByteBuddyAgent.install();
ByteBuddy byteBuddy = new ByteBuddy();
ClassReloadingStrategy classReloadingStrategy = ClassReloadingStrategy.fromInstalledAgent();
byteBuddy
.redefine(X.class)
.method(named("getValue")).intercept(FixedValue.value("faked value"))
.make()
.load(X.class.getClassLoader(), classReloadingStrategy);
X x = new X();
assertThat(x.getValue()).isEqualTo("faked value");
classReloadingStrategy.reset(X.class);
assertThat(x.getValue()).isEqualTo("real value");
}
public class X {
public String getValue() {
return "real value";
}
}
}
Stack Trace:
java.lang.UnsupportedOperationException: class redefinition failed: attempted to change the schema (add/remove fields)
at sun.instrument.InstrumentationImpl.redefineClasses0(Native Method)
at sun.instrument.InstrumentationImpl.redefineClasses(InstrumentationImpl.java:170)
at net.bytebuddy.dynamic.loading.ClassReloadingStrategy$Strategy$1.apply(ClassReloadingStrategy.java:261)
at net.bytebuddy.dynamic.loading.ClassReloadingStrategy$Strategy$1.reset(ClassReloadingStrategy.java:279)
at net.bytebuddy.dynamic.loading.ClassReloadingStrategy.reset(ClassReloadingStrategy.java:209)
at net.bytebuddy.dynamic.loading.ClassReloadingStrategy.reset(ClassReloadingStrategy.java:195)
at ByteBuddyEclEmmaTest.recreateEclEmmaByteBuddyResetIssue(ByteBuddyEclEmmaTest.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
I figured out my issue was caused by an older version of ByteBuddy. I was getting version 1.6.14 pulled into my project from Mockito. When I explicitly brought in ByteBuddy version 1.8.22, the test runs successfully, both with and without Coverage.

How to create a custom Kotlin Inspection for Intellij Idea programmatically

I want to create a plugin for Intellij Idea which provides additional inspections for Kotlin language. Following the example from official documentation for creating inspections for Java, I ended up with following code, which is not working.
Here is the link to a repository with this project: https://bitbucket.org/magycbytes/kotlin-inspections/src/master/
Links to example I followed:
docummentation page: https://www.jetbrains.org/intellij/sdk/docs/tutorials/code_inspections.html
example project: https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/comparing_references_inspection
This is the provider for inspections.
package com.magicbytes.kotlin.inspections;
import com.intellij.codeInspection.InspectionToolProvider;
import com.magicbytes.kotlin.inspections.ExampleInspection;
import org.jetbrains.annotations.NotNull;
public class ExampleProvider implements InspectionToolProvider {
#NotNull
#Override
public Class[] getInspectionClasses() {
return new Class[]{ExampleInspection.class};
}
}
This is the actual inspection subclass. For the sake of shortness it's doing nothing, but should be loaded. Note: I changed the superclass to AbstractKotlinInspection
package com.magicbytes.kotlin.inspections;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.idea.inspections.AbstractKotlinInspection;
public class ExampleInspection extends AbstractKotlinInspection {
#Nls
#NotNull
#Override
public String getDisplayName() {
return "Kotlin Test";
}
}
My buid.gradle file looks like this:
plugins {
id 'java'
id 'org.jetbrains.intellij' version '0.3.2'
}
group 'com.magicbytes'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
intellij {
version '2018.1.4'
plugins 'kotlin'
}
Mine plugin.xml looks like this:
<idea-plugin>
<id>com.magicbytes.kotlin.inspections</id>
<name>Plugin display name here</name>
<description></description>
<depends>org.jetbrains.kotlin</depends>
<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
<inspectionToolProvider implementation="com.magicbytes.kotlin.inspections.ExampleProvider"/>
</extensions>
<actions>
</actions>
</idea-plugin>
I did all the linking with plugin.xml file. But when I'm running I'm getting exception in testing IDE. Appreciate any insight. NOTE: I'm using runIde to debug the plugin.
Exception which I'm getting..
java.lang.ClassNotFoundException: ExampleProvider PluginClassLoader[com.magicbytes.kotlin.inspections, 1.0-SNAPSHOT] com.intellij.ide.plugins.cl.PluginClassLoader#6f989177
com.intellij.openapi.extensions.impl.PicoPluginExtensionInitializationException: java.lang.ClassNotFoundException: ExampleProvider PluginClassLoader[com.magicbytes.kotlin.inspections, 1.0-SNAPSHOT] com.intellij.ide.plugins.cl.PluginClassLoader#6f989177
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getComponentInstance(ExtensionComponentAdapter.java:96)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getExtension(ExtensionComponentAdapter.java:119)
at com.intellij.openapi.extensions.impl.ExtensionPointImpl.processAdapters(ExtensionPointImpl.java:246)
at com.intellij.openapi.extensions.impl.ExtensionPointImpl.getExtensions(ExtensionPointImpl.java:191)
at com.intellij.openapi.extensions.Extensions.getExtensions(Extensions.java:102)
at com.intellij.openapi.extensions.Extensions.getExtensions(Extensions.java:89)
at com.intellij.openapi.extensions.ExtensionPointName.getExtensions(ExtensionPointName.java:50)
at com.intellij.codeInspection.ex.InspectionToolRegistrar.ensureInitialized(InspectionToolRegistrar.java:54)
at com.intellij.codeInspection.ex.InspectionToolRegistrar.createTools(InspectionToolRegistrar.java:127)
at com.intellij.codeInspection.ex.InspectionSearchableOptionContributor.processOptions(InspectionSearchableOptionContributor.java:34)
at com.intellij.ide.ui.search.SearchableOptionPreloader.preload(SearchableOptionPreloader.java:49)
at com.intellij.openapi.application.Preloader.lambda$null$0(Preloader.java:74)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:543)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:488)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:94)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
at com.intellij.openapi.application.Preloader.lambda$initComponent$1(Preloader.java:72)
at com.intellij.util.concurrency.BoundedTaskExecutor$2.run(BoundedTaskExecutor.java:212)
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: java.lang.ClassNotFoundException: ExampleProvider PluginClassLoader[com.magicbytes.kotlin.inspections, 1.0-SNAPSHOT] com.intellij.ide.plugins.cl.PluginClassLoader#6f989177
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.loadImplementationClass(ExtensionComponentAdapter.java:161)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getComponentImplementation(ExtensionComponentAdapter.java:66)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getComponentInstance(ExtensionComponentAdapter.java:73)
... 21 more
Caused by: java.lang.ClassNotFoundException: ExampleProvider PluginClassLoader[com.magicbytes.kotlin.inspections, 1.0-SNAPSHOT] com.intellij.ide.plugins.cl.PluginClassLoader#6f989177
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:63)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.loadImplementationClass(ExtensionComponentAdapter.java:158)
... 23 more
Caused by:
java.lang.RuntimeException: java.lang.ClassNotFoundException: ExampleProvider PluginClassLoader[com.magicbytes.kotlin.inspections, 1.0-SNAPSHOT] com.intellij.ide.plugins.cl.PluginClassLoader#6f989177
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.loadImplementationClass(ExtensionComponentAdapter.java:161)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getComponentImplementation(ExtensionComponentAdapter.java:66)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getComponentInstance(ExtensionComponentAdapter.java:73)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getExtension(ExtensionComponentAdapter.java:119)
at com.intellij.openapi.extensions.impl.ExtensionPointImpl.processAdapters(ExtensionPointImpl.java:246)
at com.intellij.openapi.extensions.impl.ExtensionPointImpl.getExtensions(ExtensionPointImpl.java:191)
at com.intellij.openapi.extensions.Extensions.getExtensions(Extensions.java:102)
at com.intellij.openapi.extensions.Extensions.getExtensions(Extensions.java:89)
at com.intellij.openapi.extensions.ExtensionPointName.getExtensions(ExtensionPointName.java:50)
at com.intellij.codeInspection.ex.InspectionToolRegistrar.ensureInitialized(InspectionToolRegistrar.java:54)
at com.intellij.codeInspection.ex.InspectionToolRegistrar.createTools(InspectionToolRegistrar.java:127)
at com.intellij.codeInspection.ex.InspectionSearchableOptionContributor.processOptions(InspectionSearchableOptionContributor.java:34)
at com.intellij.ide.ui.search.SearchableOptionPreloader.preload(SearchableOptionPreloader.java:49)
at com.intellij.openapi.application.Preloader.lambda$null$0(Preloader.java:74)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:543)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:488)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:94)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
at com.intellij.openapi.application.Preloader.lambda$initComponent$1(Preloader.java:72)
at com.intellij.util.concurrency.BoundedTaskExecutor$2.run(BoundedTaskExecutor.java:212)
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.ClassNotFoundException: ExampleProvider PluginClassLoader[com.magicbytes.kotlin.inspections, 1.0-SNAPSHOT] com.intellij.ide.plugins.cl.PluginClassLoader#6f989177
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:63)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.loadImplementationClass(ExtensionComponentAdapter.java:158)
... 23 more
After I've imported your GitHub repo and built it locally I've found out that ./build/libs/kotlin.inspections-1.0-SNAPSHOT.jar includes META-INF only, but no classes. I suspect it's because your source code is located under ./src/main/src, not ./src/main/java as it's typical for Gradle projects, so it simply assumes you have no code at all.
After renaming that inner src directory into java the error changed to
class com.magicbytes.kotlin.inspections.ExampleInspection: group display name should be overridden or configured via XML class com.magicbytes.kotlin.inspections.ExampleInspection
java.lang.Throwable: class com.magicbytes.kotlin.inspections.ExampleInspection: group display name should be overridden or configured via XML class com.magicbytes.kotlin.inspections.ExampleInspection
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:123)
at com.intellij.codeInspection.InspectionProfileEntry.getGroupDisplayName(InspectionProfileEntry.java:230)
at com.intellij.codeInspection.InspectionProfileEntry.getGroupPath(InspectionProfileEntry.java:239)
at com.intellij.codeInspection.ex.InspectionToolWrapper.getGroupPath(InspectionToolWrapper.java:161)
at com.intellij.codeInspection.ex.InspectionSearchableOptionContributor.processOptions(InspectionSearchableOptionContributor.java:40)
at com.intellij.ide.ui.search.SearchableOptionPreloader.preload(SearchableOptionPreloader.java:49)
at com.intellij.openapi.application.Preloader.lambda$null$0(Preloader.java:74)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:580)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:525)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:85)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
at com.intellij.openapi.application.Preloader.lambda$initComponent$1(Preloader.java:72)
at com.intellij.util.concurrency.BoundedTaskExecutor$2.run(BoundedTaskExecutor.java:212)
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)
which is much better and looks like a separate problem with your code violating some contract.

java.lang.ClassNotFoundException: org.eclipse.equinox.launcher.WebStartMain

I try to launch my RCP-project with jnlp. So i implemented a small e4-RCP project. Starting with the product doesn't cause any problem. The application supposedly works just fine. I installed a tomcat server running at localhost:8080, this also starts very well. Than i wrote a jnlp file for the app. exported and signed the jar. When i try to start the app. as http://localhost:8080/webstart.jnlp i get the exception:
java.lang.ClassNotFoundException: org.eclipse.equinox.launcher.WebStartMain
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at com.sun.jnlp.JNLPClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at de.checkpoint.webstart.WebstartLauncher.main(WebstartLauncher.java:9)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Thread.java:748)
Having said all all of that, here is my main:
package de.checkpoint.webstart;
import org.eclipse.equinox.launcher.WebStartMain;
public class WebstartLauncher {
public static void main(String[] args) {
WebStartMain.main(args);
}
}
Here is my jnlp file:
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://localhost:8080/" href="webstart.jnlp">
<information>
<title>Jnlp Webstart Test</title>
<vendor>Boris Nguema B.</vendor>
<homepage href="http://localhost:8080/" />
<description>Testing Webstart</description>
</information>
<security>
<all-permissions/>
</security>
<!-- <property name="eclipse.product" value="de.checkpoint.product"/> -->
<!-- <property name="osgi.frameworkParentClassloader" value="current"/> -->
<!-- <property name="jnlp.osgi.parentClassloader" value="current"/> -->
<resources>
<j2se version="1.8+" />
<jar href="de.checkpoint.start_1.0.0.201711041646.jar" />
</resources>
<application-desc main-class="de.checkpoint.webstart.WebstartLauncher" />
</jnlp>
Can anyone tells me, what am I missing?
I am not sure if you already found out the problem,but equinox launcher do not have those lines in the manifest:
Permissions: all-permissions
Codebase: *
Trusted-Only: true
you need to add them and sign.

Object in mule's registry cannot be cast to org.mule.construct.AbstractFlowConstruct on application startup

I'm trying to store instance of some class in mule registry on flow application startup. Below you can see my java code and flow fragment. My problem is that sometimes application deployment fails with following error:
Caused by: java.lang.ClassCastException: com.company.test.sorter.model.Config cannot be cast to org.mule.construct.AbstractFlowConstruct
at org.mule.module.management.mbean.FlowConstructService.postRegister(FlowConstructService.java:139)
at org.mule.module.management.agent.ClassloaderSwitchingMBeanWrapper.postRegister(ClassloaderSwitchingMBeanWrapper.java:101)
You can find whole stacktrace below. I must repeat: this exception is raised only sometimes, approximately every fifth deployment of unchanged application. In most cases application runs perfectly fine. I googled for this exceptions and classes but I didn't find any solution. I am using Mule 3.2.1 (standalone). Is it a bug or am I doing something wrong?
#XmlRootElement(name = "config")
public class Config {
private String x2Regex;
private String x3Regex;
private String x2QueueName;
private String x3QueueName;
// constructors, getters and setters
}
public class Initializer implements
MuleContextNotificationListener<MuleContextNotification> {
#Override
public void onNotification(MuleContextNotification notification) {
if (notification.getAction() == MuleContextNotification.CONTEXT_STARTED) {
try {
notification.getMuleContext().getRegistry().registerObject("config", new Config());
} catch (RegistrationException e) {
// cut
}
}
}
}
<notifications>
<notification event="CONTEXT"/>
<notification-listener ref="Initializer"/>
</notifications>
<spring:beans>
<spring:bean id="Initializer" name="Initializer" class="com.company.test.sorter.Initializer" doc:name="Bean"/>
</spring:beans>
Below is fragment of mule's log with exception:
+ Failed to deploy app 'number-sorter', see below +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
org.mule.module.launcher.DeploymentException: Failed to deploy application [number-sorter]
at org.mule.module.launcher.DefaultMuleDeployer.deploy(DefaultMuleDeployer.java:68)
at org.mule.module.launcher.DeploymentService.start(DeploymentService.java:175)
at org.mule.module.launcher.MuleContainer.start(MuleContainer.java:157)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mule.module.reboot.MuleContainerWrapper.start(MuleContainerWrapper.java:56)
at org.tanukisoftware.wrapper.WrapperManager$12.run(WrapperManager.java:2788)
Caused by: org.mule.api.MuleRuntimeException: MBeans Failed to initialise
at org.mule.module.management.agent.JmxAgent$MuleContextStartedListener.onNotification(JmxAgent.java:707)
at org.mule.module.management.agent.JmxAgent$MuleContextStartedListener.onNotification(JmxAgent.java:685)
at org.mule.context.notification.Sender.dispatch(Sender.java:40)
at org.mule.context.notification.Policy.dispatch(Policy.java:122)
at org.mule.context.notification.ServerNotificationManager.notifyListeners(ServerNotificationManager.java:244)
at org.mule.context.notification.ServerNotificationManager.fireNotification(ServerNotificationManager.java:197)
at org.mule.DefaultMuleContext.fireNotification(DefaultMuleContext.java:404)
at org.mule.DefaultMuleContext.start(DefaultMuleContext.java:226)
at org.mule.module.launcher.application.DefaultMuleApplication.start(DefaultMuleApplication.java:146)
at org.mule.module.launcher.application.ApplicationWrapper.start(ApplicationWrapper.java:107)
at org.mule.module.launcher.DefaultMuleDeployer.deploy(DefaultMuleDeployer.java:52)
... 8 more
Caused by: javax.management.RuntimeMBeanException: RuntimeException thrown in postRegister method
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.postRegisterInvoke(Unknown Source)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(Unknown Source)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(Unknown Source)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(Unknown Source)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(Unknown Source)
at org.mule.module.management.agent.JmxAgent.registerFlowConstructServices(JmxAgent.java:428)
at org.mule.module.management.agent.JmxAgent$MuleContextStartedListener.onNotification(JmxAgent.java:700)
... 18 more
Caused by: java.lang.ClassCastException: com.company.test.sorter.model.Config cannot be cast to org.mule.construct.AbstractFlowConstruct
at org.mule.module.management.mbean.FlowConstructService.postRegister(FlowConstructService.java:139)
at org.mule.module.management.agent.ClassloaderSwitchingMBeanWrapper.postRegister(ClassloaderSwitchingMBeanWrapper.java:101)
... 25 more
Feels like a bug: after reading the source code, I find no reasonable explanation to why Mule would try to register your custom object in JMX while mistaking it for a Flow!
As a side note, why using a notification listener and the Mule registry when you can just build your object with Spring?

GWT testing error

So I'm trying to write my first gwt test. I got this part figured out that I need to add gwt-dev.jar to maven pom file, but now when I run my test I get this error:
testSimple(com.karq.tvkava.client.TelekanalServiceImplTest) Time elapsed: 3.809 sec <<< ERROR!
com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
at com.google.gwt.dev.cfg.ModuleDef.checkForSeedTypes(ModuleDef.java:518)
at com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:327)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1342)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1309)
at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:650)
at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:441)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:296)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
And here's my test file
public class TelekanalServiceImplTest extends GWTTestCase {
#Override
public String getModuleName() {
return "com.karq.tvkava.tvkavaJUnit";
}
public void testSimple(){
boolean isSaved = true;
assertTrue(isSaved);
}
}
did you include
<inherits name="com.google.gwt.junit.JUnit" />
in your *.gwt.xml file?
If this doesn't fix your error you might want to take a look at Unit Testing GWT Applications with JUnit.