Grails/Spring Web Flow Plugin: Session must not be null error - spring

I'm trying to run a flow (Grails 2.3.11, Spring Web Flow 2.0.8.1, JDK 1.7.0_21, OS X 10.9.4).
The first time I fire up the application (by typing "grails run-app" on the command line), I can get to the first page of the flow, and the flow seems to work normally.
However, the next time I try to execute the flow, I get the error below (from the console). This happens even when I delete my cookies and restart the application. If I leave it for a few days and come back to it, it seems to work again (the first time only).
I found a thread from six years ago, but I am not calling flow.clear() like the original poster was. My flow code is below.
Does anyone have any insights on this?
Error:
[ERROR] 27 Jul 2014 21:54:14,086 org.springframework.webflow.engine.impl.FlowExecutionImpl FlowExecutionListener threw exception
java.lang.NullPointerException
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:191)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
[ERROR] 27 Jul 2014 21:54:14,096 org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver IllegalArgumentException occurred when processing request: [GET] /inscriba/author/createAuthor - parameters:
execution: e1s2
Session must not be null. Stacktrace follows:
org.springframework.webflow.execution.FlowExecutionException: Exception thrown in state 'headshot' of flow 'author/createAuthor'
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:191)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.IllegalArgumentException: Session must not be null
... 5 more
Code:
def createAuthorFlow = {
log.debug("createAuthorFlow: I am here: ")
create {
log.debug("create: I am here")
on("next") {
log.debug("create.next: I am here")
flow.author = new Author(params)
!flow.author.validate() ? error() : success()
flow.author.save()
}.to "headshot"
}
headshot {
on("next") {
log.debug("headshot.next: I am here")
}.to "summary"
}
summary()
}

I believe the problem is that you have to use Serializable objects in order to put them into the flow scope. My guess is that the Author object doesn't implement Serializable.
The Grails web-flow documentation mentions this, but just says that an "exception" will be thrown. It took me quite a while to figure out what was going on - hope this helps.

Related

ParDo did not have a ParDoPayload

I've written a Beam pipeline in Go that runs successfully on my local machine, but when I add --runner=dataflow to run it on Google Cloud Dataflow I get a vague error when it's setting up that a ParDo is missing a ParDoPayload. The stacktrace is entirely Java, so I'm not sure how to translate this back into my Go code to figure out what I'm missing.
I've gone through and used beam.RegisterFunction() for all of my functions that emit and also used beam.RegisterType() for the top-level struct I'm passing around.
Any ideas how this error connects to the code I've written / how I can debug?
java.lang.RuntimeException: ParDo did not have a ParDoPayload
at org.apache.beam.runners.dataflow.worker.graph.RegisterNodeFunction.apply(RegisterNodeFunction.java:327)
at org.apache.beam.runners.dataflow.worker.graph.RegisterNodeFunction.apply(RegisterNodeFunction.java:97)
at java.util.function.Function.lambda$andThen$1(Function.java:88)
at org.apache.beam.runners.dataflow.worker.graph.CreateRegisterFnOperationFunction.apply(CreateRegisterFnOperationFunction.java:207)
at org.apache.beam.runners.dataflow.worker.graph.CreateRegisterFnOperationFunction.apply(CreateRegisterFnOperationFunction.java:74)
at java.util.function.Function.lambda$andThen$1(Function.java:88)
at java.util.function.Function.lambda$andThen$1(Function.java:88)
at org.apache.beam.runners.dataflow.worker.BatchDataflowWorker.doWork(BatchDataflowWorker.java:346)
at org.apache.beam.runners.dataflow.worker.BatchDataflowWorker.getAndPerformWork(BatchDataflowWorker.java:305)
at org.apache.beam.runners.dataflow.worker.DataflowRunnerHarness.start(DataflowRunnerHarness.java:195)
at org.apache.beam.runners.dataflow.worker.DataflowRunnerHarness.main(DataflowRunnerHarness.java:123)
Caused by: org.apache.beam.vendor.grpc.v1p21p0.com.google.protobuf.InvalidProtocolBufferException: Protocol message had invalid UTF-8.
at org.apache.beam.vendor.grpc.v1p21p0.com.google.protobuf.InvalidProtocolBufferException.invalidUtf8(InvalidProtocolBufferException.java:141)
at org.apache.beam.vendor.grpc.v1p21p0.com.google.protobuf.Utf8$DecodeUtil.handleTwoBytes(Utf8.java:1909)
at org.apache.beam.vendor.grpc.v1p21p0.com.google.protobuf.Utf8$DecodeUtil.access$700(Utf8.java:1883)
at org.apache.beam.vendor.grpc.v1p21p0.com.google.protobuf.Utf8$UnsafeProcessor.decodeUtf8(Utf8.java:1411)
at org.apache.beam.vendor.grpc.v1p21p0.com.google.protobuf.Utf8.decodeUtf8(Utf8.java:340)
at org.apache.beam.vendor.grpc.v1p21p0.com.google.protobuf.CodedInputStream$ArrayDecoder.readStringRequireUtf8(CodedInputStream.java:804)
at org.apache.beam.model.pipeline.v1.RunnerApi$FunctionSpec.<init>(RunnerApi.java:55936)
at org.apache.beam.model.pipeline.v1.RunnerApi$FunctionSpec.<init>(RunnerApi.java:55897)
at org.apache.beam.model.pipeline.v1.RunnerApi$FunctionSpec$1.parsePartialFrom(RunnerApi.java:56565)
at org.apache.beam.model.pipeline.v1.RunnerApi$FunctionSpec$1.parsePartialFrom(RunnerApi.java:56559)
at org.apache.beam.vendor.grpc.v1p21p0.com.google.protobuf.CodedInputStream$ArrayDecoder.readMessage(CodedInputStream.java:883)
at org.apache.beam.model.pipeline.v1.RunnerApi$ParDoPayload.<init>(RunnerApi.java:10363)
at org.apache.beam.model.pipeline.v1.RunnerApi$ParDoPayload.<init>(RunnerApi.java:10320)
at org.apache.beam.model.pipeline.v1.RunnerApi$ParDoPayload$1.parsePartialFrom(RunnerApi.java:12633)
at org.apache.beam.model.pipeline.v1.RunnerApi$ParDoPayload$1.parsePartialFrom(RunnerApi.java:12627)
at org.apache.beam.vendor.grpc.v1p21p0.com.google.protobuf.AbstractParser.parsePartialFrom(AbstractParser.java:100)
at org.apache.beam.vendor.grpc.v1p21p0.com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:120)
at org.apache.beam.vendor.grpc.v1p21p0.com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:125)
at org.apache.beam.vendor.grpc.v1p21p0.com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:48)
at org.apache.beam.model.pipeline.v1.RunnerApi$ParDoPayload.parseFrom(RunnerApi.java:11130)
at org.apache.beam.runners.dataflow.worker.graph.RegisterNodeFunction.apply(RegisterNodeFunction.java:325)
... 10 more

How to read tomcat error log

Here is a screenshot of my tomcat spring boot error log. How do I read this?
Specifically,
1.) where do I read there is says "63 more"?
2.) Is the top-most error the most generic, or most specific? I'm thinking most generic because it says "caused by" and then another error.
Thanks.
First, get destination of log (console, file, database, ...) by find information in:
application.properties (for example: spring.log.**** = ...)
or log4j.properties/log4j.yml/log4j.yaml (if using log4j)
or log4j2.properties/log4j2.yml/log4j2.yaml (if using log4j2)
or logback.properties/logback.yml (if using logback)
and then you can get "63 more" there
It's the most specific
most specific error <== root cause is here
^ cause by: generic error
^ cause by: generic error
...
^ cause by: most generic error
The first line contains the exact reason for the error, such as this:
java.lang.NullPointerException
abc.def.ghi.handleRequest(MyController.java:30)
...
The more you go down, the more information you get about the root cause. Usually you can find the cause at the bottom of the log message containing the stack trace. In your case, the cause for the exception is "No converter found capable of converting from type ...".

MissingMetadataException when building UWP app with .Net native

I have this UWP app that uses a project (UWP class library) which itself uses EF7 and SQLite.
I tried to build the app in the Release mode using .Net native tool chain, the build completes successfully (after a good long time, and after eating as much memory as it can), but the application crashes just after leaving the splash screen.
After following some advice on SO I tried the .Net native with Debug mode, the build finishes just like in the Release mode, but I get many errors on the output window and it is the same scenario as this one UWP - .NET Native tool chain compilation error
I followed #Matt Whilden advice, and I got rid of those errors, then tried again.
This time I got hit by this famous MissingMetadataException :
The output window shows this :
Exception thrown: 'System.AggregateException' in System.Private.Threading.dll
Exception thrown: 'System.ArgumentException' in System.Linq.Expressions.dll
Exception thrown: 'System.ArgumentException' in System.Linq.Expressions.dll
Exception thrown: 'System.ArgumentException' in System.Linq.Expressions.dll
The thread 0x2a30 has exited with code 0 (0x0).
Exception thrown: 'System.Reflection.MissingMetadataException' in System.Private.Reflection.Core.dll
Additional information: 'Microsoft.Extensions.Caching.Memory.MemoryCacheOptions' is missing
metadata. For more information, please visit
http://go.microsoft.com/fwlink/?LinkID=392859
I tried to follow my code, during execution and I found out that it is caused by the first ever call to a DbSet table from my DbContext
public long GetLastTimeStamp()
{
//-----> Here is the line causing the error
var sortedArticles = DbContext.Articles.OrderByDescending(article => article.ArticlePubDate).ToList();
if (sortedArticles != null && sortedArticles.Count != 0)
{
DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Local);
TimeSpan elapsedTime = sortedArticles.First().ArticlePubDate - epoch;
return (long)elapsedTime.TotalSeconds;
}
else
{
return 0;
}
}
This method above is called inside an Async method, just to know.
I tried, desperately, to call .ToList() by doing :
var sortedArticles = DbContext.Articles.ToList().OrderByDescending(article => article.ArticlePubDate).ToList();
But still get the same error.
This is really frustrating, I don't know how to solve this problem, not sure what and how I should change the Default.rd.xml, any one can help telling me how to achieve this build correctly ?
Please try to add type 'Microsoft.Extensions.Caching.Memory.MemoryCacheOptions' in Default.rd.xml (already present in your project).
cf. https://blogs.msdn.microsoft.com/dotnet/2014/05/21/net-native-deep-dive-help-i-hit-a-missingmetadataexception/
For example:
<?xml version="1.0" encoding="utf-8"?>
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Application>
<Type Name="Microsoft.Extensions.Caching.Memory.MemoryCacheOptions" Dynamic="Required All" />
</Application>
</Directives>

the reason of only null pointer exception

I am using spring 2.5 framework.
I am getting such error below.
Hata Nedeni :
java.lang.NullPointerException
Hata Mesajı :
java.lang.NullPointerException
Hata Detayı :
Error only contain this. It doesn't show any explanation about where exception is taken. Mostly detailed explanation was shown (especially the controller) however, today only the system gives this exception.
Thanks in advance,

how to handle nested exception in java?

I am trying to connect to mysql database. I am using try catch while establishing connection.
I want that I should be able to know what exception was caught, so that, I can show appropriate error message.
e.g if I pass incorrect hostname, i should show Wrong hostname provided.
One way to do is get class name of runtime exception class. but nested exception is being thrown like this..
There was some error while establishing connection to the
databasecom.mysql.jdbc.CommunicationsException: Communications link
failure due to underlying exception:
-- BEGIN NESTED EXCEPTION -- java.net.UnknownHostException MESSAGE:
localhsost STACKTRACE: java.net.UnknownHostException: localhsost at
java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at
java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:867) at
java.net.InetAddress.getAddressFromNameService(InetAddress.java:1246)
at java.net.InetAddress.getAllByName0(InetAddress.java:1197) at
java.net.InetAddress.getAllByName(InetAddress.java:1128) at
java.net.InetAddress.getAllByName(InetAddress.java:1064) at
com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:246)
at com.mysql.jdbc.MysqlIO.(MysqlIO.java:271) at
com.mysql.jdbc.Connection.createNewIO(Connection.java:2771) at
com.mysql.jdbc.Connection.(Connection.java:1555) at
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
at java.sql.DriverManager.getConnection(DriverManager.java:620) at
java.sql.DriverManager.getConnection(DriverManager.java:222) at
accessMySQL.accessMySQL.createConnection(accessMySQL.java:24) at
test.main(test.java:16)
-- END NESTED EXCEPTION -- Last packet sent to the server was 1 ms
ago. Problem in establishing connection.
Now I would like to know that class name UnknownHostException, so I can setup a condition like
if(e.getClass().toString() == "UnknownHostException")
System.out.println("Exception caught while connection to database. Hostname appears to be incorrect");
please help !!
P.s that typo in hostname is deliberately there to generate exception
Try this:
if (e.getCause() instanceof UnknownHostException) {
// ...
}

Resources