Extent reports - Exception in thread "main" java.lang.NoSuchFieldError: VERSION_2_3_23 - extentreports

While running the below code I found following exception. Please help me to resolve the issue. I tried with changing freemaker jar files too.
public class sample1 {
public static void main(String[] args) throws IOException {
ExtentHtmlReporter htmlReporter = new
ExtentHtmlReporter("extent.html");
ExtentReports extent = new ExtentReports();
extent.attachReporter(htmlReporter);
ExtentTest test = extent.createTest("MyFirstTest", "Sample description");
test.log(Status.INFO, "This step shows usage of log(status, details)");
test.info("This step shows usage of info(details)");
MediaEntityBuilder
.createScreenCaptureFromPath("screenshot.png")
.build());
test.addScreenCaptureFromPath("screenshot.png");
extent.flush();
}
}
Error details:
Exception in thread "main" java.lang.NoSuchFieldError: VERSION_2_3_23
at com.aventstack.extentreports.reporter.ExtentHtmlReporter.start(ExtentHtmlReporter.java:93)
at com.aventstack.extentreports.Report.attach(Report.java:55)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
at com.aventstack.extentreports.ExtentReports.attachReporter(ExtentReports.java:68)
at com.br.mainsript.sample1.main(sample1.java:23)

You need to download the current version 3 of the community edition. The version you have does not support the reporter attachments. Below is the maven depenency:
<!-- pom.xml -->
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.5</version>
</dependency>

Thank you. Just i upgraded my eclipse version from Juno to latest oxygen and found that issue is rrsolved. Issue due to java complier version. When I upgraded to jre8 it is working fine.

Related

Play mp3 with JavaFX 11 on Raspberry Pi 3

I´d like to get Java 11 and JavaFX 11 running on a Raspberry Pi 3.
I followed the instructions given by Gluon here: http://docs.gluonhq.com/embedded/
(only differences: I´m running a full Stretch image, not Lite and meanwhile BellSoft released Liberica JDK version 11.0.1 also for ARM, so I used that.)
My application is super simple: a label and a button, when the button is pressed then an mp3 shall be played:
public class HelloFX extends Application
{
#Override
public void start(Stage stage) {
String version = System.getProperty("java.version");
String fxVersion = System.getProperty("javafx.runtime.version");
Label l = new Label ("Java version: " + version + "\nJavaFX version: " + fxVersion);
Button b = new Button("play");
Scene scene = new Scene(new VBox(l, b), 350, 200);
b.setOnAction(
new EventHandler<ActionEvent>() {
#Override
public void handle(ActionEvent event) {
PlayMp3();
}
});
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
Media media;
void PlayMp3()
{
String resource = "/resources/sound.mp3";
media = new Media(getClass().getResource(resource).toURI().toURL().toString());
MediaPlayer mp = new MediaPlayer(media);
mp.play();
}
On Windows / Eclipse this runs and plays the mp3. On the Raspberry Pi I can execute the application with this command:
sudo /opt/jdk-11.0.1/bin/java --module-path=/opt/armv6hf-sdk/lib/ --add-modules javafx.graphics,javafx.media -cp /home/pi/Java/HelloFX/ -Dprism.verbose=true -Dembedded=monocle -Dglass.platform=Monocle javafx11.HelloFX
The graphics is visible on the display but when I press the button then I get the following exception:
Exception in thread "JavaFX Application Thread" java.lang.UnsatisfiedLinkError: no jfxmedia in java.library.path: [/usr/java/packages/lib, /lib, /usr/lib]
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2660)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:829)
at java.base/java.lang.System.loadLibrary(System.java:1867)
at javafx.graphics/com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:150)
at javafx.graphics/com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:62)
at javafx.media/com.sun.media.jfxmediaimpl.NativeMediaManager.lambda$new$0(NativeMediaManager.java:136)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.media/com.sun.media.jfxmediaimpl.NativeMediaManager.<init>(NativeMediaManager.java:107)
at javafx.media/com.sun.media.jfxmediaimpl.NativeMediaManager$NativeMediaManagerInitializer.<clinit>(NativeMediaManager.java:78)
at javafx.media/com.sun.media.jfxmediaimpl.NativeMediaManager.getDefaultInstance(NativeMediaManager.java:90)
at javafx.media/com.sun.media.jfxmedia.MediaManager.canPlayProtocol(MediaManager.java:78)
at javafx.media/com.sun.media.jfxmedia.locator.Locator.<init>(Locator.java:239)
at javafx.media/javafx.scene.media.Media.<init>(Media.java:393)
at javafx11.HelloFX.PlayMp3(HelloFX.java:62)
I found some posts saying that this error message means that Java is looking for a library called "libjfxmedia.so" but I can´t find that file anywhere.
Did I make any mistake or miss anything?
Do I need to change something in the java command to execute the application? (I´m unsure about the --add-modules parameter, it runs the same without this option...)
Is it possible that JavaFX 11 still does not support Media on the Raspberry Pi (I read that v8 also provided by Gluon didn´t)? Whom to ask if it will be supported in the near future?
What José Pereda wrote is correct, javafx.media was not included and it also didn´t get included in 11 release.
But things changed meanwhile, BellSoft recently released their Liberica package (Java including JavaFX) in version 14.0.1 where playing mp3s now works:
https://bell-sw.com/pages/downloads/?version=java-14&release=14.0.1+8&os=Linux&bitness=32-bit&architecture=ARM&package=jdk-full
There are still some minor bugs (e. g. mp3 file names must not contain spaces, the length of any mp3 is always infinite) but the basics are working, it even allows to play videos, just see their blog:
https://bell-sw.com/announcements/2019/09/12/JDK-JavaFX-Video-Preview/
Please make sure to really use the 14.0.1 and not the first 14 release because several fixes esp. for the Raspberry Pi have been implemented there.
Thanks to the BellSoft team for their great work here!!

tess4j The specified module could not be found

please need your help.. I testing Tess4j but i have a problem
Development environment : eclipse, jdk 1.7
Code
System.setProperty("jna.library.path", "32".equals(System.getProperty("sun.arch.data.model")) ? "/lib/win32-x86" : "/lib/win32-x86-64");
File imgFile = new File("d:\\testImg\\testimg2-1.png");
System.setProperty("jna.debug_load", "true");
Tesseract prc = new Tesseract();
prc.setDatapath("/tessdata");
try{
String rslt = prc.doOCR(imgFile);
}catch(Exception e){
e.printStackTrace();
}
Error
Looking in classpath from sun.misc.Launcher$AppClassLoader#73d16e93 for /com/sun/jna/win32-x86-64/jnidispatch.dll
Found library resource at jar:file:/D:/WorkSpace/sample/lib/jna-4.1.0.jar!/com/sun/jna/win32-x86-64/jnidispatch.dll
Looking for library 'libtesseract304'
Adding paths from jna.library.path: /lib/win32-x86-64;C:\Users\PANDORA\AppData\Local\Temp\tess4j\win32-x86-64
Trying C:\Users\PANDORA\AppData\Local\Temp\tess4j\win32-x86-64\libtesseract304.dll
Adding system paths: []
Trying C:\Users\PANDORA\AppData\Local\Temp\tess4j\win32-x86-64\libtesseract304.dll
Looking for lib- prefix
Trying liblibtesseract304.dll
Looking in classpath from sun.misc.Launcher$AppClassLoader#73d16e93 for libtesseract304
Found library resource at jar:file:/D:/WorkSpace/sample/lib/tess4j-3.2.1.jar!/win32-x86-64/libtesseract304.dll
java.lang.UnsatisfiedLinkError: Can not find the specified moduleat com.sun.jna.Native.open(Native Method)at com.sun.jna.Native.open(Native.java:1759)at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:260)at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)at com.sun.jna.Native.register(Native.java:1396)at com.sun.jna.Native.register(Native.java:1156

Spring MVC Processing multipart form data

Using Craig Walls book "Spring in Action, 4th Edition", 7.2. Processing multipart form data
The code does not run no matter what path you try. I even tried
C:\something. Don't you have to create the directory first?
When I run the code, I get the error below:
root cause org.springframework.web.multipart.MultipartException:
Could not parse multipart servlet request; nested exception is
java.io.IOException: The temporary upload location
[C:\Users\jokra_000\sts-bundle\pivotal-tc-server-developer-3.1.1.RELEASE\base-instance\work\Catalina\localhost\spittr\tmp\spittr\uploads]
is not valid
Has anyone successfully uploaded an image file as outlined in Chapter 7? It seems there's far more to it than what's described, as the code Craig supplied does not run. Instead it crashes and will not upload a file.
Any suggestions on how to implement MultipartFile and the Path?
Craig's suggestion:
in AbstractAnnotationConfigDispatcherServletInitializer:
#Override
protected void customizeRegistration(Dynamic registration) {
registration.setMultipartConfig(
new MultipartConfigElement("/tmp/spittr/uploads", 2097152, 4194304, 0));
}
in Controller processRegistration:
MultipartFile profilePicture = spitterForm.getProfilePicture();
profilePicture.transferTo(new File("/tmp/spittr/" + spitter.getUsername() + ".jpg"));
It worked when I did the following:
I changed MultipartResolver:
#Bean
public MultipartResolver multipartResolver() throws IOException {
return new CommonsMultipartResolver();
}
and also added the dependency:
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.2</version>
</dependency>
and then imported to the file that extends WebMvcConfigurerAdapter:
import org.apache.commons.fileupload.FileItemFactory;

IE does not launch using RemoteWebDrivr TestNG

Could someone please help me resolve this issue. When I run my following code in TestNG I get the following error: "The path to the driver executable must be set by the webdriver.ie.driver system property;"
public class GoogleSearch2 {
RemoteWebDriver driver;
DesiredCapabilities cap;
#Test(dataProvider="getData")
public void searchTest2() throws MalformedURLException{
System.out.println(browser);
if(browser.equals("firefox")){
System.setProperty("webdriver.firefox.bin", "C:\\Users\\sqadri \\Mozilla
Firefox\\firefox.exe");
cap = DesiredCapabilities.firefox();
cap.setBrowserName("firefox");
cap.setPlatform(Platform.ANY);
}
else if(browser.equals("iexplore")){
File file = new File("D:/Data/IEDriver/IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
cap = DesiredCapabilities.internetExplorer();
cap.setBrowserName("iexplore");
cap.setPlatform(Platform.WINDOWS);
}
If you are using selenium grid then start your node passing the path of the IE driver. This worked for me.
java -jar selenium-server-standalone-2.37.0.jar -role node -nodeConfig configNodes.json -Dwebdriver.ie.driver=<your path>/IEDriverServer.exe

Sonar and Flex plugin - Dollars ($) are not accepted in java class names

In reference to this bug from Sonar:
http://jira.codehaus.org/browse/SONAR-1865
and this one (which cross references the one above):
http://jira.codehaus.org/browse/SONAR-1637
I am still seeing this issue.
I am using Sonar server version 2.12.
I am using Hudson, version 2.2.0.
I have installed the Sonar plugin in Hudson, version 1.7.2.
and, most importantly, I have the Flex plugin installed in the Sonar server. Flex plugin version is 0.4.
When I run mvn sonar:sonar -Pflex on a flex project, i get this error in the stack trace:
Caused by: java.lang.IllegalArgumentException: Java inner classes are not supported : EntityEnums$ReportParameterName
at org.sonar.plugins.flex.FlexFile.<init>(FlexFile.java:79)
at org.sonar.plugins.flex.FlexFile.fromIOFile(FlexFile.java:165)
at org.sonar.plugins.flex.FlexSourceImporter.createResource(FlexSourceImporter.java:37)
at org.sonar.api.batch.AbstractSourceImporter.parseDirs(AbstractSourceImporter.java:75)
at org.sonar.api.batch.AbstractSourceImporter.analyse(AbstractSourceImporter.java:69)
at org.sonar.api.batch.AbstractSourceImporter.analyse(AbstractSourceImporter.java:60)
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:64)
Here is what my class looks like, that it is complaining about:
This is an Actionscript class, file name: EntityEnums$ReportParameterName.as. It was auto-generated from java to Actionscript using GraniteDS.
package com.digabit.core.db.entity.util {
[Bindable]
public class EntityEnums$ReportParameterName {
public static const tnid:String = "tnid";
public static const uname:String = "uname";
public static const lc:String = "lc";
public static const tnkey:String = "tnkey";
public static const oid:String = "oid";
public function EntityEnums$ReportParameterName()
{
super();
}
}
}
So, according the bug reports, this has been fixed in an earlier version of Sonar that I have; but I'm still seeing it in version 2.12. And why would the error show "java inner classes..." when this is a flex/actionscript class? Is anyone still seeing this bug behavior?
Issue has been created on Sonar Flex Plugin side ( http://jira.codehaus.org/browse/SONARPLUGINS-1623 ) and most probably would be fixed in next release.

Resources