Comments (16)
I am also getting the same error. Was this issue resolved/identified?
UPDATE: It is forcing me to keep inner state machine class to be static to make it work.
from squirrel.
You get this same error if your StateMachine machine object constructor has an argument and you don't specify the argument type in StateMachineBuilderFactory.create
or don't provide the argument in newStateMachine
.
from squirrel.
which sample does not work?
from squirrel.
Please find the code below.
import org.squirrelframework.foundation.fsm.StateMachineBuilderFactory;
import org.squirrelframework.foundation.fsm.UntypedStateMachine;
import org.squirrelframework.foundation.fsm.UntypedStateMachineBuilder;
import org.squirrelframework.foundation.fsm.annotation.StateMachineParameters;
import org.squirrelframework.foundation.fsm.impl.AbstractUntypedStateMachine;
public class StandaloneStateMachineTest {
// 1. Define State Machine Event
enum FSMEvent {
ToA, ToB, ToC, ToD
}
// 2. Define State Machine Class
@StateMachineParameters(stateType=String.class, eventType=FSMEvent.class, contextType=Integer.class)
static class StateMachineSample extends AbstractUntypedStateMachine {
StateMachineSample() {
}
public void fromAToB(String from, String to, FSMEvent event, Integer context) {
System.out.println("Transition from '"+from+"' to '"+to+"' on event '"+event+
"' with context '"+context+"'.");
}
public void ontoB(String from, String to, FSMEvent event, Integer context) {
System.out.println("Entry State \'"+to+"\'.");
}
}
public static void main(String[] args) {
// 3. Build State Transitions
UntypedStateMachineBuilder builder = StateMachineBuilderFactory.create(StateMachineSample.class);
builder.externalTransition().from("A").to("B").on(FSMEvent.ToB).callMethod("fromAToB");
builder.onEntry("B").callMethod("ontoB");
// 4. Use State Machine
UntypedStateMachine fsm = builder.newStateMachine("A");
fsm.fire(FSMEvent.ToB, 10);
System.out.println("Current state is "+fsm.getCurrentState());
}
}
from squirrel.
I do not have any problem to run your sample code. Everything works fine. And I cannot see why this simple code breaks. Any error stack information?
from squirrel.
I got the exception below when I run this.
Exception in thread "main" org.squirrelframework.foundation.exception.SquirrelRuntimeException: 00010007 : couldn't construct new 'null' with args [fromAToB, org.squirrelframework.foundation.fsm.impl.ExecutionContext@305f849].
from squirrel.
org.squirrelframework.foundation.exception.SquirrelRuntimeException: 00010007 : couldn't construct new 'null' with args [fromAToB, org.squirrelframework.foundation.fsm.impl.ExecutionContext@19fe59c2].
at org.squirrelframework.foundation.util.ReflectUtils.newInstance(ReflectUtils.java:255)
at org.squirrelframework.foundation.util.ReflectUtils.newInstance(ReflectUtils.java:228)
at org.squirrelframework.foundation.component.SquirrelProvider.newInstance(SquirrelProvider.java:57)
at org.squirrelframework.foundation.component.SquirrelProvider.newInstance(SquirrelProvider.java:38)
at org.squirrelframework.foundation.fsm.impl.FSM.newMethodCallActionProxy(FSM.java:103)
at org.squirrelframework.foundation.fsm.impl.TransitionBuilderImpl.callMethod(TransitionBuilderImpl.java:54)
from squirrel.
Since the issue cannot be produced and no other user report this problem. I will close this issue for now. If more information can be provided and can prove this is a bug, please reopen the issue.
from squirrel.
I am having the exact same issue, please check this for more details: https://stackoverflow.com/questions/47674628/how-to-create-a-typed-fsm-using-squirrel-fsm-framework
from squirrel.
package org.squirrelframework.foundation.issues;
import org.squirrelframework.foundation.fsm.StateMachineBuilderFactory;
import org.squirrelframework.foundation.fsm.UntypedStateMachine;
import org.squirrelframework.foundation.fsm.UntypedStateMachineBuilder;
import org.squirrelframework.foundation.fsm.annotation.StateMachineParameters;
import org.squirrelframework.foundation.fsm.annotation.Transit;
import org.squirrelframework.foundation.fsm.annotation.Transitions;
import org.squirrelframework.foundation.fsm.impl.AbstractUntypedStateMachine;
public class IssueSample {
enum TestEvent {
toA, toB, toC, toD
}
@Transitions({
@Transit(from="A", to="B", on="toB", callMethod="fromAToB"),
@Transit(from="B", to="C", on="toC"),
@Transit(from="C", to="D", on="toD")
})
@StateMachineParameters(stateType=String.class, eventType=TestEvent.class, contextType=Integer.class)
static class UntypedStateMachineSample extends AbstractUntypedStateMachine {
// No need to specify constructor anymore since 0.2.9
// protected UntypedStateMachineSample(ImmutableUntypedState initialState,
// Map<Object, ImmutableUntypedState> states) {
// super(initialState, states);
// }
protected void fromAToB(String from, String to, TestEvent event, Integer context) {
System.out.println("fromAToB");
}
protected void transitFromDToAOntoA(String from, String to, TestEvent event, Integer context) {
// transition action still type safe ...
System.out.println("transitFromDToAOntoA");
}
}
public static void main(String[] args) {
UntypedStateMachineBuilder builder = StateMachineBuilderFactory.create(
UntypedStateMachineSample.class);
// state machine builder not type safe anymore
builder.externalTransition().from("D").to("A").on(TestEvent.toA);
UntypedStateMachine fsm = builder.newStateMachine("A");
fsm.fire(TestEvent.toB);
}
}```
the sample code works as expected
from squirrel.
yes, but I am refering to the example in the "Untyped state machine" section, which is not working for me.
Here it is :
enum TestEvent {
toA, toB, toC, toD
}
@Transitions({
@Transit(from="A", to="B", on="toB", callMethod="fromAToB"),
@Transit(from="B", to="C", on="toC"),
@Transit(from="C", to="D", on="toD")
})
@StateMachineParameters(stateType=String.class, eventType=TestEvent.class, contextType=Integer.class)
class UntypedStateMachineSample extends AbstractUntypedStateMachine {
// No need to specify constructor anymore since 0.2.9
// protected UntypedStateMachineSample(ImmutableUntypedState initialState,
// Map<Object, ImmutableUntypedState> states) {
// super(initialState, states);
// }
protected void fromAToB(String from, String to, TestEvent event, Integer context) {
// transition action still type safe ...
}
protected void transitFromDToAOntoA(String from, String to, TestEvent event, Integer context) {
// transition action still type safe ...
}
}
UntypedStateMachineBuilder builder = StateMachineBuilderFactory.create(
UntypedStateMachineSample.class);
// state machine builder not type safe anymore
builder.externalTransition().from("D").to("A").on(TestEvent.toA);
UntypedStateMachine fsm = builder.newStateMachine("A");
from squirrel.
yes, but I am refering to the example in the "Untyped state machine" section, which is not working for me.
Here it is :
enum TestEvent { toA, toB, toC, toD } @Transitions({ @Transit(from="A", to="B", on="toB", callMethod="fromAToB"), @Transit(from="B", to="C", on="toC"), @Transit(from="C", to="D", on="toD") }) @StateMachineParameters(stateType=String.class, eventType=TestEvent.class, contextType=Integer.class) class UntypedStateMachineSample extends AbstractUntypedStateMachine { // No need to specify constructor anymore since 0.2.9 // protected UntypedStateMachineSample(ImmutableUntypedState initialState, // Map<Object, ImmutableUntypedState> states) { // super(initialState, states); // } protected void fromAToB(String from, String to, TestEvent event, Integer context) { // transition action still type safe ... } protected void transitFromDToAOntoA(String from, String to, TestEvent event, Integer context) { // transition action still type safe ... } } UntypedStateMachineBuilder builder = StateMachineBuilderFactory.create( UntypedStateMachineSample.class); // state machine builder not type safe anymore builder.externalTransition().from("D").to("A").on(TestEvent.toA); UntypedStateMachine fsm = builder.newStateMachine("A");
notice that your Class UntypedStateMachineSample should be static
from squirrel.
I am also getting the same error.
Because I added a constructor with arguments in my custome StateMachine,and when create it without the arguments
from squirrel.
Same error here. Tried all versions 0.2.7 -> 0.3.8. Tried sample code, also tried the code from the comments here.
from squirrel.
The problem can be reproduced by adding to pom,xml
<dependency>
<groupId>com.google.collections</groupId>
<artifactId>google-collections</artifactId>
<version>1.0</version>
</dependency>
from squirrel.
Opened a new issue #102
from squirrel.
Related Issues (20)
- Set id of state machine HOT 3
- 指定的callMethod方法没执行
- CVE-2018-8088
- AbstractStateMachine.canAccept(E event) does not work for events acceptable from parent state
- Event firing has race conditions
- ConcurrentModificationException on event firing
- 为什么没有中文文档呢
- 同学,您这个项目引入了10个开源组件,存在1个漏洞,辛苦升级一下 HOT 1
- [Transition exception] To state same as From state if transition is not defined on defined event
- fire() 执行中,再获取状态机实例的当前状态时会被锁住
- parallel fire event, get exception: The state machine is already terminated. HOT 1
- event 处理并发安全咨询 HOT 1
- Race condition upon the instantiation of declarative state machines
- builder.transitions() not support from(A).to(B).onAmont(E1,E2...)
- 请问下该状态机实例有状态吗?是线程安全的吗?
- when biz code occurs an exception , here will lost StackTrace HOT 1
- ActionsImpl getSortedAction 方法会触发并发问题 HOT 1
- entry Action方法的from参数 为什么一直是null
- New history type 'recursive'
- 你一个国人不整一个中文文档 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from squirrel.