Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java class is not being called in executable jar #1660

Closed
rohit1212s opened this issue Jun 22, 2021 · 3 comments
Closed

Java class is not being called in executable jar #1660

rohit1212s opened this issue Jun 22, 2021 · 3 comments
Labels

Comments

@rohit1212s
Copy link

When we use executable jar and run the feature file then the java class which we called from different package inside the feature file is not getting executed and giving below error:-

failed features:

js failed:
01: javaclass.getPayload(map)
<<<<
org.graalvm.polyglot.PolyglotException

  • sun.misc.Unsafe.ensureClassInitialized(Native Method)
  • java.lang.invoke.DirectMethodHandle$EnsureInitialized.computeValue(DirectMethodHandle.java:330)
  • java.lang.invoke.DirectMethodHandle$EnsureInitialized.computeValue(DirectMethodHandle.java:327)
  • java.lang.ClassValue.getFromHashMap(ClassValue.java:227)
  • java.lang.ClassValue.getFromBackup(ClassValue.java:209)
  • java.lang.ClassValue.get(ClassValue.java:115)
  • java.lang.invoke.DirectMethodHandle.checkInitialized(DirectMethodHandle.java:351)

I have attached a sample jar file which demonstrates this behaviour directly (i.e. by showing the content is empty when run from a jar)

Instructions.

unzip the karate-sample.zip jar file and open up the project in your ide.

Run the file TestApplication as a java app in the IDE.

The output of the test will indicate content:

19:27:29.878 [main] INFO com.intuit.karate - [print] Request body---> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
SOAP-ENV:Header/
SOAP-ENV:Body
<ns3:GetShareholderMeetingRequest xmlns="http://syntel.nl/Epos/Common/ServiceContext" xmlns:ns2="http://www.able.eu/Epos/Common/SharedObjects" xmlns:ns3="http://syntel.nl/Epos/Custody/GetShareholderMeeting/Request">

2b14dd4f29ea8ba6
2
nl

RK88YA


1234


abcdef


ns3:shareholderMeeting
ns3:id12345</ns3:id>
</ns3:shareholderMeeting>
</ns3:GetShareholderMeetingRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

19:27:30.617 [main] INFO com.intuit.karate - [print]
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
SOAP-ENV:Header/
SOAP-ENV:Body
SOAP-ENV:Fault
SOAP-ENV:Server
An unexpected error occurred

<ns2:faultResponseMessage xmlns:ns2="http://syntel.nl/Epos/Common">
ns2:responses
ns2:response
ns2:code5054</ns2:code>
ns2:domainGetInternalIdByExternalId</ns2:domain>
ns2:parameter
ns2:descriptionEPOS Version</ns2:description>
ns2:id-1</ns2:id>
ns2:value08.03.04.00</ns2:value>
</ns2:parameter>
ns2:parameter
ns2:descriptionEPOS RequestID</ns2:description>
ns2:id-2</ns2:id>
ns2:valuedc2d8bf0-5bde-446a-9b40-d67a934c334b</ns2:value>
</ns2:parameter>
ns2:parameter
ns2:descriptionConversationID</ns2:description>
ns2:id-3</ns2:id>
ns2:value2b14dd4f29ea8ba6</ns2:value>
</ns2:parameter>
ns2:serviceAuthorisationLogDA</ns2:service>
ns2:severityERROR</ns2:severity>
ns2:shortDescriptionInvalid ExternalIdentificationId: abcdef for type: EXTERNAL_1</ns2:shortDescription>
</ns2:response>
</ns2:responses>
ns2:version8030400</ns2:version>
</ns2:faultResponseMessage>

</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


feature: src/main/resources/features/Test2.feature
scenarios: 1 | passed: 1 | failed: 0 | time: 3,3617

19:27:31.622 [main] INFO com.intuit.karate.Suite - <> feature 1 of 1 (0 remaining) src/main/resources/features/Test2.feature
Karate version: 1.0.1

elapsed: 8,86 | threads: 1 | thread time: 3,36
features: 1 | skipped: 0 | efficiency: 0,38
scenarios: 1 | passed: 1 | failed: 0
[======================================================]

Now run the maven clean install
karate-sample.zip
build, this will build out an executable jar called: sample-test-jar-with-dependencies.jar

Run this as a java jar file: java -Depos.environment=testbe2 -Depos.version=320 -Dkarate.env=develop
ment -jar target\sample-test-jar-with-dependencies.jar

The output of the test now is :

failed features:

js failed:
01: javaclass.getPayload(map)
<<<<
org.graalvm.polyglot.PolyglotException

  • sun.misc.Unsafe.ensureClassInitialized(Native Method)
  • java.lang.invoke.DirectMethodHandle$EnsureInitialized.computeValue(DirectMethodHandle.java:330)
  • java.lang.invoke.DirectMethodHandle$EnsureInitialized.computeValue(DirectMethodHandle.java:327)
  • java.lang.ClassValue.getFromHashMap(ClassValue.java:227)
  • java.lang.ClassValue.getFromBackup(ClassValue.java:209)
  • java.lang.ClassValue.get(ClassValue.java:115)
  • java.lang.invoke.DirectMethodHandle.checkInitialized(DirectMethodHandle.java:351)

karate-sample.zip

@ptrthomas
Copy link
Member

tagging this as help wanted - not considered a priority. we've had enough headaches with JAR files, refer #520

@ptrthomas
Copy link
Member

@rohit1212s are you sure you uploaded the right zip file ? your instructions don't match what I am seeing. please try again

@rohit1212s
Copy link
Author

rohit1212s commented Jun 24, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants