I am invoking JsonBuilder.toString() in Groovy code inside a Camel route. This Camel route runs inside Widlfly Camel 12.0. The code looks like so:
def builder = new JsonBuilder()
builder {
'myField': myFieldVal
}
return builder.toString()
The builder.toString() method invocation produces the following error:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class
groovy.json.internal.FastStringUtils
But I do have the dependencies mentioned properly in pom.xml like so:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-groovy</artifactId>
<scope>provided</scope>
</dependency>
I also tried adding this extra dependency to resolve the problem:
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-json</artifactId>
<version>2.4.13</version>
</dependency>
But I still keep on getting the above exception. However when I run the same Camel code using the camel-maven-plugin, without deploying it inside Wildfly, it runs perfectly.
Can someone please help?
Thanks in advance.
I think the problem is that module org.apache.camel.script.groovy cannot access sun.misc.Unsafe. So I added the following module dependency to modules/system/layers/fuse/org/apache/camel/script/groovy/main/module.xml.
<module name="sun.jdk">
<imports>
<include path="sun/misc/Unsafe"/>
</imports>
</module>
Your example worked for me afterwards.
Related
I could run Harness example here
but I copied the code to another directory and use the same dependencies in pom.xml, it raised error that no routers defined
I debug and found that MyModule which extends StateFunModule was not found. Thus the class loader get no module and the router and func size is 0 and failed in validation step. (The step to check ingress, egress, router, func not size 0)
PS: I just copied all the code, thus #AutoService is also included. According to here, it should work without further configuration.
Update:
Seems its statefun issue related to #AutoService
I added following code in the pom in another project (unrelated to statefun)
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>1.0-rc6</version>
<optional>true</optional>
</dependency>
It works, the META-INF is generated.
But if using
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>statefun-flink-distribution</artifactId>
<version>2.2-SNAPSHOT</version>
</dependency>
The META-INF is not generated, and I found in statefun, the dependency used is actually
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>1.0-rc6</version>
<optional>true</optional>
</dependency>
And I test this dependency, it could not generate META-INF, and I am curious that why if we directly clone the statefun repo and mvn clean package, it could work.
I configured extent reports (Selenium - TESTING) in my project and everything was working fine. I had tried to configure Maven but it failed, now extent reports were working fine and suddenly I have started getting below messages in eclipse console,
I tried to clean project, restart the system, update extent jar files, removing Maven related configurations, but nothing worked and still getting the below errors in console and my second iteration is not getting executed properly.
DEBUG 15341 [freemark] (): Couldn't find template in cache for "index.ftl"("en", UTF-8, parsed); will try to load it.
DEBUG 15341 [freemark] (): TemplateLoader. findTemplateSource("index_en.ftl"): Not found.
DEBUG 15341 [freemark] (): TemplateLoader.findTemplateSource("index.ftl"): Found.
DEBUG 15341 [freemark] (): Loading template for "index.ftl"("en", UTF-8, parsed) from "jar:file:/C:/Users/a00/Downloads/selenium-java-3.13.0/jar_files(1) /extentreports-3.1.5.jar!/com/aventstack/extentreports/view/html-report /index.ftl".
and so on.
Set org.freemarker.loggerLibrary property to none as below
System.setProperty("org.freemarker.loggerLibrary", "none");
If you are moving to maven as a build tool make sure you have the dependencies for extent reports. Your stack trace is complaining about freemarker. Make sure you have these 3 dependencies in your POM file
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.freemarker/freemarker -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.23</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.8.3</version>
</dependency>
I need to mark a step pass or fail a step after validating a text "shipping" available or not available in the page.
How can I mark the step pass or fail based availability.
As you are using Cucumber, I am assuming you are using JUnit and Java.
You need to use Assert of JUNIT/TestNG
You need to use Junit separately don't use cucumber JUnit API for asserting
You can use below dependencies
https://mvnrepository.com/artifact/junit/junit/4.12
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
Now you can use assert as below:
Assert.assertEquals("shubham page", driver.getTitle());
Use below import
import org.junit.Assert;
Running Camel 2.17.3 on Karaf 4.0.5 with camel-atmosphere-websocket feature Atmosphere (v2.4.3) raises the following exception:
Cannot load the WebSocketProtocol org.apache.camel.component.atmosphere.websocket.WebsocketHandler
java.lang.ClassNotFoundException: org.apache.camel.component.atmosphere.websocket.WebsocketHandler not found by org.atmosphere.runtime [203]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1574)[org.apache.felix.framework-5.4.0.jar:]
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79)[org.apache.felix.framework-5.4.0.jar:]
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018)[org.apache.felix.framework-5.4.0.jar:]
at java.lang.ClassLoader.loadClass(ClassLoader.java:805)[:1.8.0-internal]
at org.atmosphere.util.IOUtils.loadClass(IOUtils.java:370)[203:org.atmosphere.runtime:2.4.3]
at org.atmosphere.cpr.AtmosphereFramework.initWebSocket(AtmosphereFramework.java:1762)[203:org.atmosphere.runtime:2.4.3]
The package is exported by the bundle org.apache.camel.camel-atmosphere-websocket.
Am I missing any dependencies or is there an issue with the startup order?
Add this dependency to your pom.xml
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-atmosphere-websocket</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
As mentioned you need to use the same version for all dependecies.Reference : http://camel.apache.org/atmosphere-websocket.htmlHope this Works.
I'm new to GWT. I've manage to do the tutorial about how to build the simple StockWatcher application.
Now, I want to load the data from the server. After reading about the many different ways to do it in GWT I decide to use RequestFactory because apparently it the most affective way to write maintainable application.
The problem is that there is no tutorial about RequestFactory and Eclipse is hard enough to manage when you know if, it even harder to manage when I'm using a new tool like GWT.
I've manage to find the different jars required for RequestFactory like
gwt-servlet.jar
gwt-servlet-deps.jar
requestfactory-server.jar
Now I get the following error:
java.lang.RuntimeException: The RequestFactory ValidationTool must be run for the com.google.gwt.sample.stockwatcher.shared.service.StockWatcherRequestFactory RequestFactory type
I've even found a direction for this as well: RequestFactoryInterfaceValidation
but it's still not working.
I've add the com.google.web.bindery.requestfactory.apt.ValidationTool to my build path and it seem to help (the message was gone) but then I got different error message.
I've push the source to github repository.
Any help will be great.
I'll try to make a post once I'll manage to get this working so other can use it.
Thank you,
Ido.
I figure this out. object is not an instance of declaring class means that we try to invoke a instance method on object which is not of the type the method is declared on.
My mistake was that in my ServiceLocator implementation I mistakably return an instance of my domain model object (StockQuote) instead of the DAO (StockQuoteDao). This cause RequestFactory code to try and invoke StockQuoteDao.getNum method on StockQuote instance.
Ido.
If you are using google plugin for eclipse use this
http://vivagwt.blogspot.com/2011/09/requestfactory-en-gwt-24.html
you need rebuild you project every time you change you requestcontext
note: gwt-servlet.jar is needed if you use RPC
Also you may automatically run RequestFactory ValidationTool with maven in compiling phase:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.web.bindery</groupId>
<artifactId>requestfactory-apt</artifactId>
<version>2.6.1</version>
</dependency>
</dependencies>
</plugin>