Microsoft Speech to Text API File Not Found : 400 Bad Request The 2019 Stack Overflow Developer Survey Results Are InJavaRegEx and complex long stringorg.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.ClassCastExceptionjava.lang.NoSuchMethodError: dispSpring MVC Attribute not recognizedwhat does org.omg.CORBA.COMM_FAILURE: Connection refused: connect vmcid: 0x0 minor code: 0 completed: No means?send email in java by outlookWeb App (Struts framework) - Java - ClassNotFoundException ErrorGetting error java.lang.NoClassDefFoundError: com/certicom/security/cert/internal/x509/Base64Oracle BPM 12c - Using external UI for Human Task Initiator sends 404-popuporacle.jbo.NoDefException: JBO-25002: Definition Model.VOAPP of type ApplicationModule is not found
"What time...?" or "At what time...?" - what is more grammatically correct?
What tool would a Roman-age civilization have to grind silver and other metals into dust?
Output the Arecibo Message
Does a dangling wire really electrocute me if I'm standing in water?
Inline version of a function returns different value than non-inline version
It's possible to achieve negative score?
How to reverse every other sublist of a list?
How to change the limits of integration
What do the Banks children have against barley water?
Is flight data recorder erased after every flight?
Which Sci-Fi work first showed weapon of galactic-scale mass destruction?
How long do I have to send payment?
Understanding the implication of what "well-defined" means for the operation in quotient group
Limit the amount of RAM Mathematica may access?
Springs with some finite mass
Why do UK politicians seemingly ignore opinion polls on Brexit?
Can distinct morphisms between curves induce the same morphism on singular cohomology?
Should I write numbers in words or as numerals when there are multiple next to each other?
Why is Grand Jury testimony secret?
What is the motivation for a law requiring 2 parties to consent for recording a conversation
Idiomatic way to prevent slicing?
Inversion Puzzle
What are the motivations for publishing new editions of an existing textbook, beyond new discoveries in a field?
Falsification in Math vs Science
Microsoft Speech to Text API File Not Found : 400 Bad Request
The 2019 Stack Overflow Developer Survey Results Are InJavaRegEx and complex long stringorg.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.ClassCastExceptionjava.lang.NoSuchMethodError: dispSpring MVC Attribute not recognizedwhat does org.omg.CORBA.COMM_FAILURE: Connection refused: connect vmcid: 0x0 minor code: 0 completed: No means?send email in java by outlookWeb App (Struts framework) - Java - ClassNotFoundException ErrorGetting error java.lang.NoClassDefFoundError: com/certicom/security/cert/internal/x509/Base64Oracle BPM 12c - Using external UI for Human Task Initiator sends 404-popuporacle.jbo.NoDefException: JBO-25002: Definition Model.VOAPP of type ApplicationModule is not found
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm working on a web service to call the microsoft speech to text api, i'm passing a wav file from microsoft, so the format should be correct. The java code works fine when it is not in web service, but when I tried to make a web service and web method, I got Java file not found exception. source code: https://github.com/Azure-Samples/SpeechToText-REST
@WebMethod
public void getSpeech3()
File file = new File("filepath", "whatstheweatherlike.wav");
file.setReadable(true);
System.out.println(file.canRead());
byte[] bytes = ReadFully(file);
InputStream inputstream = new ByteArrayInputStream(bytes);
SpeechResult response = new SpeechResult();
try
String result = getResponse(upload(inputstream, connect()));
System.out.println(result);
catch(Exception e)
e.printStackTrace();
private HttpURLConnection upload(InputStream is, HttpURLConnection connection) throws IOException
try (OutputStream output = connection.getOutputStream())
byte[] buffer = new byte[1024];
int length;
while ((length = is.read(buffer)) != -1)
output.write(buffer, 0, length);
output.flush();
return connection;
private HttpURLConnection connect() throws MalformedURLException, IOException
HttpURLConnection connection = (HttpURLConnection) buildRequestURL().openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-type", "audio/wav; codec="audio/pcm"; samplerate=16000");
connection.setRequestProperty("Accept", "application/json;text/xml");
connection.setRequestProperty("Ocp-Apim-Subscription-Key", "mykey");
connection.setChunkedStreamingMode(0); // 0 == default chunk size
connection.connect();
return connection;
private String getResponse(HttpURLConnection connection) throws IOException
SpeechResult response = new SpeechResult();
try (BufferedReader reader =
new BufferedReader(new InputStreamReader(connection.getInputStream())))
System.out.println(reader.readLine());
return reader.readLine();
error log:
java.io.FileNotFoundException: Response: '400: Bad Request' for url: 'https://westus.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?language=en-US&format=simple'
at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:487)
at weblogic.net.http.SOAPHttpsURLConnection.getInputStream(SOAPHttpsURLConnection.java:37)
at ph.com.aub.domain.VoiceCommandWS.getResponse(VoiceCommandWS.java:526)
at ph.com.aub.domain.VoiceCommandWS.getSpeech3(VoiceCommandWS.java:473)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:92)
at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:74)
at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:151)
at com.sun.xml.ws.server.sei.EndpointMethodHandlerImpl.invoke(EndpointMethodHandlerImpl.java:268)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:100)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:866)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:815)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:778)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:680)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:403)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:532)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:253)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:140)
at weblogic.wsee.jaxws.WLSServletAdapter.handle(WLSServletAdapter.java:171)
at weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke.run(HttpServletAdapter.java:708)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
at weblogic.wsee.util.ServerSecurityHelper.authenticatedInvoke(ServerSecurityHelper.java:103)
at weblogic.wsee.jaxws.HttpServletAdapter$3.run(HttpServletAdapter.java:311)
at weblogic.wsee.jaxws.HttpServletAdapter.post(HttpServletAdapter.java:336)
at weblogic.wsee.jaxws.JAXWSServlet.doRequest(JAXWSServlet.java:95)
at weblogic.servlet.http.AbstractAsyncServlet.service(AbstractAsyncServlet.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
java web-services filenotfoundexception bad-request
add a comment |
I'm working on a web service to call the microsoft speech to text api, i'm passing a wav file from microsoft, so the format should be correct. The java code works fine when it is not in web service, but when I tried to make a web service and web method, I got Java file not found exception. source code: https://github.com/Azure-Samples/SpeechToText-REST
@WebMethod
public void getSpeech3()
File file = new File("filepath", "whatstheweatherlike.wav");
file.setReadable(true);
System.out.println(file.canRead());
byte[] bytes = ReadFully(file);
InputStream inputstream = new ByteArrayInputStream(bytes);
SpeechResult response = new SpeechResult();
try
String result = getResponse(upload(inputstream, connect()));
System.out.println(result);
catch(Exception e)
e.printStackTrace();
private HttpURLConnection upload(InputStream is, HttpURLConnection connection) throws IOException
try (OutputStream output = connection.getOutputStream())
byte[] buffer = new byte[1024];
int length;
while ((length = is.read(buffer)) != -1)
output.write(buffer, 0, length);
output.flush();
return connection;
private HttpURLConnection connect() throws MalformedURLException, IOException
HttpURLConnection connection = (HttpURLConnection) buildRequestURL().openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-type", "audio/wav; codec="audio/pcm"; samplerate=16000");
connection.setRequestProperty("Accept", "application/json;text/xml");
connection.setRequestProperty("Ocp-Apim-Subscription-Key", "mykey");
connection.setChunkedStreamingMode(0); // 0 == default chunk size
connection.connect();
return connection;
private String getResponse(HttpURLConnection connection) throws IOException
SpeechResult response = new SpeechResult();
try (BufferedReader reader =
new BufferedReader(new InputStreamReader(connection.getInputStream())))
System.out.println(reader.readLine());
return reader.readLine();
error log:
java.io.FileNotFoundException: Response: '400: Bad Request' for url: 'https://westus.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?language=en-US&format=simple'
at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:487)
at weblogic.net.http.SOAPHttpsURLConnection.getInputStream(SOAPHttpsURLConnection.java:37)
at ph.com.aub.domain.VoiceCommandWS.getResponse(VoiceCommandWS.java:526)
at ph.com.aub.domain.VoiceCommandWS.getSpeech3(VoiceCommandWS.java:473)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:92)
at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:74)
at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:151)
at com.sun.xml.ws.server.sei.EndpointMethodHandlerImpl.invoke(EndpointMethodHandlerImpl.java:268)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:100)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:866)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:815)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:778)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:680)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:403)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:532)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:253)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:140)
at weblogic.wsee.jaxws.WLSServletAdapter.handle(WLSServletAdapter.java:171)
at weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke.run(HttpServletAdapter.java:708)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
at weblogic.wsee.util.ServerSecurityHelper.authenticatedInvoke(ServerSecurityHelper.java:103)
at weblogic.wsee.jaxws.HttpServletAdapter$3.run(HttpServletAdapter.java:311)
at weblogic.wsee.jaxws.HttpServletAdapter.post(HttpServletAdapter.java:336)
at weblogic.wsee.jaxws.JAXWSServlet.doRequest(JAXWSServlet.java:95)
at weblogic.servlet.http.AbstractAsyncServlet.service(AbstractAsyncServlet.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
java web-services filenotfoundexception bad-request
add a comment |
I'm working on a web service to call the microsoft speech to text api, i'm passing a wav file from microsoft, so the format should be correct. The java code works fine when it is not in web service, but when I tried to make a web service and web method, I got Java file not found exception. source code: https://github.com/Azure-Samples/SpeechToText-REST
@WebMethod
public void getSpeech3()
File file = new File("filepath", "whatstheweatherlike.wav");
file.setReadable(true);
System.out.println(file.canRead());
byte[] bytes = ReadFully(file);
InputStream inputstream = new ByteArrayInputStream(bytes);
SpeechResult response = new SpeechResult();
try
String result = getResponse(upload(inputstream, connect()));
System.out.println(result);
catch(Exception e)
e.printStackTrace();
private HttpURLConnection upload(InputStream is, HttpURLConnection connection) throws IOException
try (OutputStream output = connection.getOutputStream())
byte[] buffer = new byte[1024];
int length;
while ((length = is.read(buffer)) != -1)
output.write(buffer, 0, length);
output.flush();
return connection;
private HttpURLConnection connect() throws MalformedURLException, IOException
HttpURLConnection connection = (HttpURLConnection) buildRequestURL().openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-type", "audio/wav; codec="audio/pcm"; samplerate=16000");
connection.setRequestProperty("Accept", "application/json;text/xml");
connection.setRequestProperty("Ocp-Apim-Subscription-Key", "mykey");
connection.setChunkedStreamingMode(0); // 0 == default chunk size
connection.connect();
return connection;
private String getResponse(HttpURLConnection connection) throws IOException
SpeechResult response = new SpeechResult();
try (BufferedReader reader =
new BufferedReader(new InputStreamReader(connection.getInputStream())))
System.out.println(reader.readLine());
return reader.readLine();
error log:
java.io.FileNotFoundException: Response: '400: Bad Request' for url: 'https://westus.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?language=en-US&format=simple'
at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:487)
at weblogic.net.http.SOAPHttpsURLConnection.getInputStream(SOAPHttpsURLConnection.java:37)
at ph.com.aub.domain.VoiceCommandWS.getResponse(VoiceCommandWS.java:526)
at ph.com.aub.domain.VoiceCommandWS.getSpeech3(VoiceCommandWS.java:473)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:92)
at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:74)
at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:151)
at com.sun.xml.ws.server.sei.EndpointMethodHandlerImpl.invoke(EndpointMethodHandlerImpl.java:268)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:100)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:866)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:815)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:778)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:680)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:403)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:532)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:253)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:140)
at weblogic.wsee.jaxws.WLSServletAdapter.handle(WLSServletAdapter.java:171)
at weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke.run(HttpServletAdapter.java:708)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
at weblogic.wsee.util.ServerSecurityHelper.authenticatedInvoke(ServerSecurityHelper.java:103)
at weblogic.wsee.jaxws.HttpServletAdapter$3.run(HttpServletAdapter.java:311)
at weblogic.wsee.jaxws.HttpServletAdapter.post(HttpServletAdapter.java:336)
at weblogic.wsee.jaxws.JAXWSServlet.doRequest(JAXWSServlet.java:95)
at weblogic.servlet.http.AbstractAsyncServlet.service(AbstractAsyncServlet.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
java web-services filenotfoundexception bad-request
I'm working on a web service to call the microsoft speech to text api, i'm passing a wav file from microsoft, so the format should be correct. The java code works fine when it is not in web service, but when I tried to make a web service and web method, I got Java file not found exception. source code: https://github.com/Azure-Samples/SpeechToText-REST
@WebMethod
public void getSpeech3()
File file = new File("filepath", "whatstheweatherlike.wav");
file.setReadable(true);
System.out.println(file.canRead());
byte[] bytes = ReadFully(file);
InputStream inputstream = new ByteArrayInputStream(bytes);
SpeechResult response = new SpeechResult();
try
String result = getResponse(upload(inputstream, connect()));
System.out.println(result);
catch(Exception e)
e.printStackTrace();
private HttpURLConnection upload(InputStream is, HttpURLConnection connection) throws IOException
try (OutputStream output = connection.getOutputStream())
byte[] buffer = new byte[1024];
int length;
while ((length = is.read(buffer)) != -1)
output.write(buffer, 0, length);
output.flush();
return connection;
private HttpURLConnection connect() throws MalformedURLException, IOException
HttpURLConnection connection = (HttpURLConnection) buildRequestURL().openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-type", "audio/wav; codec="audio/pcm"; samplerate=16000");
connection.setRequestProperty("Accept", "application/json;text/xml");
connection.setRequestProperty("Ocp-Apim-Subscription-Key", "mykey");
connection.setChunkedStreamingMode(0); // 0 == default chunk size
connection.connect();
return connection;
private String getResponse(HttpURLConnection connection) throws IOException
SpeechResult response = new SpeechResult();
try (BufferedReader reader =
new BufferedReader(new InputStreamReader(connection.getInputStream())))
System.out.println(reader.readLine());
return reader.readLine();
error log:
java.io.FileNotFoundException: Response: '400: Bad Request' for url: 'https://westus.stt.speech.microsoft.com/speech/recognition/interactive/cognitiveservices/v1?language=en-US&format=simple'
at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:487)
at weblogic.net.http.SOAPHttpsURLConnection.getInputStream(SOAPHttpsURLConnection.java:37)
at ph.com.aub.domain.VoiceCommandWS.getResponse(VoiceCommandWS.java:526)
at ph.com.aub.domain.VoiceCommandWS.getSpeech3(VoiceCommandWS.java:473)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:92)
at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:74)
at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:151)
at com.sun.xml.ws.server.sei.EndpointMethodHandlerImpl.invoke(EndpointMethodHandlerImpl.java:268)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:100)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:866)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:815)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:778)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:680)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:403)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:532)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:253)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:140)
at weblogic.wsee.jaxws.WLSServletAdapter.handle(WLSServletAdapter.java:171)
at weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke.run(HttpServletAdapter.java:708)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
at weblogic.wsee.util.ServerSecurityHelper.authenticatedInvoke(ServerSecurityHelper.java:103)
at weblogic.wsee.jaxws.HttpServletAdapter$3.run(HttpServletAdapter.java:311)
at weblogic.wsee.jaxws.HttpServletAdapter.post(HttpServletAdapter.java:336)
at weblogic.wsee.jaxws.JAXWSServlet.doRequest(JAXWSServlet.java:95)
at weblogic.servlet.http.AbstractAsyncServlet.service(AbstractAsyncServlet.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
java web-services filenotfoundexception bad-request
java web-services filenotfoundexception bad-request
asked Mar 22 at 2:52
Wilson ChuaWilson Chua
135
135
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55292219%2fmicrosoft-speech-to-text-api-file-not-found-400-bad-request%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55292219%2fmicrosoft-speech-to-text-api-file-not-found-400-bad-request%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown