I sure hope you can help, I am getting towards the end of my rope. I posted this question yesterday but was quickly down-voted because I referred to what I was doing as Distance Matrix API and it was immediately assumed I had simply enabled the wrong API in google. I have now enabled many more APIs than I would ever need and am still getting the same IllegalAccessError:
May 06, 2015 12:48:16 PM com.google.maps.GeoApiContext setQueryRateLimit
INFO: Configuring rate limit at QPS: 10, minimum delay 50ms between requests
Exception in thread "AWT-EventQueue-0" java.lang.IllegalAccessError: tried to access class com.squareup.okhttp.Dispatcher from class com.google.maps.GeoApiContext
at com.google.maps.GeoApiContext.setQueryRateLimit(GeoApiContext.java:224)
at com.google.maps.GeoApiContext.setQueryRateLimit(GeoApiContext.java:210)
at com.google.maps.GeoApiContext.<init>(GeoApiContext.java:56)
at budgetrouting.MapPane.<init>(MapPane.java:27)
at budgetrouting.BudgetRouting$1.run(BudgetRouting.java:19)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Process exited with exit code 0.
My code:
GeoApiContext context = new GeoApiContext();
context.setApiKey(APIKey);
GeocodingResult[] results;
try {
results = GeocodingApi.geocode(context, "1600 Amphitheatre Parkway Mountain View, CA 94043").await();
System.out.println(results[0].formattedAddress);
} catch (Exception e) {
e.printStackTrace();
}
I have read every scrap of information on this error and how it relates to google api, but so far I don't have any definitive answers. I think that the fact that it is an error and not an exception means that it may not have anything to do with my access rights, especially since the error occurs the line before I set my API key. Since the definition of IllegalAccessError states "this error can only occur at run time if the definition of a class has incompatibly changed," I will include my dependencies:
google-maps-services-0.1.1.jar
okhttp-1.2.1-jar-with-dependencies.jar
I have checked okhttp for integrity and the class mentioned in the error does exist. I am using Oracle JDeveloper 12c. No Maven-type helper was used.
Just for completeness sake, these are the APIs I have enabled:
BigQuery API
Debuglet Controller API
Directions API
Distance Matrix API
Elevation API
Geocoding API
Google Cloud Logging API
Google Cloud SQL
Google Cloud Storage
Google Cloud Storage JSON API
Google Maps Embed API
Google Maps Engine API
Time Zone API
Any ideas? Thanks!
The reason I was getting the above error was that google-maps-services-0.1.1.jar requires okhttp 2.0.0, not okhttp-1.2.1-jar-with-dependencies.jar, along with a few other things. This was a result of not using a Maven-like application.
I work with these libraries:
google-maps-services-0.1.1.jar -
okhttp-2.0.0.jar -
okio-1.11.0.jar -
Example code:
public String obtenerLatitudLongitud (String direccion) throws Exception{
try {
GeoApiContext context = new GeoApiContext().setApiKey(this.propiedades.get(ConstantesApi.KEY_MAPS_GOOGLE));
context.setQueryRateLimit(50);
GeocodingResult[] results = GeocodingApi.geocode(context,direccion).await();
latLong = results[0].geometry.location.toString();
logger.debug("Latitud, longitud : " + latLong);
} catch (Exception e) {
logger.error("Error Normalizando la direccion : " + direccion + " " + e.getMessage());
}
return latLong;
}
Related
I am attempting to retrieve a secret from aws secrets manager. My application can retrieve 3 / 4 secrets. When attempting to retrieve the 2nd secret, i get an interrupt exception. The code below is what i am using. I am unsure where to look or why this is happening. It consistently happens when attempting to retrieve the 2nd secret. I have verified that it exists in aws and that it contains the value i expect.
I am using the reativerse [https://github.com/reactiverse/aws-sdk] library in tandem with vert.x + aws sdk 2. Any help or pointers on where to look would be greatly appreciated. The exception i see and the code i have are written below.
java.util.concurrent.ExecutionException: software.amazon.awssdk.core.exception.SdkClientException
at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:159)
at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:100)
at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:157)
at io.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: software.amazon.awssdk.core.exception.SdkClientException
at software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:98)
at software.amazon.awssdk.core.internal.http.AmazonAsyncHttpClient$RequestExecutionBuilderImpl.execute(AmazonAsyncHttpClient.java:189)
at software.amazon.awssdk.core.internal.handler.BaseAsyncClientHandler.invoke(BaseAsyncClientHandler.java:271)
at software.amazon.awssdk.core.internal.handler.BaseAsyncClientHandler.doExecute(BaseAsyncClientHandler.java:213)
at software.amazon.awssdk.core.internal.handler.BaseAsyncClientHandler.lambda$execute$1(BaseAsyncClientHandler.java:91)
at software.amazon.awssdk.core.internal.handler.BaseAsyncClientHandler.measureApiCallSuccess(BaseAsyncClientHandler.java:277)
at software.amazon.awssdk.core.internal.handler.BaseAsyncClientHandler.execute(BaseAsyncClientHandler.java:74)
at software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler.execute(AwsAsyncClientHandler.java:52)
at software.amazon.awssdk.services.secretsmanager.DefaultSecretsManagerAsyncClient.getSecretValue(DefaultSecretsManagerAsyncClient.java:1142)
... 8 more
Caused by: software.amazon.awssdk.core.exception.SdkInterruptedException
at software.amazon.awssdk.core.internal.http.InterruptMonitor.checkInterrupted(InterruptMonitor.java:40)
at software.amazon.awssdk.core.internal.http.pipeline.stages.ApplyTransactionIdStage.execute(ApplyTransactionIdStage.java:43)
at software.amazon.awssdk.core.internal.http.pipeline.stages.ApplyTransactionIdStage.execute(ApplyTransactionIdStage.java:29)
at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
at software.amazon.awssdk.core.internal.http.AmazonAsyncHttpClient$RequestExecutionBuilderImpl.execute(AmazonAsyncHttpClient.java:185)
... 16 more
private final SecretsManagerAsyncClient client = VertxSdkClient.withVertx(SecretsManagerAsyncClient.builder(), ctx).build();
public <T> Promise<T> getSecret(String secretName) {
Promise<T> completableFuture = Promise.promise();
Context ctx = Vertx.vertx().getOrCreateContext();
ctx.owner().executeBlocking(blockingFuture -> {
try {
GetSecretValueRequest valueRequest = GetSecretValueRequest.builder().secretId(secretName).build();
CompletableFuture<GetSecretValueResponse> valueResponse = this.client.getSecretValue(valueRequest);
GetSecretValueResponse getResponse = valueResponse.get();
String response = getResponse.secretString();
completableFuture.complete((T) Json.decodeValue(response, new <T>Object().getClass()));
blockingFuture.complete();
} catch (Exception e) {
// log exception.
}
});
...
}
See SdkInterruptedException ...it has one method getResponse():
try {
// provoke the exception in here
} catch (SdkInterruptedException e) {
System.err.println(e.getResponse());
}
This should (hopefully) at least tell why the request had been interrupted.
// log exception. is not the correct approach to handle any Exception.
The SdkClientException might be more relevant than the SdkInterruptedException:
try { ...
} catch (SdkClientException e) {
// log that exception, instead of ignoring it.
System.err.println(e.getMessage());
}
This is how an Authorization Header (AWS Signature Version 4) should basically look alike.
It may well be, that HMAC-SHA256 headers are being enforced (they're different on each single request). I could even provide a known to be working example... which would show how to configure the SecretsManagerClient. I'd suspect the root cause related to that client's configuration.
When I read "when attempting to retrieve the 2nd secret", this with high probability means that you need a refresh the HMAC-SHA256 signature before the second request will be performed. Destroying the client and constructing it again may be one sloppy workaround. When seeing duplicate values for AWS4-HMAC-SHA256 header on both requests, this definitely is the cause.
I am trying to create an application which uses jira for authentication. I am using Jira Rest api for the same. In the documentation it says to use the same public key and consumer-key to create application link as given in the doc. This works fine, and I am able to create access-token. But in java code as mentioned in this, I am not sure what should be given for private_key. I tried two methods-
Generated a random private key using rsa and provided it in place of private_key which didn't work. It gave exception telling length too long. I tried for 2048, 1024, 512, 256 and 128 bits. Everything gave same error.
Application link:
Consumer-key: hardcoded-consumer
Consumer Name: hardcoded-consumer
Public Key:
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxZDzGUGk6rElyPm0iOua0lWg84nOlhQN1gmTFTIu5WFyQFHZF6OA4HX7xATttQZ6N21yKMakuNdRvEudyN/coUqe89r3Ae+rkEIn4tCxGpJWX205xVF3Cgsn8ICj6dLUFQPiWXouoZ7HG0sPKhCLXXOvUXmekivtyx4bxVFD9Zy4SQ7IHTx0V0pZYGc6r1gF0LqRmGVQDaQSbivigH4mlVwoAO9Tfccf+V00hYuSvntU+B1ZygMw2rAFLezJmnftTxPuehqWu9xS5NVsPsWgBL7LOi3oY8lhzOYjbMKDWM6zUtpOmWJA52cVJW6zwxCxE28/592IARxlJcq14tjwYwIDAQAB
Generated private and public key pair and provided the same in application link and in code respectively. But in this case, I am unable to create access token. It is giving -
Application link:
Consumer-key: hardcoded-consumer
Consumer Name: hardcoded-consumer
Public Key:
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC0YjCwIfYoprq/FQO6lb3asXrx LlJFuCvtinTF5p0GxvQGu5O3gYytUvtC2JlYzypSRjVxwxrsuRcP3e641SdASwfr mzyvIgP08N4S0IFzEURkV1wp/IpH7kH41EtbmUmrXSwfNZsnQRE5SYSOhh+LcK2w yQkdgcMv11l4KoBkcwIDAQAB
Exception in thread "main" java.lang.reflect.InvocationTargetException
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.simontuffs.onejar.Boot.run(Boot.java:340)
at com.simontuffs.onejar.Boot.main(Boot.java:166)
Caused by: java.lang.RuntimeException: Failed to obtain request token
at com.atlassian.oauth.client.example.AtlassianOAuthClient.getRequestToken(AtlassianOAuthClient.java:66)
at com.atlassian.oauth.client.example.JIRAOAuthClient.main(JIRAOAuthClient.java:52)
... 6 more
Caused by: net.oauth.OAuthProblemException: signature_invalid
at net.oauth.client.OAuthResponseMessage.toOAuthProblemException(OAuthResponseMessage.java:83)
at net.oauth.client.OAuthClient.invoke(OAuthClient.java:306)
at net.oauth.client.OAuthClient.invoke(OAuthClient.java:260)
at net.oauth.client.OAuthClient.getRequestTokenResponse(OAuthClient.java:190)
at com.atlassian.oauth.client.example.AtlassianOAuthClient.getRequestToken(AtlassianOAuthClient.java:57)
Can someone explain me what should be done? Am I missing something here?
And also what is the difference between shared key, consumer key and public key?
Thanks in advance
The exception occurs due to ending with "/" in JIRA base URL (caused by net.oauth.OAuthProblemException: signature_invalid).
The correct request is:
java -jar rest-oauth-client-1.0.one-jar.jar requestToken https://jira_base_server_url http://your_redirctedUrl
I somehow fixed the issue by using the public that is provided in the documentation and the private key as given in the example
But still, I was unable to create an application link with private and public key generated by me.
I've just upgraded to El Capitan and I'm running into problems starting a custom JavaFX2 application running under JDK1.7.0u79 (the latest available from Oracle).
When starting the app, I'm getting this Exception:
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at javafx.scene.control.Control.loadClass(Control.java:115)
at javafx.scene.control.Control.loadSkinClass(Control.java:1021)
at javafx.scene.control.Control.access$500(Control.java:70)
at javafx.scene.control.Control$12.invalidated(Control.java:972)
at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:127)
at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:161)
at com.sun.javafx.css.StyleableStringProperty.set(StyleableStringProperty.java:71)
at javafx.scene.control.Control$12.set(Control.java:964)
at com.sun.javafx.css.StyleableStringProperty.applyStyle(StyleableStringProperty.java:59)
at com.sun.javafx.css.StyleableStringProperty.applyStyle(StyleableStringProperty.java:31)
at com.sun.javafx.css.StyleableProperty.set(StyleableProperty.java:70)
at com.sun.javafx.css.StyleHelper.transitionToState(StyleHelper.java:900)
at javafx.scene.Node.impl_processCSS(Node.java:7418)
at javafx.scene.Parent.impl_processCSS(Parent.java:1146)
at javafx.scene.control.Control.impl_processCSS(Control.java:1154)
at javafx.scene.Parent.impl_processCSS(Parent.java:1153)
at javafx.scene.Parent.impl_processCSS(Parent.java:1153)
at javafx.scene.Node.processCSS(Node.java:7386)
at javafx.scene.Scene.doCSSPass(Scene.java:454)
at javafx.scene.Scene.preferredSize(Scene.java:1468)
at javafx.scene.Scene.impl_preferredSize(Scene.java:1535)
at javafx.stage.Window$9.invalidated(Window.java:717)
at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:127)
at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:161)
at javafx.stage.Window.setShowing(Window.java:781)
at javafx.stage.Window.show(Window.java:796)
at javafx.stage.Stage.show(Stage.java:233)
at au.com.religaresecurities.trademax.client.Start.start(Start.java:131)
at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:219)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:182)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:179)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
Caused by: java.lang.NullPointerException
at com.sun.t2k.MacFontFinder.initPSFontNameToPathMap(MacFontFinder.java:339)
at com.sun.t2k.MacFontFinder.getFontNamesOfFontFamily(MacFontFinder.java:390)
at com.sun.t2k.T2KFontFactory.getFontResource(T2KFontFactory.java:233)
at com.sun.t2k.LogicalFont.getSlot0Resource(LogicalFont.java:184)
at com.sun.t2k.LogicalFont.getSlotResource(LogicalFont.java:228)
at com.sun.t2k.CompositeStrike.getStrikeSlot(CompositeStrike.java:86)
at com.sun.t2k.CompositeStrike.getMetrics(CompositeStrike.java:132)
at com.sun.javafx.font.PrismFontUtils.getFontMetrics(PrismFontUtils.java:31)
at com.sun.javafx.font.PrismFontLoader.getFontMetrics(PrismFontLoader.java:466)
at javafx.scene.text.Text.<init>(Text.java:153)
at javafx.scene.text.Text.<init>(Text.java:162)
at com.sun.javafx.scene.control.skin.ProgressIndicatorSkin.<clinit>(ProgressIndicatorSkin.java:78)
... 37 more
I can't just migrate the app to Java 8, so any help is much appreciated.
Update
I've been able to get the app running again by adding this to the start of my main method. Any better solutions out there?
try {
Class<?> macFontFinderClass = Class.forName("com.sun.t2k.MacFontFinder");
Field psNameToPathMap = macFontFinderClass.getDeclaredField("psNameToPathMap");
psNameToPathMap.setAccessible(true);
psNameToPathMap.set(null, new HashMap<String, String>());
} catch (Exception e) {
// ignore
}
After more than a week with that in an extensive enterprise application, I haven't noticed any problems in the UI.
For the lack of a better solution, I'm accepting my update above as answer. Maybe it helps someone...
I've been able to get the app running again by adding this to the start of my main method.
try {
Class<?> macFontFinderClass = Class.forName("com.sun.t2k.MacFontFinder");
Field psNameToPathMap = macFontFinderClass.getDeclaredField("psNameToPathMap");
psNameToPathMap.setAccessible(true);
psNameToPathMap.set(null, new HashMap<String, String>());
} catch (Exception e) {
// ignore
}
This isn't a direct answer, however I thought it important to pass on that this bug has been identified and fixed in an upcoming Java release. See https://bugs.openjdk.java.net/browse/JDK-8143907
I had the same problem. I changed the Text to a Label. I'm not sure it's possible in your case.
when I send invalid xml to my web services on websphere server, I get java heap space:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Header/>
<soap:Body>
<MyElementsomething</MyElement>
</soap:Body>
</soap:Envelope>
with the element
<MyElement>something</MyElement>
Everything works ok
Exception:
java.lang.OutOfMemoryError: Java heap space
at com.ibm.ws.webservices.utils.BAIS.create(BAIS.java:74) ~[com.ibm.ws.runtime.jar:?]
at com.ibm.ws.webservices.utils.WebServicesInputSource.getBAISContent(WebServicesInputSource.java:744) ~[com.ibm.ws.runtime.jar:?]
at com.ibm.ws.webservices.utils.WebServicesInputSource.getByteArrayContent(WebServicesInputSource.java:710) ~[com.ibm.ws.runtime.jar:?]
at com.ibm.ws.webservices.utils.WebServicesInputSource.getStringContent(WebServicesInputSource.java:674) ~[com.ibm.ws.runtime.jar:?]
at com.ibm.ws.webservices.utils.WebServicesInputSource.getString(WebServicesInputSource.java:425) ~[com.ibm.ws.runtime.jar:?]
at com.ibm.ws.webservices.engine.SOAPPart._getSOAPEnvelope(SOAPPart.java:1090) ~[com.ibm.ws.runtime.jar:?]
at com.ibm.ws.webservices.engine.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:628) ~[com.ibm.ws.runtime.jar:?]
at com.ibm.ws.webservices.engine.SOAPPart.getEnvelope(SOAPPart.java:656) ~[com.ibm.ws.runtime.jar:?]
at org.springframework.ws.soap.saaj.support.SaajUtils.getSaajVersion(SaajUtils.java:155) ~[spring-ws-core-2.1.0.RELEASE.jar:?]
at org.springframework.ws.soap.saaj.SaajSoapMessage.getSaajVersion(SaajSoapMessage.java:257) ~[spring-ws-core-2.1.0.RELEASE.jar:?]
at org.springframework.ws.soap.saaj.SaajSoapMessage.getImplementation(SaajSoapMessage.java:342) ~[spring-ws-core-2.1.0.RELEASE.jar:?]
at org.springframework.ws.soap.saaj.SaajSoapMessage.<init>(SaajSoapMessage.java:117) ~[spring-ws-core-2.1.0.RELEASE.jar:?]
at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:186) ~[spring-ws-core-2.1.0.RELEASE.jar:?]
at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:60) ~[spring-ws-core-2.1.0.RELEASE.jar:?]
at org.springframework.ws.transport.AbstractWebServiceConnection.receive(AbstractWebServiceConnection.java:90) ~[spring-ws-core-2.1.0.RELEASE.jar:?]
at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:86) ~[spring-ws-core-2.1.0.RELEASE.jar:?]
EDIT:
nobody know ?
PS: spring validation doesnt help because it is after websphere stuff. When I send invalid xml agains xsd (for example string instead of number) then it works:
2015-02-18 10:12:46.128 [WebContainer : 8] WARN cz.isvs.ais3.ws.interceptor.ServerPayloadValidatingInterceptor - XML validation error on request: cvc-datatype-valid.1.2.1: 'b' is not a valid value for 'integer'.
2015-02-18 10:12:46.128 [WebContainer : 8] WARN cz.isvs.ais3.ws.interceptor.ServerPayloadValidatingInterceptor - XML validation error on request: cvc-type.3.1.3: The value 'b' of element 'urn1:Ais' is not valid.
because of WebServiceMessageReceiverObjectSupport.class:
86 WebServiceMessage request = connection.receive(getMessageFactory()); // here occurs out of memory
87 MessageContext messageContext = new DefaultMessageContext(request, getMessageFactory());
88 receiver.receive(messageContext); // and in this method are interceptor which validate request
PS2:
when I tried to increase heap space from 2gb to 4gb there is another exception on the same spot:
java.lang.IndexOutOfBoundsException
at java.io.PushbackInputStream.read(PushbackInputStream.java:181) ~[?:1.7.0]
at java.io.FilterInputStream.read(FilterInputStream.java:133) ~[?:1.7.0]
at com.ibm.ws.webservices.utils.WebServicesInputSource$FilterIS.read(WebServicesInputSource.java:805) ~[com.ibm.ws.runtime.jar:?]
at com.ibm.ws.webservices.utils.BAIS.create(BAIS.java:77) ~[com.ibm.ws.runtime.jar:?]
PS3:
this is correct behavior with sun java:
Caused by: org.xml.sax.SAXParseException: The element type "urn:ZadostInfo" must be terminated by the matching end-tag "</urn:ZadostInfo>".
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) ~[?:?]
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) ~[?:?]
at org.xml.sax.helpers.XMLFilterImpl.parse(Unknown Source) ~[?:?]
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(Unknown Source) ~[?:?]
at com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer.transform(EfficientStreamingTransformer.java:411) ~[?:1.7.0]
at com.sun.xml.internal.messaging.saaj.soap.EnvelopeFactory.createEnvelope(EnvelopeFactory.java:115) ~[?:1.7.0]
at com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelopeFromSource(SOAPPart1_1Impl.java:80) ~[?:1.7.0]
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:140) ~[?:1.7.0]
at org.springframework.ws.soap.saaj.support.SaajUtils.getSaajVersion(SaajUtils.java:155) ~[spring-ws-core-2.1.2.RELEASE.jar:?]
This looks like a Websphere bug. Using Spring-WS I got the some error:
java.lang.OutOfMemoryError: Java heap space
at com.ibm.ws.webservices.utils.BAIS.create(BAIS.java:74)
I managed to solved this way: put in /AppServer/lib/ext this library: axis2-saaj-1.6.2.jar (worked for me on Websphere v8.5 and Spring-WS v2.2.0, but you may have to change the version).
Explanation
When Spring-WS asks for a javax.xml.soap.MessageFactory implementation it gets a com.ibm.ws.webservices.engine.soap.MessageFactoryImpl instance (from Websphere runtime) instead of a com.sun.xml.internal.messaging.saaj.soap.MessageFactoryImpl instance (from JVM), which leads to the mentioned error.
The axis2-saaj library also contains a javax.xml.soap.MessageFactory implementation: org.apache.axis2.saaj.MessageFactoryImpl. This one is now used when axis2-saaj is in lib/ext folder and error is gone (I also configured PARENT LAST classpath, don't know if it matters here)
Update
#hudi your solution is correct, I just tested it. Sadly, cannot upvote you.
the best way is to use spring payloadinterceptor to validate the incoming xml against the XML schema before it allows to be parsed further...
Sample code:
bean id="validatingInterceptor"
class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
<property name="schema" value="/WEB-INF/conf/MyElement.xsd"/>
<property name="validateRequest" value="true"/>
<property name="validateResponse" value="false"/>
For more details, read the spring documentation
You just found a bug. Please report the bug. Since this is related to the parsing. You can do two things.
First of all you can take a memory dump. Just dump the memory (or profile this using visualvm and make a memory profile run). This way you understand what polutes the memory.
Second you can correct the issue you found. I do it all the way with third party code. So just before they step into parsing the snippet you do another step evaluating if the xml is correct without checking for shema. Just use a parser run with no shema involved.
In order to provide a modified implementation use the sourcecode or if not available, decompile it or rename the class and provide a new implementation class extending from this. If it is a private method or feature you need to access just modify the byte code.
In order to inject your version just add your class to your class path (or the classpath of the websphere) and put it in front of it. Usually your code is preceeded for any library code. This way you can override every implementation detail of any library as long as you control the classpath (usually by setting it within the java.exe.
So just add an additional test for correctness before this bugged version is issued. And report the bug and also blog about it.
If you have questions or need a tool advice just ask. I do this on a regular basis. With open source and non-open source software. Also great for other things like extending features.
I tried to fix this by my own. I examined how spring-ws validate xml and tried to do it before websphere. Here is code. I test it and it is working for me.
public class SaajSoapMessageValidatorFactory extends SaajSoapMessageFactory {
#Override
public SaajSoapMessage createWebServiceMessage(InputStream inputStream) throws IOException {
InputStream original;
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
IOUtils.copy(inputStream, baos);
original = new ByteArrayInputStream(baos.toByteArray());
InputStream validate = new ByteArrayInputStream(baos.toByteArray());
try {
ValidatorResources validator = new XmlValidatorResources(validate);
validator.process();
} catch (Exception parseException) {
throw new InvalidXmlException("Could not parse XML", parseException);
} finally {
IOUtils.closeQuietly(validate);
}
} finally {
IOUtils.closeQuietly(inputStream);
}
return super.createWebServiceMessage(original);
}
}
public class XmlValidatorResources extends ValidatorResources {
private static final long serialVersionUID = 1L;
public XmlValidatorResources(InputStream in) throws IOException, SAXException {
Digester digester = new Digester();
digester.push(this);
digester.parse(in);
}
}
and in spring context I add:
<bean id="messageFactory" class="cz.isvs.ais3.ws.validator.SaajSoapMessageValidatorFactory" />
After Martin advise I try to decompile ibm code and I think problem is in this procedure:
private SOAPEnvelope _getSOAPEnvelope()
throws WebServicesFault
{
SOAPEnvelope soapEnvelope = _getCachedSOAPEnvelope();
if(soapEnvelope == null)
if(currentForm == 4)
{
soapEnvelope = (SOAPEnvelope)getCurrentMessage();
} else
{
if(log.isDebugEnabled())
log.debug("Converting " + formNames[currentForm] + " to " + formNames[4]);
MessageContext mc = getMessage().getMessageContext();
if(mc != null)
if(mc.isHighFidelity())
{
if(originalContent == null)
originalContent = _getCachedWebServicesInputSource();
} else
{
originalContent = null;
}
WebServicesInputSource wsis = _getWebServicesInputSource();
if(log.isDebugEnabled())
log.debug("Parsing inputSource " + wsis.dumpStats());
String encoding = getMessage().getCharacterEncoding();
if(encoding != null)
wsis.setEncoding(encoding);
DeserializationContext dser = new DeserializationContextImpl(wsis, getMessage().getMessageContext(), getMessage().getMessageType(), getMessage().getSOAPConstants(), Utils._isSAAJ13Enabled());
try
{
dser.parse();
}
catch(SAXException e)
{
FFDCFilter.processException(e, "com.ibm.ws.webservices.engine.SOAPPart.getSOAPEnvelope", "964", this);
Exception real = e.getException();
wsis.reset();
if(real instanceof WebServicesFault)
throw (WebServicesFault)real;
if(originalContent == null)
originalContent = wsis;
problem section:
if(originalContent == null)// I am not sure but I think this will never happend. So to fix it I will delete this condition and throw this
exception not the second one where it want to display message
throw WebServicesFault.makeFault("To see the message containing the parsing error in the log, either enable web service engine tracing or set MessageContext.setHighFidelity(true).", ((Throwable) (real == null ? ((Throwable) (e)) : ((Throwable) (real)))));
else
throw WebServicesFault.makeFault("Message being parsed: " + originalContent.getString(), ((Throwable) (real == null ? ((Throwable) (e)) : ((Throwable) (real)))));
}
if(log.isDebugEnabled())
log.debug("Done parsing inputSource.");
originalParseLength = wsis.getContentLength();
soapEnvelope = dser.getEnvelope();
setCurrentForm(soapEnvelope, 4);
String messageProtocol = getMessage().getSOAPConstants().getSOAPProtocol();
String factoryProtocol = soapEnvelope.getSOAPFactory().getSOAPConstants().getSOAPProtocol();
String envelopeProtocol = "SOAP 1.1 Protocol";
String ns = soapEnvelope.getNamespaceURI();
if(soapEnvelope.getNamespaceURI().equals("http://schemas.xmlsoap.org/soap/envelope/"))
envelopeProtocol = "SOAP 1.2 Protocol";
if(messageProtocol.equals("Dynamic Protocol"))
{
getMessage().setSOAPConstants(soapEnvelope.getSOAPFactory().getSOAPConstants());
messageProtocol = getMessage().getSOAPConstants().getSOAPProtocol();
}
if(envelopeProtocol.equals(factoryProtocol) && factoryProtocol.equals(messageProtocol))
{
if(log.isDebugEnabled())
log.debug("The protocol is: " + envelopeProtocol);
} else
if(log.isDebugEnabled())
{
log.debug("The SOAPEnvelope protocol is: " + envelopeProtocol);
log.debug("The SOAPFactory protocol is: " + factoryProtocol);
log.debug("The SOAPMessage protocol is: " + messageProtocol);
}
}
return soapEnvelope;
}
Refer to IBM developer wroks post
https://developer.ibm.com/answers/questions/291621/how-to-resolve-outofmemoryerror-when-sending-inval.html
Customer using WebSphere 8.5.5.x with SDK 1.7 and using SAAJ with Spring frmae work may encounter OutOfMemoryError when sending SOAP request that that has invalid request. This is due to bug fix went into SDK 1.7 and later versions.
IBM has fixed this issue through IBM SDK APAR IV73614.
Details of the bug fix went in later releases
JAVA.IO.PACKEDINPUTSTREAM.AVAILABLE() RETURNS INTEGER.MAX_VALUE I.E., 2147483647 ON EMPTY STREAM IN JAVA 7
From javacore stack indicate following 4XESTACKTRACE at com/ibm/ws/webservices/utils/BAIS.create(BAIS.java:74) 4XESTACKTRACE at com/ibm/ws/webservices/utils/WebServicesInputSource.getBAISContent(WebServicesInputSource.java:744) 4XESTACKTRACE at com/ibm/ws/webservices/utils/WebServicesInputSource.getByteArrayContent(WebServicesInputSource.java:710) 4XESTACKTRACE at com/ibm/ws/webservices/utils/WebServicesInputSource.getStringContent(WebServicesInputSource.java:674) 4XESTACKTRACE at com/ibm/ws/webservices/utils/WebServicesInputSource.getString(WebServicesInputSource.java:425(Compiled Code)) 4XESTACKTRACE at com/ibm/ws/webservices/engine/SOAPPart._getSOAPEnvelope(SOAPPart.java:1090(Compiled Code)) 4XESTACKTRACE at com/ibm/ws/webservices/engine/SOAPPart.getAsSOAPEnvelope(SOAPPart.java:628(Compiled Code)) 4XESTACKTRACE at com/ibm/ws/webservices/engine/SOAPPart.getEnvelope(SOAPPart.java:656(Compiled Code)) 4XESTACKTRACE at org/springframework/ws/soap/saaj/support/SaajUtils.getSaajVersion(SaajUtils.java:155) 4XESTACKTRACE at org/springframework/ws/soap/saaj/SaajSoapMessage.getSaajVersion(SaajSoapMessage.java:257) 4XESTACKTRACE at org/springframework/ws/soap/saaj/SaajSoapMessage.getImplementation(SaajSoapMessage.java:342(Compiled Code))
I have a GWT app that uses Google Maps and Im trying to create a method that uses Googele's geocoder class to get the LatLng ofan address.
This is my code:
Geocoder gc = new Geocoder();
gc.getLatLng(this.testAddress, new LatLngCallback()
{
public void onFailure()
{
System.out.println("ERROR: Could not obtain the Coordinates for address" + testAddress);
}
public void onSuccess(LatLng point)
{
System.out.println("For Address= "+testAddress +"are Latitude: "+point.getLatitude() + "Longitude: "+ point.getLongitude());
}
});
It compiles fine but at runtime throws this exception:
06:25:09.359 [ERROR] [foodvendor] Unable to load module entry point class cs310.client.Main (see associated exception for details)
com.google.gwt.core.client.JavaScriptException: (TypeError): undefined is not a function
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:248)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.maps.client.impl.__GeocoderImplImpl.construct(__GeocoderImplImpl.java)
at com.google.gwt.maps.client.geocode.Geocoder.<init>(Geocoder.java:41)
at cs310.client.AshTestClass.<init>(AshTestClass.java:25)
at cs310.client.Main.onModuleLoad(Main.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:680)
Im not sure what this exception means, could someoone help me understand? Thanks
You may need to first load the Maps JS API using Maps.loadMapsApi(...) before the geocoding methods will be accessible to your GWT code.
If you're using an emulator geocoder doesn't work. Its a pretty big bug they havent fixed but the solution is to test on a real device. Hopefully it should work then.