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

Tests not passing after #210 #213

Closed
krzysztofxkwiecien opened this issue Sep 22, 2022 · 9 comments
Closed

Tests not passing after #210 #213

krzysztofxkwiecien opened this issue Sep 22, 2022 · 9 comments

Comments

@krzysztofxkwiecien
Copy link

Hi, after #210 all of the tests in ocpp-v1_6-test/src/test/groovy/eu/chargetime/ocpp/test/profiles/core/soap are failing for me. They were passing before this PR. All other tests are passing.

It seems that there is a problem with parsing the Confirmation after the new changes.

Here's a log from SOAPAuthorizeSpec test, they are all very similar:

21:04:12.318 [Test worker] DEBUG eu.chargetime.ocpp.Queue - Queue size: 1, store time: 21.80 ?s
21:04:12.513 [pool-41-thread-1] DEBUG eu.chargetime.ocpp.Server - Session created: 4a1c9ac1-4102-4307-b087-ee9333d633ea
21:04:12.537 [pool-41-thread-1] WARN eu.chargetime.ocpp.SOAPCommunicator - packPayload() failed
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
	at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
	at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:445)
	at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277)
	at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:124)
	at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1123)
	at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:147)
	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 javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:247)
	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234)
	at javax.xml.bind.ContextFinder.find(ContextFinder.java:462)
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
	at eu.chargetime.ocpp.SOAPCommunicator.packPayload(SOAPCommunicator.java:81)
	at eu.chargetime.ocpp.Communicator.sendCallResult(Communicator.java:206)
	at eu.chargetime.ocpp.ConfirmationHandler.accept(ConfirmationHandler.java:60)
	at eu.chargetime.ocpp.ConfirmationHandler.accept(ConfirmationHandler.java:32)
	at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774)
	at java.util.concurrent.CompletableFuture.uniWhenCompleteStage(CompletableFuture.java:792)
	at java.util.concurrent.CompletableFuture.whenComplete(CompletableFuture.java:2153)
	at eu.chargetime.ocpp.Session$CommunicatorEventHandler.onCall(Session.java:203)
	at eu.chargetime.ocpp.Communicator$EventHandler.receivedMessage(Communicator.java:301)
	at eu.chargetime.ocpp.WebServiceReceiver.forwardMessage(WebServiceReceiver.java:84)
	at eu.chargetime.ocpp.SOAPSyncHelper.relay(SOAPSyncHelper.java:69)
	at eu.chargetime.ocpp.WebServiceListener$WSHttpEventHandler.incomingRequest(WebServiceListener.java:148)
	at eu.chargetime.ocpp.WSHttpHandler.handle(WSHttpHandler.java:55)
	at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
	at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
	at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)
	at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:705)
	at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
	at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:677)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:750)
21:04:12.541 [pool-41-thread-1] WARN eu.chargetime.ocpp.SOAPCommunicator - createMessage() failed
java.lang.NullPointerException: null
	at eu.chargetime.ocpp.SOAPCommunicator.setNamespace(SOAPCommunicator.java:94)
	at eu.chargetime.ocpp.SOAPCommunicator.createMessage(SOAPCommunicator.java:177)
	at eu.chargetime.ocpp.SOAPCommunicator.makeCallResult(SOAPCommunicator.java:123)
	at eu.chargetime.ocpp.Communicator.sendCallResult(Communicator.java:206)
	at eu.chargetime.ocpp.ConfirmationHandler.accept(ConfirmationHandler.java:60)
	at eu.chargetime.ocpp.ConfirmationHandler.accept(ConfirmationHandler.java:32)
	at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774)
	at java.util.concurrent.CompletableFuture.uniWhenCompleteStage(CompletableFuture.java:792)
	at java.util.concurrent.CompletableFuture.whenComplete(CompletableFuture.java:2153)
	at eu.chargetime.ocpp.Session$CommunicatorEventHandler.onCall(Session.java:203)
	at eu.chargetime.ocpp.Communicator$EventHandler.receivedMessage(Communicator.java:301)
	at eu.chargetime.ocpp.WebServiceReceiver.forwardMessage(WebServiceReceiver.java:84)
	at eu.chargetime.ocpp.SOAPSyncHelper.relay(SOAPSyncHelper.java:69)
	at eu.chargetime.ocpp.WebServiceListener$WSHttpEventHandler.incomingRequest(WebServiceListener.java:148)
	at eu.chargetime.ocpp.WSHttpHandler.handle(WSHttpHandler.java:55)
	at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
	at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
	at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)
	at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:705)
	at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
	at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:677)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:750)
wrz 22, 2022 9:04:12 PM com.sun.xml.internal.messaging.saaj.soap.impl.BodyImpl extractContentAsDocument
SEVERE: SAAJ0250: Cannot extract Document from body
21:04:12.559 [Thread-186] WARN eu.chargetime.ocpp.SOAPCommunicator - parseMessage() failed
javax.xml.soap.SOAPException: Cannot extract Document from body
	at com.sun.xml.internal.messaging.saaj.soap.impl.BodyImpl.extractContentAsDocument(BodyImpl.java:296)
	at eu.chargetime.ocpp.SOAPCommunicator$SOAPParser.parseMessage(SOAPCommunicator.java:292)
	at eu.chargetime.ocpp.SOAPCommunicator.parse(SOAPCommunicator.java:253)
	at eu.chargetime.ocpp.Communicator$EventHandler.receivedMessage(Communicator.java:283)
	at eu.chargetime.ocpp.WebServiceTransmitter$1.run(WebServiceTransmitter.java:90)
	at java.lang.Thread.run(Thread.java:750)
21:04:12.559 [Thread-186] DEBUG eu.chargetime.ocpp.Queue - Queue size: 0, store time: 6.900 ?s
21:04:12.560 [Thread-186] WARN eu.chargetime.ocpp.Session - Unable to process action
java.lang.NullPointerException: null
	at eu.chargetime.ocpp.SOAPCommunicator.setNamespace(SOAPCommunicator.java:94)
	at eu.chargetime.ocpp.SOAPCommunicator.unpackPayload(SOAPCommunicator.java:67)
	at eu.chargetime.ocpp.Session$CommunicatorEventHandler.onCallResult(Session.java:168)
	at eu.chargetime.ocpp.Communicator$EventHandler.receivedMessage(Communicator.java:293)
	at eu.chargetime.ocpp.WebServiceTransmitter$1.run(WebServiceTransmitter.java:90)
	at java.lang.Thread.run(Thread.java:750)
21:04:12.560 [Thread-186] ERROR eu.chargetime.ocpp.Communicator - An error occurred. Sending this information: uniqueId 71df58de-b7a4-4eec-b355-ab3640f00767: action: AuthorizeResponse, errorCore: FormationViolation, errorDescription: Unable to process action
21:04:12.584 [pool-41-thread-1] DEBUG eu.chargetime.ocpp.Server - Promise not found for error Unable to process action

Condition not satisfied after 1,00 seconds and 11 attempts
Condition not satisfied after 1,00 seconds and 11 attempts
	at spock.util.concurrent.PollingConditions.within(PollingConditions.java:164)
	at spock.util.concurrent.PollingConditions.eventually(PollingConditions.java:134)
	at eu.chargetime.ocpp.test.profiles.core.soap.SOAPAuthorizeSpec.Charge point sends Authorize request and receives a response(SOAPAuthorizeSpec.groovy:20)
Caused by: Condition not satisfied:

chargePoint.hasReceivedAuthorizeConfirmation("Accepted")
|           |
|           false
eu.chargetime.ocpp.test.FakeChargePoint@f75077a

	at eu.chargetime.ocpp.test.profiles.core.soap.SOAPAuthorizeSpec.Charge point sends Authorize request and receives a response_closure2(SOAPAuthorizeSpec.groovy:21)
	at eu.chargetime.ocpp.test.profiles.core.soap.SOAPAuthorizeSpec.Charge point sends Authorize request and receives a response_closure2(SOAPAuthorizeSpec.groovy)
	at groovy.lang.Closure.call(Closure.java:414)
	at spock.util.concurrent.PollingConditions.within(PollingConditions.java:158)
	... 2 more

@emilm Did you also encounter this issue?

@emilm
Copy link
Contributor

emilm commented Sep 22, 2022

@Arflayd I guess Confirmation needs @XmlRootElement annotation.

Also I first had to add jakarta.xml.bind to even get this far:

javax.xml.bind.JAXBException

  • with linked exception:
    [java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory]

https://mkyong.com/java/java-lang-classnotfoundexception-com-sun-xml-bind-v2-contextfactory/ am I missing something there?

@krzysztofxkwiecien
Copy link
Author

@emilm That is also a problem when using higher versions of Java, but when sticking to Java 8 it doesn't occur and no extra dependencies are needed. I have tried Xml related annotation on the Confirmation class, but the problem still occurs.

Also - in my app which uses this library and Spring, there also seems to be a problem with serialization of the Confirmations when attempting to save them in a database, so it's a bigger problem than just with the tests :/

@emilm
Copy link
Contributor

emilm commented Sep 22, 2022

@Arflayd I use Java 11 and I have no idea how to correctly reproduce . Do I have to get java 8 as well?

@krzysztofxkwiecien
Copy link
Author

For Java 11 I added compile group: 'com.sun.xml.messaging.saaj', name: 'saaj-impl', version: '1.4.0' as a dependency for ocpp-v1_6 and get the same stack trace as posted above

@emilm
Copy link
Contributor

emilm commented Sep 22, 2022

Hm I have no idea where to add that into the maven project. I use Maven.

I added

        <dependency>
            <groupId>com.sun.xml.messaging.saaj</groupId>
            <artifactId>saaj-impl</artifactId>
            <version>1.4.0</version>
        </dependency>

But same error. I use intellij too

@emilm
Copy link
Contributor

emilm commented Sep 22, 2022

I reproduced the problem and fixed it by adding @XmlTransient. @XmlRootElement is not necessary:

public abstract class Confirmation implements Validatable {
    private transient ConfirmationCompletedHandler completedHandler;

    @XmlTransient
    public ConfirmationCompletedHandler getCompletedHandler() {
        return completedHandler;
    }
    public void setCompletedHandler(ConfirmationCompletedHandler completedHandler) {
        this.completedHandler = completedHandler;
    }
}

@krzysztofxkwiecien
Copy link
Author

Great, it does work. I never worked with this serialization and only tried this annotation on the field, not the getter. Thank you for getting to the bottom of it!

@emilm
Copy link
Contributor

emilm commented Sep 22, 2022

Cool!
@TVolden not sure how to add this fix, another PR ?

@TVolden
Copy link
Member

TVolden commented Sep 23, 2022

@emilm yeah that would work.

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

No branches or pull requests

3 participants