Application.yaml:
request.delay.ms: 200
A spring component:
#Value("${request.delay.ms}")
private long requestDelay;
Now, as strange as it sounds, it looks like spring can successfully resolve the property if it's value is a string, i.e. if I change 200 to 200a. It does throw an error
Caused by: java.lang.NumberFormatException: For input string: "200a" but that's expected.
If I change the value back to 200 I get
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'long'; nested exception is java.lang.NumberFormatException: For input string: "${request.delay.ms}"
And if I run tomcat in debug mode and step through the spring code, it works fine with no errors.
String #Value(s) are resolved fine in the same component all the time.
If you are using YAML instead of .properties you should write it in the following manner:
request:
delay:
ms: 200
which will be transformed to properties:
request.delay.ms=200 but you are mixing both files
See more here
Related
basically cross from https://discuss.dev.twitch.tv/t/using-google-oauth-client-java-fails-to-execute-token-request/24191
the exception I get is this:
Exception in thread "main" java.lang.IllegalArgumentException: key scope
at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:902)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:362)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:337)
at com.google.api.client.json.JsonObjectParser.parseAndClose(JsonObjectParser.java:79)
at com.google.api.client.json.JsonObjectParser.parseAndClose(JsonObjectParser.java:73)
at com.google.api.client.http.HttpResponse.parseAs(HttpResponse.java:444)
at com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:346)
at de.cryptearth.oauth.Main.main(Main.java:67)
Caused by: java.lang.IllegalArgumentException: key scope, field private java.lang.String com.google.api.client.auth.oauth2.TokenResponse.scope
at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:902)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:453)
at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:789)
... 7 more
Caused by: java.lang.IllegalArgumentException: expected collection or array type but got class java.lang.String
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:164)
at com.google.api.client.util.Preconditions.checkArgument(Preconditions.java:67)
at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:726)
... 9 more
Any Idea what might could be the issue here?
Well, tried several OAuth libs linked on oaut.net but got none to work, so I ended up in doing it low-level with URLConnection and RegEx parsing.
Side-note: I also tried the other libs on YouTube, but only could Googles own implementation to work on it.
~closed
I am working a SPring-MVC project where I am trying to set the cookie. I am using Tomcat7, And I have already set the cookie processor in context.xml to Rfc6265CookieProcessor. Currently I am getting the following error.
Error log :
HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalArgumentException: An invalid character [44] was present in the Cookie value
type Exception report
message Request processing failed; nested exception is java.lang.IllegalArgumentException: An invalid character [44] was present in the Cookie value
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: An invalid character [44] was present in the Cookie value
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:979)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:869)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
Cookie values to be set : The spaces are not actually there, got them while reformatting in IntelliJ to get them in one paragraph :
s.d774b7c6eabba92fce3edbed8a9b003b,
s.bdf5f951e4ab858aac87fb182439f57f,
s.e77bd0cd86b4af86c4a550ec11d71d4c,
s.431334e112350c9d545f7a44cbcc530d,
s.6e6057e5483b538cf9c6daf2934fd825,
s.ea2438094c8631123fab3bf3efb7ec17,
s.e17b1d9dd1b9702ca8c9e95d30906dd5, s .3f 3 c8f3fc19597025ef87dafc0fb277a, s .5531
b742d6e12717f4071818b5861bd2, s .420811998d
b14d0a68dd9e3d3c04849f, s.d8ed1aa3b0a2e513d449a96182898160, s.f3b5784d6e777032c6b7576e7d824af0, s .69
bc19557e43fcfa83816f427b60a09d, s .5677087e bc57003436c55f49fceff5cb, s .5f
a872b3e84fd69618534940034e1adb, s.fe4184c9b925ddf04def79c0c55392ca, s .74e4438d 05f 267
c48297a0c66a7dbeba, s .95e c071a356cf1998d809267006725db, s .9 b72a01cfda4509833c1f0c7bf2afdac, s .5240f
10897d 2f 96f 49d 0328 a2521519c, s .518 cd1d749fbba6540424874d64c5443
Character 44 (comma) is not valid in a cookie value.
See https://www.rfc-editor.org/rfc/rfc6265 for more details.
The solution for me was to change the version of Tomcat, I was working with 8.5 and I was getting the character error in cookie value, I changed to Tomcat 9 and the problem continued, finally with Tomcat 7 it was solved. The most logical option is to replace the commas in the cookie values, but if you want to quickly fix the problem locally and keep working you might consider switching from Tomcat.
use com.squareup.wire wire-runtime.
code:
Wire wire = new Wire();
VerifyTicketRsp ticketRsp = wire.parseFrom(moaResult.objectBytes, VerifyTicketRsp.class);
error info:
java.lang.IllegalArgumentException: No WireType for value 118
at com.squareup.wire.WireType.valueOf(WireType.java:36)
at com.squareup.wire.MessageAdapter.read(MessageAdapter.java:521)
at com.squareup.wire.Wire.parseFrom(Wire.java:144)
at com.squareup.wire.Wire.parseFrom(Wire.java:135)
Note: this code run on 99% device work fine. But sometimes get this error, the probability is 1/100000. Anyone knows ?
I had a working Apache James mail server up and running, but just converted it to use a MySQL database instead of the filesystem.
It created (some) the tables, but it won't write to them. This makes it not deliver any mail.
Since it will interact with the database and insert users, I think I have my database data-source and user configured correctly...
<data-source name="maildb" class="org.apache.james.util.dbcp.JdbcDataSource">
<driver>com.mysql.jdbc.Driver</driver>
<dburl>jdbc:mysql://127.0.0.1/james</dburl>
<user>xxxx</user>
<password>yyyy</password>
<max>20</max>
</data-source>
But when I try to send an email, I get no error from the client, but I get nothing in the database in any table.
All I get is this error on James console...
exception! javax.mail.MessagingException: Exception caught while storing mail Container: ;
nested exception is:
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '' for column 'last_updated' at row 1
Here's the full stack trace from mailet log...
10/12/14 16:23:18 INFO James.Mailet: Error while storing mail.
javax.mail.MessagingException: Exception caught while storing mail Container: ;
nested exception is:
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '' for column 'last_updated' at row 1
at org.apache.james.mailrepository.JDBCMailRepository.store(JDBCMailRepository.java:764)
at org.apache.james.transport.mailets.ToMultiRepository.storeMail(ToMultiRepository.java:230)
at org.apache.james.transport.mailets.ToMultiRepository.service(ToMultiRepository.java:154)
at org.apache.james.transport.mailets.LocalDelivery.service(LocalDelivery.java:66)
at org.apache.james.transport.LinearProcessor.service(LinearProcessor.java:424)
at org.apache.james.transport.JamesSpoolManager.process(JamesSpoolManager.java:405)
at org.apache.james.transport.JamesSpoolManager.run(JamesSpoolManager.java:309)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '' for column 'last_updated' at row 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2973)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1600)
at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1129)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:681)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:803)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:168)
at org.apache.james.mailrepository.JDBCMailRepository.store(JDBCMailRepository.java:752)
10/12/14 16:23:18 INFO James.Mailet: ToRepository: Storing mail Mail1418257398530-1 in dbfile://maildb/deadletter/error
Here is how I specified the repository...
<mailet match="All" class="ToRepository">
<repositoryPath> db://maildb/deadletter/error </repositoryPath>
</mailet>
Since it seems to be complaining about an empty last_updated datetime, I made that column null allowed, but that didn't help.
I'm not changing the java in any way, so there shouldn't be anything I messed up. I don't even know where it gets the datetime.
Can anyone see something I've missed?
Solved: I found an obscure post in the Apache bug archives that mentions adding this parm...
<dburl>jdbc:mysql://127.0.0.1/james?useServerPrepStmts=false</dburl>
...to the data-source area. Actually, the post says to add 2 parms here, but I found that it will only accept one parm.
I don't know how I was supposed to know about those parms or what they do, but this made everything magically work. Sometimes using open source software teaches you more about researching than programming.
My CF9 application running on a windows server pops mail. When I attempt to retrieve the entire body of the message, I sometimes get the following error...
Error:
An exception occurred while retrieving mail.
The cause of this exception was: java.lang.ClassCastException: javax.mail.internet.MimeMessage cannot be cast to javax.mail.internet.MimeBodyPart.
Location:
Line 335 in controllers\Submissions.cfc
Not sure if this is pertinent, but FYI every message will have an image attached and the whole process usually works fine. This problem is intermittent.
My Questions
Any idea what causes this?
Any idea how to catch and resolve this issue?
I suspect I'll need to drop down into java, but not sure where to start.
Code Fragments
<cfscript>
// setup variables array for all cfpop calls
CFPopAttributes = {
server = request.pop.server,
port = request.pop.port,
username = request.pop.username,
password = request.pop.password,
timeout = 300
};
</cfscript>
<cfpop
action="getall"
name="entireEmail"
uid="#uid#"
attachmentpath="#originalsPath#"
attributecollection="#CFPopAttributes#" // Line 335
generateuniquefilenames="true"
/>
NOTE: I added the comment "Line 335" above to communicate exactly where in the code the template is breaking. If I move the attributecollection up or down (before/after other attributes), the error always breaks at the attributecollection line.
Stack Trace
struct [Filtered - 1 of 8 keys hidden]
Detail: An exception occurred while invoking an event handler method from Application.cfc. The method name is: onRequest.
Message: Event handler exception.
RootCause:
[struct]
Detail: The cause of this exception was: java.lang.ClassCastException: javax.mail.internet.MimeMessage cannot be cast to javax.mail.internet.MimeBodyPart.
Message: An exception occurred while retrieving mail.
RootCause:
[struct]
Message: javax.mail.internet.MimeMessage cannot be cast to javax.mail.internet.MimeBodyPart
StackTrace: java.lang.ClassCastException: javax.mail.internet.MimeMessage cannot be cast to javax.mail.internet.MimeBodyPart
at coldfusion.mail.EmailTable.getAttachmentName(EmailTable.java:819)
at coldfusion.mail.EmailTable.populate(EmailTable.java:283)
at coldfusion.mail.PopImpl.getMails(PopImpl.java:241)
at coldfusion.tagext.net.PopTag$1.run(PopTag.java:433)
at java.security.AccessController.doPrivileged(Native Method)
at coldfusion.tagext.net.PopTag.doStartTag(PopTag.java:429)
at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2799)
at cfSubmissions2ecfc1952269377$funcGETEMAIL.runFunction(D:\home\wwwroot\controllers\Submissions.cfc:335)