When i try an java agent to run i get this error on java console. Target property of agent is None. Trigger is "On Event, "Action Menu Selected".I do ot know what i have to do to solve this problem. Any suggestion.
import org.openntf.domino.*;
import org.json.JSONArray;
import org.json.JSONObject;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import org.openntf.domino.ext.Session.Fixes;
import org.openntf.domino.utils.Factory;
public class JavaAgent extends AgentBase
{
public void NotesMain()
{
try
{
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
ERROR LINE:
Unexpected error while executing java agent:JavaAgent
-->java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=, offset=6
java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=, offset=6
at java.lang.ClassLoader.defineClass(ClassLoader.java:287)
at java.lang.ClassLoader.defineClass(ClassLoader.java:224)
at lotus.domino.AgentLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(ClassLoader.java:638)
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:287)
at java.lang.ClassLoader.defineClass(ClassLoader.java:224)
at lotus.domino.AgentLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(ClassLoader.java:638)
at lotus.domino.AgentLoader.runAgent(Unknown Source)
I have added this .jar file in to archive that
Related
I have this really simple java Lucene code that works in my friends PC but it makes a lot of errors for me ... we all use Lucene 5.3.1, I think that the problem is my jdk11
package project;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.IntField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
public class Act1 {
public static void main(String[] args) throws
IOException {
Document doc = new Document();
Field titre = new TextField("Titre", "mon A staticestimation technique",Field.Store.YES);
Field ref = new IntField("Year", 2001,Field.Store.YES);
Field auteurs = new TextField("Auteurs","TaewhanKim, Ki-Seok Chung, C. L. Liu",Field.Store.YES);
doc.add(titre);
doc.add(ref);
doc.add(auteurs);
Path p = Paths.get("C:\\Users\\user\\Desktop\\abc");
Directory dir = FSDirectory.open(p);
StandardAnalyzer analyzer = new StandardAnalyzer();
IndexWriterConfig config = new IndexWriterConfig(analyzer);
IndexWriter index = new IndexWriter(dir, config);
index.addDocument(doc);
index.close();
}
}
but it make those errors
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.lucene.store.MMapDirectory$1 (file:/C:/Users/user/Downloads/lucene-5.3.1/core/lucene-core-5.3.1.jar) to method java.nio.DirectByteBuffer.cleaner()
WARNING: Please consider reporting this to the maintainers of org.apache.lucene.store.MMapDirectory$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Exception in thread "main" java.io.IOException: Unable to unmap the mapped buffer: MMapIndexInput(path="C:\Users\user\Desktop\abc\_1_Lucene50_0.doc")
at org.apache.lucene.store.MMapDirectory$2.freeBuffer(MMapDirectory.java:329)
at org.apache.lucene.store.ByteBufferIndexInput.freeBuffer(ByteBufferIndexInput.java:376)
at org.apache.lucene.store.ByteBufferIndexInput.close(ByteBufferIndexInput.java:355)
at org.apache.lucene.codecs.lucene50.Lucene50CompoundFormat.write(Lucene50CompoundFormat.java:92)
at org.apache.lucene.index.IndexWriter.createCompoundFile(IndexWriter.java:4680)
at org.apache.lucene.index.DocumentsWriterPerThread.sealFlushedSegment(DocumentsWriterPerThread.java:492)
at org.apache.lucene.index.DocumentsWriterPerThread.flush(DocumentsWriterPerThread.java:459)
at org.apache.lucene.index.DocumentsWriter.doFlush(DocumentsWriter.java:503)
at org.apache.lucene.index.DocumentsWriter.flushAllThreads(DocumentsWriter.java:615)
at org.apache.lucene.index.IndexWriter.doFlush(IndexWriter.java:3121)
at org.apache.lucene.index.IndexWriter.flush(IndexWriter.java:3096)
at org.apache.lucene.index.IndexWriter.shutdown(IndexWriter.java:1078)
at org.apache.lucene.index.IndexWriter.close(IndexWriter.java:1123)
at projet.Act1.main(Act1.java:31)
Caused by: java.lang.IllegalAccessException: class org.apache.lucene.store.MMapDirectory$2$1 cannot access class jdk.internal.ref.Cleaner (in module java.base) because module java.base does not export jdk.internal.ref to unnamed module #6e8dacdf
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:361)
at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:591)
at java.base/java.lang.reflect.Method.invoke(Method.java:558)
at org.apache.lucene.store.MMapDirectory$2$1.run(MMapDirectory.java:322)
at org.apache.lucene.store.MMapDirectory$2$1.run(MMapDirectory.java:314)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.apache.lucene.store.MMapDirectory$2.freeBuffer(MMapDirectory.java:314)
... 13 more
please help me to fix this problem ...
and plz if there is anyone who is good in java and Lucene help I'm struggling I have a mini java/Lucene project and because of covid19 we didn't had any course... as you can see I can't even write a simple code
I am doing a project in IntelliJ IDEA on JavaFX application for the first time. I am unable to run my code.
When I first build->Run, I got an error saying that I require kotlin stdlib in my module,then I downloaded and added kotlin standard library into my module.
But now I am getting java.lang.NoClassDefFoundError in my code .
Sample.Main
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
#Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
primaryStage.setTitle("Hello World");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
module-info.java file
module Calculator {
requires javafx.fxml;
requires javafx.controls;
requires kotlin.stdlib;
opens Sample;
}
fxml file
<GridPane fx:controller="Sample.Controller"
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
</GridPane>
error message:
"C:\Program Files\Java\jdk-11.0.1\bin\java.exe" "-javaagent:C:\Coding_Setups\JetBrains\IntelliJ IDEA Community Edition 2019.1.2\lib\idea_rt.jar=52562:C:\Coding_Setups\JetBrains\IntelliJ IDEA Community Edition 2019.1.2\bin" -Dfile.encoding=UTF-8 -classpath "G:\JavaFXproject\Calculator\out\production\Calculator;C:\Coding_Setups\javafx lib\javafx-sdk-11.0.2\lib\javafx.swing.jar;C:\Coding_Setups\javafx lib\javafx-sdk-11.0.2\lib\javafx.web.jar;C:\Coding_Setups\javafx lib\javafx-sdk-11.0.2\lib\javafx.media.jar;C:\Coding_Setups\javafx lib\javafx-sdk-11.0.2\lib\javafx.graphics.jar;C:\Coding_Setups\javafx lib\javafx-sdk-11.0.2\lib\javafx.fxml.jar;C:\Coding_Setups\javafx lib\javafx-sdk-11.0.2\lib\javafx.controls.jar;C:\Coding_Setups\javafx lib\javafx-sdk-11.0.2\lib\javafx.base.jar;C:\Coding_Setups\javafx lib\javafx-sdk-11.0.2\lib\javafx-swt.jar" sample.Main
Error: Could not find or load main class sample.Main
Caused by: java.lang.NoClassDefFoundError: Sample/Main (wrong name: sample/Main)
I am confused why would my javafx project demand for kotlin stdlib and why I have added it to my module I am getting a new error even when I have not changed the provided code yet.
I have a cucumber project and I want to get al the tags in the project to be able to choose them as parameters.
I found this question where cucumber had an option to get the tags but I found that doesn't work anymore, then I found this other question where I found I need a custom formatter to get my tags, but it is for ruby, and I need it for Java, so then I found this article on how to create a custom formatter, but I found that this worked for the cukes version and I'm using the io one.
So I searched inside the cucumber packages and created a custom formatter from a copy of the JSONFormatter inside the package cucumber.runtime.formatter, here is my code:
import cucumber.api.TestCase;
import cucumber.api.event.*;
import cucumber.api.formatter.Formatter;
import cucumber.api.formatter.NiceAppendable;
import gherkin.deps.com.google.gson.Gson;
import gherkin.deps.com.google.gson.GsonBuilder;
import gherkin.pickles.PickleTag;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class TagsFormatter implements Formatter {
private String currentFeatureFile;
private final Gson gson = new GsonBuilder().setPrettyPrinting().create();
private final NiceAppendable out;
private List<String> tags = new ArrayList<>();
private EventHandler<TestCaseStarted> caseStartedHandler = this::handleTestCaseStarted;
private EventHandler<TestRunFinished> runFinishedHandler = event -> finishReport();
public TagsFormatter(Appendable out) {
this.out = new NiceAppendable(out);
}
#Override
public void setEventPublisher(EventPublisher publisher) {
publisher.registerHandlerFor(TestCaseStarted.class, caseStartedHandler);
publisher.registerHandlerFor(TestRunFinished.class, runFinishedHandler);
}
private void handleTestCaseStarted(TestCaseStarted event) {
if (currentFeatureFile == null || !currentFeatureFile.equals(event.testCase.getUri())) {
currentFeatureFile = event.testCase.getUri();
collectTags(event.testCase);
}
}
private void finishReport() {
out.append(gson.toJson(tags));
out.close();
}
private void collectTags(TestCase testCase) {
testCase.getTags();
tags.addAll(testCase.getTags()
.stream()
.map(PickleTag::getName)
.collect(Collectors.toList()));
}
}
I copied the libraries I need to run cucumber in a lib folder inside my project and tried running it using my formatter like this:
java -cp .\lib\cucumber-core-2.4.0.jar;.\lib\gherkin-5.0.0.jar;.\lib\cucumber-java-2.4.0.jar;.\lib\cucumber-jvm-deps-1.0.6.jar cucumber.api.cli.Main -p "com.myproject.formatters.TagsFormatter:tags.txt"
But Im getting a class not found exception:
λ java -cp .\lib\cucumber-core-2.4.0.jar;.\lib\gherkin-5.0.0.jar;.\lib\cucumber-java-2.4.0.jar;.\lib\cucumber-jvm-deps-1.0.6.jar cucumber.api.cli.Main -p "com.myproject.formatters.TagsFormatter:tags.txt"
Exception in thread "main" cucumber.runtime.CucumberException: Couldn't load plugin class: com.myproject.formatters.TagsFormatter
at cucumber.runtime.formatter.PluginFactory.loadClass(PluginFactory.java:181)
at cucumber.runtime.formatter.PluginFactory.pluginClass(PluginFactory.java:166)
at cucumber.runtime.formatter.PluginFactory.getPluginClass(PluginFactory.java:223)
at cucumber.runtime.formatter.PluginFactory.isFormatterName(PluginFactory.java:201)
at cucumber.runtime.RuntimeOptions$ParsedPluginData.addPluginName(RuntimeOptions.java:471)
at cucumber.runtime.RuntimeOptions.parse(RuntimeOptions.java:157)
at cucumber.runtime.RuntimeOptions.<init>(RuntimeOptions.java:115)
at cucumber.runtime.RuntimeOptions.<init>(RuntimeOptions.java:108)
at cucumber.runtime.RuntimeOptions.<init>(RuntimeOptions.java:100)
at cucumber.api.cli.Main.run(Main.java:31)
at cucumber.api.cli.Main.main(Main.java:18)
Caused by: java.lang.ClassNotFoundException: com.myproject.formatters.TagsFormatter
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at cucumber.runtime.formatter.PluginFactory.loadClass(PluginFactory.java:174)
... 10 more
So, how can I create this formatter in a way it is recognized? or at least get the tags list from cucumber from console?
Thanks
By just eyeballing your code, I don't think there is anything wrong with it. However your command does not appear to include a compiled version of the TagsFormatter on the class path.
If your compiled sources are in .\bin\ make sure to include that folder ie:
java -cp .\lib\cucumber-core-2.4.0.jar;.\lib\gherkin-5.0.0.jar;.\lib\cucumber-java-2.4.0.jar;.\lib\cucumber-jvm-deps-1.0.6.jar;.\bin\* cucumber.api.cli.Main -p "com.myproject.formatters.TagsFormatter:tags.txt"
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.nio.file.Files;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.parser.PdfReaderContentParser;
import com.itextpdf.text.pdf.parser.SimpleTextExtractionStrategy;
import com.itextpdf.text.pdf.parser.TextExtractionStrategy;
`
public class Test{
public static void main(String []args) throws IOException
{
String pdf= "c:\\sample.pdf";
PdfReader reader = new PdfReader(pdf);
}
}
it not working
like it should i am running windows
need help please help i tried a lot of things but still getting the same message
here is the error message
this is the output i get when i tried ur code
File Exists: true
Exception in thread "main" java.lang.NoClassDefFoundError:
org/bouncycastle/asn1/ASN1Encodable
at com.itextpdf.text.pdf.PdfEncryption.<init>(PdfEncryption.java:148)
at com.itextpdf.text.pdf.PdfReader.readDecryptedDocObj(PdfReader.java:1024)
at com.itextpdf.text.pdf.PdfReader.readDocObj(PdfReader.java:1430)
at com.itextpdf.text.pdf.PdfReader.readPdf(PdfReader.java:732)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:181)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:219)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:207)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:197)
at pdfconverter.Test.main(Test.java:37)
Caused by: java.lang.ClassNotFoundException:
org.bouncycastle.asn1.ASN1Encodable
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 9 more
The code looks good to me. Perhaps more information on the error you are having? For instance, it could be a classpath error - something like the itextpdf classes not being located...
In case it helps as a baseline - the following code works for me. I removed the extraneous includes, though they won't hurt to leave them in.
import java.io.File;
import com.itextpdf.text.pdf.PdfReader;
public class Test {
public static void main(String[] args) {
String pdf= "C:\\Java-Design-Patterns.pdf";
try {
System.out.println("File Exists: "+new File(pdf).exists());
PdfReader reader = new PdfReader(pdf);
int count = reader.getNumberOfPages();
System.out.println("PDF has "+count+" pages.");
} catch (Exception e) {
System.out.println("Failed to open PDF ["+pdf+"]: "+e);
e.printStackTrace();
}
}
}
The output is:
File Exists: true
PDF has 183 pages.
The itext jar I used is: itextpdf-5.5.12.jar (included via maven).
The pdf I used (courtesy of google: java design patterns pdf) is here: http://enos.itcollege.ee/~jpoial/java/naited/Java-Design-Patterns.pdf
I haven't read it yet, but the first page looks good ;)
That said, itextpdf is quite awesome.
java.lang.NoClassDefFoundError: org/bouncycastle/asn1/ASN1Encodable
clearly indicates the issue: Bouncy Castle is missing! (Or at least the required version is missing.)
Bouncy Castle is a library used by iText for encryption, decryption, signing, and signature verification, here their web representation.
Thus, add the Bouncy Castle libraries to your class path. Please be aware, though, that the BC version required depends on the iText version in question. The maven link you provided for your itext7 version indicates that BC 1.49 is required.
I am trying to use a third party api in the project where the way to access those apis are provide in swagger
When i generate the client using swagger and try to use in my local i am getting the error has
io.swagger.client.ApiException: java.net.SocketTimeoutException: connect timed out
at io.swagger.client.ApiClient.execute(ApiClient.java:973)
at io.swagger.client.api.PlatformApi.getAppsWithHttpInfo(PlatformApi.java:729)
at io.swagger.client.api.PlatformApi.getApps(PlatformApi.java:716)
at io.swagger.client.api.testSample.getNodesTest(testSample.java:16)
at io.swagger.client.api.testSample.main(testSample.java:29)
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:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.net.SocketTimeoutException: connect timed out
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at com.squareup.okhttp.internal.Platform.connectSocket(Platform.java:120)
at com.squareup.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:141)
at com.squareup.okhttp.internal.io.RealConnection.connect(RealConnection.java:112)
at com.squareup.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:184)
at com.squareup.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)
at com.squareup.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)
at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281)
at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224)
at com.squareup.okhttp.Call.getResponse(Call.java:286)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:243)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205)
at com.squareup.okhttp.Call.execute(Call.java:80)
at io.swagger.client.ApiClient.execute(ApiClient.java:969)
... 9 more
i am trying to use one of the method from the generated client as shown below
package io.swagger.client.api;
import com.squareup.okhttp.OkHttpClient;
import io.swagger.client.ApiClient;
import io.swagger.client.ApiException;
import io.swagger.client.Configuration;
import io.swagger.client.model.AppModel;
import io.swagger.client.model.NodeModel;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
public class testSample {
private final PlatformApi api = new PlatformApi();
public void getNodesTest() throws ApiException {
List<AppModel> response = api.getApps();
System.out.print("------------------------inside testsample------------------------");
System.out.print(response);
}
public static void main(String args[]){
testSample t1=new testSample();
System.out.print("------------------------inside main------------------------");
try{
ApiClient defaultApiClient = Configuration.getDefaultApiClient();
ApiClient apiClient = t1.api.getApiClient();
System.out.println(defaultApiClient);
System.out.println(apiClient);
t1.getNodesTest();
}
catch(Exception e){
System.out.println("inside exeption");
e.printStackTrace();
}
}
}
Please provide some suggestion how to use the generated java client from swagger in local
I hope these helps someone;
DefaultApi defaultApi = new DefaultApi();
ApiClient apiClient = new ApiClient();
apiClient.setBasePath("http://....");
apiClient.addDefaultHeader("Authorization", "bearer TOKEN");
OkHttpClient httpClient = apiClient.getHttpClient();
httpClient.setConnectTimeout(60, TimeUnit.SECONDS);
httpClient.setReadTimeout(60, TimeUnit.SECONDS);
httpClient.setWriteTimeout(60, TimeUnit.SECONDS);
defaultApi.setApiClient(apiClient);
SomeModel var1 = defaultApi.getNodesTest();
generator sample command;
> java -jar swagger-codegen-cli-2.2.2.jar generate -l java -o myModule --library okhttp-gson -i http://..../swagger
to download jar file;
http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/
for more info;
https://github.com/swagger-api/swagger-codegen
The error below suggests that the Java API client couldn't connect to the API server:
io.swagger.client.ApiException: java.net.SocketTimeoutException: connect timed out
I would suggest you to verify the Swagger/OpenAPI spec to ensure it has a proper host setting, e.g.
host: petstore.swagger.io
e.g. https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/test/resources/2_0/petstore.yaml#L12
Ref: Swagger 2.0 spec: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swagger-object