I had a offer state which is implementing LinearState and It was working fine till this point. Then I needed to implement Queryable state in our Offer state But when I implement the Queryable state and implement the schema for persistent state and When I run the flow it is not doing anything and flow is terminating without showing any error. When I approched the logs of the node, an exception was there which is as follows:
stack (net.corda.node.services.statemachine.FlowStateMachineImpl)
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:101) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer.write(CompatibleFieldSerializer.java:65) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:575) ~[kryo-4.0.2.jar:?]
at co.paralleluniverse.io.serialization.kryo.ReplaceableObjectKryo.writeObject(ReplaceableObjectKryo.java:85) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:79) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer.write(CompatibleFieldSerializer.java:65) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:575) ~[kryo-4.0.2.jar:?]
at co.paralleluniverse.io.serialization.kryo.ReplaceableObjectKryo.writeObject(ReplaceableObjectKryo.java:85) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:79) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer.write(CompatibleFieldSerializer.java:65) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:575) ~[kryo-4.0.2.jar:?]
at co.paralleluniverse.io.serialization.kryo.ReplaceableObjectKryo.writeObject(ReplaceableObjectKryo.java:85) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:79) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer.write(CompatibleFieldSerializer.java:65) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:575) ~[kryo-4.0.2.jar:?]
at co.paralleluniverse.io.serialization.kryo.ReplaceableObjectKryo.writeClassAndObject(ReplaceableObjectKryo.java:54) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.write(DefaultArraySerializers.java:361) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.write(DefaultArraySerializers.java:302) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:575) ~[kryo-4.0.2.jar:?]
at co.paralleluniverse.io.serialization.kryo.ReplaceableObjectKryo.writeObject(ReplaceableObjectKryo.java:85) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:79) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer.write(CompatibleFieldSerializer.java:65) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.Kryo.writeObjectOrNull(Kryo.java:629) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:86) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:508) ~[kryo-4.0.2.jar:?]
at co.paralleluniverse.fibers.Fiber$FiberSerializer.write(Fiber.java:2109) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at co.paralleluniverse.fibers.Fiber$FiberSerializer.write(Fiber.java:2086) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:575) ~[kryo-4.0.2.jar:?]
at co.paralleluniverse.io.serialization.kryo.ReplaceableObjectKryo.writeObject(ReplaceableObjectKryo.java:85) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:79) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer.write(CompatibleFieldSerializer.java:65) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:575) ~[kryo-4.0.2.jar:?]
at co.paralleluniverse.io.serialization.kryo.ReplaceableObjectKryo.writeObject(ReplaceableObjectKryo.java:85) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:79) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer.write(CompatibleFieldSerializer.java:65) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:575) ~[kryo-4.0.2.jar:?]
at co.paralleluniverse.io.serialization.kryo.ReplaceableObjectKryo.writeObject(ReplaceableObjectKryo.java:85) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:79) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer.write(CompatibleFieldSerializer.java:65) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:575) ~[kryo-4.0.2.jar:?]
at co.paralleluniverse.io.serialization.kryo.ReplaceableObjectKryo.writeClassAndObject(ReplaceableObjectKryo.java:54) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:100) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:40) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:575) ~[kryo-4.0.2.jar:?]
at co.paralleluniverse.io.serialization.kryo.ReplaceableObjectKryo.writeObject(ReplaceableObjectKryo.java:85) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:79) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer.write(CompatibleFieldSerializer.java:65) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.Kryo.writeObjectOrNull(Kryo.java:629) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:86) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer.write(CompatibleFieldSerializer.java:65) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:575) ~[kryo-4.0.2.jar:?]
at co.paralleluniverse.io.serialization.kryo.ReplaceableObjectKryo.writeClassAndObject(ReplaceableObjectKryo.java:54) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.write(DefaultArraySerializers.java:361) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.write(DefaultArraySerializers.java:302) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:575) ~[kryo-4.0.2.jar:?]
at co.paralleluniverse.io.serialization.kryo.ReplaceableObjectKryo.writeObject(ReplaceableObjectKryo.java:85) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:79) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer.write(CompatibleFieldSerializer.java:65) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.Kryo.writeObjectOrNull(Kryo.java:629) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:86) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:508) ~[kryo-4.0.2.jar:?]
at co.paralleluniverse.fibers.Fiber$FiberSerializer.write(Fiber.java:2109) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at co.paralleluniverse.fibers.Fiber$FiberSerializer.write(Fiber.java:2086) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:575) ~[kryo-4.0.2.jar:?]
at co.paralleluniverse.io.serialization.kryo.ReplaceableObjectKryo.writeClassAndObject(ReplaceableObjectKryo.java:54) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at net.corda.nodeapi.internal.serialization.kryo.KryoCheckpointSerializer$serialize$1$1.invoke(KryoCheckpointSerializer.kt:116) ~[corda-node-api-4.5.jar:?]
at net.corda.nodeapi.internal.serialization.kryo.KryoCheckpointSerializer$serialize$1$1.invoke(KryoCheckpointSerializer.kt:42) ~[corda-node-api-4.5.jar:?]
at net.corda.nodeapi.internal.serialization.kryo.KryoStreams$kryoOutput$1.invoke(KryoStreams.kt:30) ~[corda-node-api-4.5.jar:?]
at net.corda.nodeapi.internal.serialization.kryo.KryoStreams$kryoOutput$1.invoke(KryoStreams.kt) ~[corda-node-api-4.5.jar:?]
at net.corda.serialization.internal.ByteBufferStreams.byteArrayOutput(ByteBufferStreams.kt:22) ~[corda-serialization-4.5.jar:?]
at net.corda.nodeapi.internal.serialization.kryo.KryoStreams.kryoOutput(KryoStreams.kt:26) ~[corda-node-api-4.5.jar:?]
at net.corda.nodeapi.internal.serialization.kryo.KryoCheckpointSerializer$serialize$1.invoke(KryoCheckpointSerializer.kt:107) ~[corda-node-api-4.5.jar:?]
at net.corda.nodeapi.internal.serialization.kryo.KryoCheckpointSerializer$serialize$1.invoke(KryoCheckpointSerializer.kt:42) ~[corda-node-api-4.5.jar:?]
at net.corda.nodeapi.internal.serialization.kryo.KryoCheckpointSerializer$kryo$1.execute(KryoCheckpointSerializer.kt:70) ~[corda-node-api-4.5.jar:?]
at com.esotericsoftware.kryo.pool.KryoPoolQueueImpl.run(KryoPoolQueueImpl.java:58) ~[kryo-4.0.2.jar:?]
at net.corda.nodeapi.internal.serialization.kryo.KryoCheckpointSerializer.kryo(KryoCheckpointSerializer.kt:66) ~[corda-node-api-4.5.jar:?]
at net.corda.nodeapi.internal.serialization.kryo.KryoCheckpointSerializer.serialize(KryoCheckpointSerializer.kt:106) ~[corda-node-api-4.5.jar:?]
at net.corda.core.serialization.internal.CheckpointSerializationAPIKt.checkpointSerialize(CheckpointSerializationAPI.kt:130) ~[corda-core-4.5.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl$suspend$1.write(FlowStateMachineImpl.kt:484) ~[corda-node-4.5.jar:?]
at co.paralleluniverse.fibers.Fiber$3.run(Fiber.java:1994) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:824) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) ~[quasar-core-0.7.12_r3-jdk8.jar:0.7.12_r3]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_265]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_265]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[?:1.8.0_265]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[?:1.8.0_265]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_265]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_265]
at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$1$thread$1.run(AffinityExecutor.kt:63) ~[corda-node-4.5.jar:?]
**Caused by: java.lang.UnsupportedOperationException: net.corda.nodeapi.internal.persistence.CordaPersistence, which is a closeable resource, has been detected during flow checkpointing. Restoring such resources across node restarts is not supported. Make sure code accessing it is confined to a private method or the reference is nulled out.**
at net.corda.nodeapi.internal.serialization.kryo.AutoCloseableSerialisationDetector.write(KryoCheckpointSerializer.kt:36) ~[corda-node-api-4.5.jar:?]
at net.corda.nodeapi.internal.serialization.kryo.AutoCloseableSerialisationDetector.write(KryoCheckpointSerializer.kt:31) ~[corda-node-api-4.5.jar:?]
at com.esotericsoftware.kryo.Kryo.writeObjectOrNull(Kryo.java:629) ~[kryo-4.0.2.jar:?]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:86) ~[kryo-4.0.2.jar:?]
... 89 more
I have made the line bold which I think defines the problem mostly.
Here is the code for the state.
#BelongsToContract(OfferContract.class)
public class OfferState implements LinearState, QueryableState {
private final UniqueIdentifier linearID;
private AnonymousParty sender;
private AnonymousParty receiver;
private final String policyID;
private final double faceValue;
private double offeredAmount;
#Nullable
private boolean isActive;
public OfferState(UniqueIdentifier linearID, AnonymousParty sender, AnonymousParty receiver, String policyID, double faceValue, double offeredAmount, boolean isActive) {
this.linearID = linearID;
this.sender = sender;
this.receiver = receiver;
this.policyID = policyID;
this.faceValue = faceValue;
this.offeredAmount = offeredAmount;
this.isActive = isActive;
}
public AnonymousParty getSender() {
return sender;
}
public AnonymousParty getReceiver() {
return receiver;
}
public double getOfferedAmount() {
return offeredAmount;
}
public String getPolicyID() {
return policyID;
}
public double getFaceValue() {
return faceValue;
}
public UniqueIdentifier getLinearID() {
return linearID;
}
public boolean isActive() {
return isActive;
}
#NotNull
#Override
public List<AbstractParty> getParticipants() {
return Arrays.asList(sender,receiver);
}
#NotNull
#Override
public UniqueIdentifier getLinearId() {
return linearID;
}
#Override
public PersistentState generateMappedObject(#NotNull MappedSchema schema) {
if (schema instanceof BeLifeSchemaV1) {
return new BeLifeSchemaV1.PersistentOffer(
this.sender.toString(),
this.receiver.toString(),
this.policyID,
this.faceValue,
this.offeredAmount,
this.linearID
);
} else {
throw new IllegalArgumentException("Unrecognised schema $schema");
}
}
#Override
public Iterable<MappedSchema> supportedSchemas() {
return Arrays.asList(new BeLifeSchemaV1());
}
#Override
public String toString() {
return String.format("OfferState(LinearID = %s, Sender = %s, receiver =%s, policyID = %s, faceValue = %.2f, offeredAmount = %.2f)",linearID,
sender.getClass().getName(),receiver.getClass().getName(),policyID,faceValue,offeredAmount );
}
}
This is the code for my schema
package com.template.Schema;
/**
* The family of schemas for IOUState.
*/
public class BeLifeSchema {}
And here is the code for SchemaV1
public class BeLifeSchemaV1 extends MappedSchema {
public BeLifeSchemaV1() {
super(BeLifeSchema.class, 1, Arrays.asList(PersistentOffer.class));
}
#Nullable
#Override
public String getMigrationResource() {
return "BeLife.changelog-master";
}
/**
* An OfferState schema.
*/
#Entity
#Table(name = "Offer_states")
public static class PersistentOffer extends PersistentState {
#Column(name = "sender") private final String sender;
#Column(name = "receiver") private final String receiver;
#Column(name = "policyID") private final String policyID;
#Column(name = "faceValue") private final double faceValue;
#Column(name = "offeredAmount") private final double offeredAmount;
#Column(name = "linear_id") #Type (type = "uuid-char") private final UniqueIdentifier linearId;
public PersistentOffer(String sender, String receiver, String policyID, double faceValue, double offeredAmount, UniqueIdentifier linearId) {
this.sender = sender;
this.receiver = receiver;
this.policyID = policyID;
this.faceValue = faceValue;
this.offeredAmount = offeredAmount;
this.linearId = linearId;
}
// Default constructor required by hibernate.
public PersistentOffer() {
this.policyID = null;
this.offeredAmount = 0;
this.sender = null;
this.receiver = null;
this.faceValue = 0;
this.linearId = null;
}
public String getSender() {
return sender;
}
public String getReceiver() {
return receiver;
}
public String getPolicyID() {
return policyID;
}
public double getFaceValue() {
return faceValue;
}
public double getOfferedAmount() {
return offeredAmount;
}
public UniqueIdentifier getLinearId() {
return linearId;
}
}
}
I could not find any solution for this till now.
Please see If anyone can help. I am stuck here for days now.
As Adel said, without your schema it's hard to know what could be causing this.
Separately the error is actually mentioned in that log here:
**Caused by: java.lang.UnsupportedOperationException: net.corda.nodeapi.internal.persistence.CordaPersistence, which is a closeable resource, has been detected during flow checkpointing. Restoring such resources across node restarts is not supported. Make sure code accessing it is confined to a private method or the reference is nulled out.**
That being said the last thing I can share is some examples of queryableState being implemented. R3 maintains some samples.
In this IOUState sample the class implements both LinearState and QueryableState.
https://github.com/corda/samples-java/blob/master/Basic/cordapp-example/contracts-java/src/main/java/com/example/state/IOUState.java
There's also this sample using QueryableState for a Car insurance use case.
https://github.com/corda/samples-java/blob/master/Features/queryablestate-carinsurance/contracts/src/main/java/net/corda/examples/carinsurance/states/InsuranceState.java
good luck!
Related
I followed this guide How to display data from Firestore in a RecyclerView with Android?, but am facing a NullPointerException in the setter in the ViewHolder. I'm also actually very unsure of what to do in the setter in the ViewHolder...
![database]https://imgur.com/a/wquZ08f
Model:
public class FoodModel {
private String foodName;
private String foodType;
private String foodQty;
private String foodExpDate;
public FoodModel() {}
public FoodModel(String name, String type, String qty, String expDate) {
this.foodName = name;
this.foodType = type;
this.foodQty = qty;
this.foodExpDate = expDate;
}
public String getFoodName() {return foodName;}
public void setFoodName(String name) {foodName = name;}
public String getFoodType() {return foodType;}
public void setFoodType(String type) {foodType = type;}
public String getFoodQty() {return foodQty;}
public void setFoodQty(String qty) {foodQty = qty;}
public String getFoodExpDate() {return foodExpDate;}
public void setFoodExpDate(String expDate) {foodExpDate = expDate;}
}
Activity code:
recyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
Query foodQuery = db.collection("Food")
.orderBy("food_name", Query.Direction.ASCENDING);
FirestoreRecyclerOptions<FoodModel> options = new FirestoreRecyclerOptions.Builder<FoodModel>()
.setQuery(foodQuery, FoodModel.class)
.build();
adapter = new FirestoreRecyclerAdapter<FoodModel, FoodViewHolder>(options) {
#Override
protected void onBindViewHolder(#NonNull FoodViewHolder holder, int position, #NonNull FoodModel model) {
holder.setFoodName(model.getFoodName());
}
#NonNull
#Override
public FoodViewHolder onCreateViewHolder(#NonNull ViewGroup group, int viewType) {
View view = LayoutInflater.from(group.getContext()).inflate(R.layout.recycler_view_row, group, false);
return new FoodViewHolder(view);
}
};
recyclerView.setAdapter(adapter);
}
private class FoodViewHolder extends RecyclerView.ViewHolder {
private View view;
FoodViewHolder(View itemView) {
super(itemView);
view = itemView;
}
void setFoodName(String foodName) {
TextView textView = view.findViewById(R.id.editName);
textView.setText(foodName);
}
}
xml of recycler_view_row:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/foodListRow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
errors:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.qremind, PID: 17735
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
at com.example.qremind.FoodList$FoodViewHolder.setFoodName(FoodList.java:91)
at com.example.qremind.FoodList$1.onBindViewHolder(FoodList.java:70)
at com.example.qremind.FoodList$1.onBindViewHolder(FoodList.java:67)
at com.firebase.ui.firestore.FirestoreRecyclerAdapter.onBindViewHolder(FirestoreRecyclerAdapter.java:158)
at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7065)
at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7107)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6012)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6279)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114)
at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2303)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1627)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1587)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:665)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4134)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3851)
at androidx.recyclerview.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1897)
at androidx.recyclerview.widget.RecyclerView$1.run(RecyclerView.java:414)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:878)
at android.view.Choreographer.doCallbacks(Choreographer.java:690)
at android.view.Choreographer.doFrame(Choreographer.java:622)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:864)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:185)
at android.app.ActivityThread.main(ActivityThread.java:6473)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:916)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:806)
You have defined the Textview inside the function. Define it as
private class FoodViewHolder extends RecyclerView.ViewHolder {
private View view;
TextView textView;
FoodViewHolder(View itemView) {
super(itemView);
view = itemView;
textView = view.findViewById(R.id.editName);
}
void setFoodName(String foodName) {
textView.setText(foodName);
}
}
Change this:
TextView textView = view.findViewById(R.id.editName);
into this:
TextView textView = view.findViewById(R.id.foodListRow);
In FoodViewHolder class:
This method:
void setFoodName(String foodName) {
//here is your problem
TextView textView = view.findViewById(R.id.editName);
textView.setText(foodName);
}
Must be like this, you are pointing to the wrong ID:
void setFoodName(String foodName) {
TextView textView = view.findViewById(R.id.foodListRow);
textView.setText(foodName);
}
I'm getting the following error when I run my flow:
java.lang.IllegalArgumentException: Step Requesting Stellar to execute the escrow. not found in progress tracker.
at net.corda.core.utilities.ProgressTracker.setCurrentStep(ProgressTracker.kt:140) ~[corda-core-4.3.jar:?]
at com.finablr.money.loyalty.wallet.flows.RevokeCustomToken.call(RevokeCustomToken.java:139) ~[wallet-workflows-0.1.jar:?]
at com.finablr.money.loyalty.wallet.flows.RevokeCustomToken.call(RevokeCustomToken.java:36) ~[wallet-workflows-0.1.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:270) ~[corda-node-4.3.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:46) ~[corda-node-4.3.jar:?]
at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1092) ~[quasar-core-0.7.10-jdk8.jar:0.7.10]
at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:788) ~[quasar-core-0.7.10-jdk8.jar:0.7.10]
at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) ~[quasar-core-0.7.10-jdk8.jar:0.7.10]
at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) ~[quasar-core-0.7.10-jdk8.jar:0.7.10]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_222]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_222]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[?:1.8.0_222]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[?:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_222]
at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$1$thread$1.run(AffinityExecutor.kt:63) ~[corda-node-4.3.jar:?]
Even though I do have that step defined inside my flow:
private final Step STELLAR_EXECUTE_ESCROW = new Step("Requesting Stellar to execute the escrow.");
private final ProgressTracker progressTracker = new ProgressTracker(
STELLAR_EXECUTE_ESCROW
);
// Inside the call() method.
// Checkpoint workflow to replay from here in case of node failure.
sleep(Duration.ofMillis(1));
// Request Stellar to execute the escrow.
progressTracker.setCurrentStep(STELLAR_EXECUTE_ESCROW);
Flow tests didn't throw that error, it only happened on Google cloud; not sure whether check-pointing the flow is causing that or not.
Are you saying the issue was unique to google cloud? You didn't have this issue when running locally?
I'd double-check how you've defined the progressTracker.
Here's the highlights on a progresstracker definition from a code sample I've got handy.
public class YoFlow extends FlowLogic<SignedTransaction> {
private static final ProgressTracker.Step CREATING = new ProgressTracker.Step("Creating a new Yo!");
private static final ProgressTracker.Step SIGNING = new ProgressTracker.Step("Signing the Yo!");
private static final ProgressTracker.Step VERIFYING = new ProgressTracker.Step("Verfiying the Yo!");
private static final ProgressTracker.Step FINALISING = new ProgressTracker.Step("Sending the Yo!") {
#Nullable
#Override
public ProgressTracker childProgressTracker() {
return FinalityFlow.tracker();
}
};
ProgressTracker progressTracker = new ProgressTracker(
CREATING,
SIGNING,
VERIFYING,
FINALISING
);
#Nullable
#Override
public ProgressTracker getProgressTracker() {
return progressTracker;
}
private final Party target;
public YoFlow(Party target) {
this.target = target;
}
#Suspendable
#Override
public SignedTransaction call() throws FlowException {
progressTracker.setCurrentStep(CREATING);
As another possibility, make sure you're overriding the progress tracker methods, if you don't then you can't call the flow over SSH due to an obscure corda bug.
See https://docs.corda.net/docs/corda-os/4.4/shell.html#limitations
"Flows cannot be run unless they override the progress tracker"
Consider code bellow
Beneficiaire class :
#Entity
#Table(uniqueConstraints=
#UniqueConstraint(name="u_benef_noBenef", columnNames="noBenef"))
public class Beneficiaire implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer idBenef;
#Column(nullable=false)
private Integer noApBenef;
#Column(nullable=false)
private Integer noBenef;
#Column(columnDefinition="character varying(100) not null")
private String nomBenef;
#DateTimeFormat(pattern="dd/MM/yyyy")
#Column(nullable=false)
private LocalDate dateNaissanceBenef;
#ManyToOne(cascade=CascadeType.ALL)
#JoinColumn(name="id_cat_beneficiaire",
foreignKey=#ForeignKey(name="fk_benef_idCatBenef"),
nullable=false)
private CategorieBeneficiaire categorieBeneficiaire;
#ManyToOne(cascade=CascadeType.ALL)
#JoinColumn(name="id_sexe",
foreignKey=#ForeignKey(name="fk_benef_idSexe"),
nullable=false)
private Sexe sexe;
#ManyToOne(cascade=CascadeType.ALL)
#JoinColumn(name="id_assure",
foreignKey=#ForeignKey(name="fk_benef_idAssure"),
nullable=false)
private Assure assure;
#ManyToOne(cascade=CascadeType.ALL)
#JoinColumn(name="id_attributaire",
foreignKey=#ForeignKey(name="fk_benef_idAttrib"),
nullable=false)
private Attributaire attributaire;
#ManyToOne(cascade=CascadeType.ALL)
#JoinColumn(name="id_prestation",
foreignKey=#ForeignKey(name="fk_benef_idPrestation"),
nullable=false)
private Prestation prestation;
#DateTimeFormat(pattern="dd/MM/yyyy")
#Column(nullable=false)
private LocalDate dateEffetPrestation;
#Column(precision=8, nullable=false)
private BigDecimal mntMensuelPrestation;
private Integer trimestreDerniereEmission;
private Integer anneeDerniereEmission;
#Column(columnDefinition="integer default 1 not null", insertable=false)
private Integer estActifBenef;
#Column(columnDefinition="timestamp default current_timestamp not null", insertable=false)
private LocalDateTime dateheureCreationBenef;
#ManyToOne(cascade=CascadeType.ALL)
#JoinColumn(name="id_utilisateur",
foreignKey=#ForeignKey(name="utilisateur_id_fk"),
nullable=true)
private Utilisateur utilisateur;
/*#OneToMany(mappedBy="beneficiairePj", cascade=CascadeType.ALL, orphanRemoval=true)
private List<PieceJustificative> pieceJustificatives = new ArrayList<PieceJustificative>();*/
public Beneficiaire() {
//For JPA
}
public Beneficiaire(Integer noBenef, String nomBenef, Integer noApBenef,
CategorieBeneficiaire categorieBeneficiaire, Sexe sexe, Assure assure, Attributaire attributaire,
Prestation prestation) {
super();
this.noBenef = noBenef;
this.nomBenef = nomBenef;
this.noApBenef = noApBenef;
this.categorieBeneficiaire = categorieBeneficiaire;
this.sexe = sexe;
this.assure = assure;
this.attributaire = attributaire;
this.prestation = prestation;
}
public Integer getIdBenef() {
return idBenef;
}
public void setIdBenef(Integer idBenef) {
this.idBenef = idBenef;
}
public Integer getNoBenef() {
return noBenef;
}
public void setNoBenef(Integer noBenef) {
this.noBenef = noBenef;
}
public String getNomBenef() {
return nomBenef;
}
public void setNomBenef(String nomBenef) {
this.nomBenef = nomBenef;
}
public Integer getNoApBenef() {
return noApBenef;
}
public void setNoApBenef(Integer noApBenef) {
this.noApBenef = noApBenef;
}
public LocalDate getDateNaissanceBenef() {
return dateNaissanceBenef;
}
public void setDateNaissanceBenef(LocalDate dateNaissanceBenef) {
this.dateNaissanceBenef = dateNaissanceBenef;
}
public CategorieBeneficiaire getCategorieBeneficiaire() {
return categorieBeneficiaire;
}
public void setCategorieBeneficiaire(CategorieBeneficiaire categorieBeneficiaire) {
this.categorieBeneficiaire = categorieBeneficiaire;
}
public Sexe getSexe() {
return sexe;
}
public void setSexe(Sexe sexe) {
this.sexe = sexe;
}
public Assure getAssure() {
return assure;
}
public void setAssure(Assure assure) {
this.assure = assure;
}
public Attributaire getAttributaire() {
return attributaire;
}
public void setAttributaire(Attributaire attributaire) {
this.attributaire = attributaire;
}
public Prestation getPrestation() {
return prestation;
}
public void setPrestation(Prestation prestation) {
this.prestation = prestation;
}
public LocalDate getDateEffetPrestation() {
return dateEffetPrestation;
}
public void setDateEffetPrestation(LocalDate datteEffetPrestation) {
this.dateEffetPrestation = datteEffetPrestation;
}
public BigDecimal getMntMensuelPrestation() {
return mntMensuelPrestation;
}
public void setMntMensuelPrestation(BigDecimal mntMensuelPrestation) {
this.mntMensuelPrestation = mntMensuelPrestation;
}
public Integer getTrimestreDerniereEmission() {
return trimestreDerniereEmission;
}
public void setTrimestreDerniereEmission(Integer trimestreDerniereEmission)
{
this.trimestreDerniereEmission = trimestreDerniereEmission;
}
public Integer getAnneeDerniereEmission() {
return anneeDerniereEmission;
}
public void setAnneeDerniereEmission(Integer anneeDerniereEmission) {
this.anneeDerniereEmission = anneeDerniereEmission;
}
public Integer getEstActifBenef() {
return estActifBenef;
}
public void setEstActifBenef(Integer estActifBenef) {
this.estActifBenef = estActifBenef;
}
public LocalDateTime getDateheureCreationBenef() {
return dateheureCreationBenef;
}
public void setDateheureCreationBenef(LocalDateTime dateheureCreationBenef)
{
this.dateheureCreationBenef = dateheureCreationBenef;
}
public Utilisateur getUtilisateur() {
return utilisateur;
}
public void setUtilisateur(Utilisateur utilisateur) {
this.utilisateur = utilisateur;
}
//For Test Equal, override equals() and hashCode()
#Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Beneficiaire beneficiaire = (Beneficiaire) o;
return noBenef.equals(beneficiaire.getNoBenef());
}
#Override
public int hashCode() {
return Objects.hash(noBenef);
}
}
PieceJustificative class :
#Entity
#Table(uniqueConstraints=
#UniqueConstraint(name="u_pj_noPj", columnNames="noPj"))
public class PieceJustificative implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer idPj;
#Column(nullable=false)
private Integer noPj;
#DateTimeFormat(pattern="dd/MM/yyyy")
#Column(nullable=false)
private LocalDate dateDebutValiditePj;
#DateTimeFormat(pattern="dd/MM/yyyy")
#Column(nullable=false)
private LocalDate dateFinValiditePj;
#DateTimeFormat(pattern="dd/MM/yyyy")
#Column(nullable=false)
private LocalDate dateSignaturePj;
#Column(columnDefinition="timestamp default current_timestamp not null", insertable=false)
private LocalDateTime dateHeureSaisiePj;
private LocalDateTime dateHeureValidationPj;
#Column(columnDefinition="integer default 0 not null", insertable=false)
private Integer estValidePj;
/*#ManyToOne(optional=false, fetch=FetchType.LAZY)
*/
#ManyToOne
#JoinColumn(name="id_type_pj",
foreignKey=#ForeignKey(name="fk_pj_id_type_pj"),
nullable=false)
private TypePj typePj;
/*#ManyToOne(optional=false, fetch=FetchType.LAZY)
#JoinColumn(name="id_beneficiaire",
foreignKey=#ForeignKey(name="fk_pj_id_beneficiaire"))
*/
/*#ManyToOne(optional=false)*/
#ManyToOne
#JoinColumn(name="idBenef",
foreignKey=#ForeignKey(name="fk_pj_id_beneficiaire"),
nullable=false)
private Beneficiaire beneficiairePj;
#ManyToOne
#JoinColumn(name="id_utilisateur_saisie",
foreignKey=#ForeignKey(name="fk_pj_id_utilisateur_saisie"))
private Utilisateur utilisateurSaisiePj;
#ManyToOne
#JoinColumn(name="id_utilisateur_valide",
foreignKey=#ForeignKey(name="fk_pj_id_utilisateur_valide"))
private Utilisateur utilisateurValidationPj;
protected PieceJustificative() {
//For JPA
}
public Integer getIdPj() {
return idPj;
}
public void setIdPj(Integer idPj) {
this.idPj = idPj;
}
public Integer getNoPj() {
return noPj;
}
public void setNoPj(Integer noPj) {
this.noPj = noPj;
}
public LocalDate getDateDebutValiditePj() {
return dateDebutValiditePj;
}
public void setDateDebutValiditePj(LocalDate dateDebutValiditePj) {
this.dateDebutValiditePj = dateDebutValiditePj;
}
public LocalDate getDateFinValiditePj() {
return dateFinValiditePj;
}
public void setDateFinValiditePj(LocalDate dateFinValiditePj) {
this.dateFinValiditePj = dateFinValiditePj;
}
public LocalDate getDateSignaturePj() {
return dateSignaturePj;
}
public void setDateSignaturePj(LocalDate dateSignaturePj) {
this.dateSignaturePj = dateSignaturePj;
}
public LocalDateTime getDateHeureSaisiePj() {
return dateHeureSaisiePj;
}
public void setDateHeureSaisiePj(LocalDateTime dateHeureSaisiePj) {
this.dateHeureSaisiePj = dateHeureSaisiePj;
}
public LocalDateTime getDateHeureValidationPj() {
return dateHeureValidationPj;
}
public void setDateHeureValidationPj(LocalDateTime dateHeureValidationPj) {
this.dateHeureValidationPj = dateHeureValidationPj;
}
public Integer getEstValidePj() {
return estValidePj;
}
public void setEstValidePj(Integer estValidePj) {
this.estValidePj = estValidePj;
}
/**
* #return the typePj
*/
public TypePj getTypePj() {
return typePj;
}
/**
* #param typePj the typePj to set
*/
public void setTypePj(TypePj typePj) {
this.typePj = typePj;
}
public Beneficiaire getBeneficiairePj() {
return beneficiairePj;
}
public void setBeneficiairePj(Beneficiaire beneficiairePj) {
this.beneficiairePj = beneficiairePj;
}
public Utilisateur getUtilisateurSaisiePj() {
return utilisateurSaisiePj;
}
public void setUtilisateurSaisiePj(Utilisateur utilisateurSaisiePj) {
this.utilisateurSaisiePj = utilisateurSaisiePj;
}
public Utilisateur getUtilisateurValidationPj() {
return utilisateurValidationPj;
}
public void setUtilisateurValidationPj(Utilisateur utilisateurValidationPj) {
this.utilisateurValidationPj = utilisateurValidationPj;
}
//For Test Equal, override equals() and hashCode()
#Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
PieceJustificative pieceJustificative = (PieceJustificative) o;
return noPj.equals(pieceJustificative.getNoPj());
}
#Override
public int hashCode() {
return Objects.hash(noPj);
}
}
My thymeleaf rendered view for list of PieceJustificative :
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorator="layouts/layout">
<head>
<meta charset="UTF-8" />
<title>Liste des pièces justificatives</title>
<!-- <link th:href="#{/css/form.css}" rel="stylesheet"/> -->
</head>
<body>
<div id="content" layout:fragment="content">
<div class="w3-container">
<h2>Liste des pièces justificatives</h2>
<!-- <table class="w3-table-all w3-hoverable"> -->
<table id="customers">
<thead>
<!-- <tr class="w3-light-grey"> -->
<tr >
<th>N° pièce jointe</th>
<th>Type pièce jointe</th>
<th>N° bénéficiaire</th>
<th>Nom bénéficiaire</th>
<th>Date début validité</th>
<th>Date fin validité</th>
<th>Date signature</th>
<th>Modifier</th>
<th>Supprimer</th>
</tr>
</thead>
<tr th:each="pieceJustificative : ${pieceJustificatives}">
<td th:text="${pieceJustificative.noPj}">N°</td>
<td th:text="${pieceJustificative.typePj.libelleTypePj}">libelleTypePj</td>
<td th:text="${pieceJustificative.beneficiairePj.noBenef}">noBenef</td>
<td th:text="${pieceJustificative.beneficiairePj.nomBenef}">nomBenef</td>
<td th:text="${#temporals.format(pieceJustificative.dateDebutValiditePj, 'dd/MM/yyyy')}">dateDebutValiditePj</td>
<td th:text="${#temporals.format(pieceJustificative.dateFinValiditePj, 'dd/MM/yyyy')}">dateFinValiditePj</td>
<td th:text="${#temporals.format(pieceJustificative.dateSignaturePj, 'dd/MM/yyyy')}">dateSignaturePj</td>
<td>Modifier</td>
<td>Supprimer</td>
</tr>
</table>
</div>
<p>
Ajouter pièce justificative
</p>
</div><!-- end div content -->
When I tried to render this list of PieceJustificative, I got this exception, however the Beneficiaire with id 57271 exist in my database :
javax.persistence.EntityNotFoundException: Unable to find ne.cnss.pension.beneficiaire.Beneficiaire with id 57271
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$JpaEntityNotFoundDelegate.handleEntityNotFound(EntityManagerFactoryBuilderImpl.java:144) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:278) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:121) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:89) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1129) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:1022) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:639) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.type.EntityType.resolve(EntityType.java:431) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:154) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:128) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1133) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.loader.Loader.processResultSet(Loader.java:992) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.loader.Loader.doQuery(Loader.java:930) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:336) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2617) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2600) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2429) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.loader.Loader.list(Loader.java:2424) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:501) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:371) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1326) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:87) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:606) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:483) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.jpa.criteria.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:50) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:329) ~[spring-data-jpa-1.11.8.RELEASE.jar:na]
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:74) ~[spring-data-jpa-1.11.8.RELEASE.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:504) ~[spring-data-commons-1.13.8.RELEASE.jar:na]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:489) ~[spring-data-commons-1.13.8.RELEASE.jar:na]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:461) ~[spring-data-commons-1.13.8.RELEASE.jar:na]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:56) ~[spring-data-commons-1.13.8.RELEASE.jar:na]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[spring-tx-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) ~[spring-tx-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) ~[spring-tx-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133) ~[spring-data-jpa-1.11.8.RELEASE.jar:na]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57) ~[spring-data-commons-1.13.8.RELEASE.jar:na]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at com.sun.proxy.$Proxy162.findAll(Unknown Source) ~[na:na]
at ne.cnss.pension.piecejustificative.PieceJustificativeService.listeDesPiecesJustificatives(PieceJustificativeService.java:101) ~[classes/:na]
at ne.cnss.pension.piecejustificative.PieceJustificativeController.listeDesCategoriesPieceJustificatives(PieceJustificativeController.java:117) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) ~[spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.23.jar:8.5.23]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:108) ~[spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81) ~[spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) ~[spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) [tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803) [tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) [tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459) [tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.23.jar:8.5.23]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_131]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.23.jar:8.5.23]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]
Try fetch=FetchType.EAGER
Default is lazy. It should work.
Can anyone help me!
i am a new developer getting this error. I am trying to populate a recyclerview with firebase through databinding in a fragment.
ProductListFragment.java
public class ProductListFragment extends Fragment {
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
RecyclerView recyclerView = (RecyclerView) inflater.inflate(R.layout.recycler_view, container, false);
FirebaseRecyclerAdapter adapter;
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
Firebase mFirebaseRef = new Firebase(Constants.FIREBASE_URL).child("subcategories").child("abc");
adapter = new FirebaseRecyclerAdapter<Product, ViewHolder>(
Product.class, R.layout.fragment_list_product, ViewHolder.class, mFirebaseRef) {
#Override
protected void populateViewHolder(ViewHolder viewHolder, Product product, int i) {
FragmentProductListBinding binding = viewHolder.getBinding();
binding.setProduct(product);
}
};
recyclerView.setAdapter(adapter);
return recyclerView;
}
public static class ViewHolder extends RecyclerView.ViewHolder {
FragmentProductListBinding binding;
public ViewHolder (View rootView) {
super(rootView);
binding = DataBindingUtil.bind(rootView);
}
public FragmentProductListBinding getBinding() {
return binding;
}
}
}
Product.java contains the POJO
public class Product extends BaseObservable {
public String productTitle;
public String productUnit;
public String productMRP;
public String productSellingPrice;
public String productDescription;
public Product() {
}
#Bindable
public String getProductUnit() {
return productUnit;
}
public void setProductUnit(String productUnit) {
this.productUnit = productUnit;
}
#Bindable
public String getProductMRP() {
return productMRP;
}
public void setProductMRP(String productMRP) {
this.productMRP = productMRP;
}
#Bindable
public String getProductSellingPrice() {
return productSellingPrice;
}
public void setProductSellingPrice(String productSellingPrice) {
this.productSellingPrice = productSellingPrice;
}
#Bindable
public String getProductDescription() {
return productDescription;
}
public void setProductDescription(String productDescription) {
this.productDescription = productDescription;
}
#Bindable
public String getProductTitle() {
return productTitle;
}
public void setProductTitle(String productTitle) {
this.productTitle = productTitle;
}
}
fragment_list_product.xml
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable name="Product" type="com.abc.www.abc.model.Product"/>
</data>
<RelativeLayout
android:padding="#dimen/activity_horizontal_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/product_image"
android:layout_width="40dp"
android:layout_height="40dp"
android:scaleType="centerCrop"
android:src="#drawable/ic_twitter"
android:contentDescription="#string/product_list_image_content_description"/>
<TextView
android:id="#+id/product_mrp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/colorPrimary"
android:ellipsize="end"
android:singleLine="true"
android:text="#{Product.productMRP}"
android:textAppearance="?attr/textAppearanceListItem"
android:textSize="14sp"
android:layout_gravity="center"
android:layout_below="#+id/product_title"
android:layout_toRightOf="#+id/product_image"
android:layout_toEndOf="#+id/product_image" />
<TextView
android:id="#+id/product_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_toRightOf="#+id/product_image"
android:layout_toEndOf="#+id/product_image"
android:layout_marginEnd="16dp"
android:text="#{Product.productTitle}"
android:textAppearance="?attr/textAppearanceListItem"
android:textSize="16sp"
android:layout_gravity="top" />
<TextView
android:id="#+id/product_selling_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/colorPrimary"
android:ellipsize="end"
android:singleLine="true"
android:text="#{Product.productSellingPrice}"
android:textAppearance="?attr/textAppearanceListItem"
android:textSize="14sp"
android:layout_gravity="center"
android:layout_below="#+id/product_title"
android:layout_toRightOf="#+id/product_mrp"
android:layout_toEndOf="#+id/product_mrp" />
</RelativeLayout>
here is the error which i am getting.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.abc.www.abc, PID: 1894
com.firebase.client.FirebaseException: Failed to bounce to type
at com.firebase.client.DataSnapshot.getValue(DataSnapshot.java:183)
at com.firebase.ui.FirebaseRecyclerAdapter.parseSnapshot(FirebaseRecyclerAdapter.java:161)
at com.firebase.ui.FirebaseRecyclerAdapter.getItem(FirebaseRecyclerAdapter.java:150)
at com.firebase.ui.FirebaseRecyclerAdapter.onBindViewHolder(FirebaseRecyclerAdapter.java:190)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5453)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5486)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4723)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4599)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1988)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1384)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1347)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:574)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3003)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2881)
at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1457)
at android.support.v7.widget.RecyclerView.access$400(RecyclerView.java:147)
at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:285)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:603)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5422)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type [simple type, class com.abc.www.abc.model.Product] from String value; no single-String constructor/factory method
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator._createFromStringFallbacks(StdValueInstantiator.java:428)
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createFromString(StdValueInstantiator.java:299)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromString(BeanDeserializerBase.java:1056)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:136)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:123)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2888)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2034)
at com.firebase.client.DataSnapshot.getValue(DataSnapshot.java:181)
at com.firebase.ui.FirebaseRecyclerAdapter.parseSnapshot(FirebaseRecyclerAdapter.java:161)
at com.firebase.ui.FirebaseRecyclerAdapter.getItem(FirebaseRecyclerAdapter.java:150)
at com.firebase.ui.FirebaseRecyclerAdapter.onBindViewHolder(FirebaseRecyclerAdapter.java:190)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5453)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5486)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4723)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4599)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1988)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1384)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1347)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:574)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3003)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2881)
at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1457)
at android.support.v7.widget.RecyclerView.access$400(RecyclerView.java:147)
at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:285)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:603)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5422)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
it is the database which i am try to fetch from firebase.
subcategories{
abc{
product-description:"xxadasccdcnsdcnsdc"
product-mrp: 100
product-selling-price: 80
product-title:"Name"
product-unit: "100 meter"}
}
Use #JsonProperty("product-description") on top of your variables to match it with your db.
#JsonProperty("product-title")
public String productTitle;
#JsonProperty("product-unit")
public String productUnit;
The problem here is that the Jackson library used by Firebase Android client to serialize/deserialize JSON is not matching property names in the POJO and the DB
Use the #JsonIgnoreProperties(ignoreUnknown = true) on the top of your BaseObservable.class
#JsonIgnoreProperties(ignoreUnknown = true)
public class Product extends BaseObservable {
public Product() {
}
Refer this link for reference
I have my service endpoint invoking get() method on my DAO, but fails with java.lang.NullPointerException. while debuging it seems Spring cannot find the implementation of my DAO
ContactEndoint
package com.spring.contacts;
#Endpoint
#Configuration
#ComponentScan(basePackages="com.spring.contacts")
#EnableWebMvc
public class ContactEndpoint {
private static final String NAMESPACE_URI = "http://spring.io/guides/gs-producing-web-service";
#Autowired
private ContactDAO contactDAO;
//Default constructor
public ContactEndpoint(){
}
#Autowired
public ContactEndpoint(ContactDAO contactDAO) {
this.contactDAO = contactDAO;
}
#Cacheable(cacheName="imageCache", keyGenerator=#KeyGenerator(name="StringKeyCache"))
#PayloadRoot(namespace = NAMESPACE_URI, localPart = "getContactRequest")
#RequestMapping(value = "/editContact", method = RequestMethod.GET)
#ResponsePayload
public GetContactResponse getContact(#RequestPayload GetContactRequest request){
GetContactResponse response = new GetContactResponse();
response.setContact(contactDAO.get(request.getId()));
return response;
}
ContactDAO
package com.spring.contacts.dao;
public interface ContactDAO {
public Contact get(int contactId);
ContactDAOImpl
package com.spring.contacts.dao;
#Repository("contactDAO")
public class ContactDAOImpl implements ContactDAO {
private JdbcTemplate jdbcTemplate;
//default constructor
public ContactDAOImpl(){
}
public ContactDAOImpl(DataSource dataSource) {
jdbcTemplate = new JdbcTemplate(dataSource);
}
#Override
public Contact get(int contactId) {
String sql = "SELECT * FROM contact WHERE contact_id=" + contactId;
return jdbcTemplate.query(sql, new ResultSetExtractor<Contact>() {
#Override
public Contact extractData(ResultSet rs) throws SQLException,
DataAccessException {
if (rs.next()) {
Contact contact = new Contact();
contact.setId(rs.getInt("contact_id"));
contact.setName(rs.getString("name"));
contact.setEmail(rs.getString("email"));
contact.setAdress(rs.getString("address"));
contact.setTelephone(rs.getString("telephone"));
return contact;
}
return null;
}
});
}
WebServiceConfig
package com.spring.contacts;
#EnableWs
#Configuration
#ComponentScan("com.spring")
public class WebServiceConfig extends WsConfigurerAdapter {
#Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(servlet, "/ws/*");
}
#Bean(name = "countries")
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) {
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
wsdl11Definition.setPortTypeName("CountriesPort");
wsdl11Definition.setLocationUri("/ws");
wsdl11Definition.setTargetNamespace("http://spring.io/guides/gs-producing-web-service");
wsdl11Definition.setSchema(countriesSchema);
return wsdl11Definition;
}
#Bean(name = "contacts")
public DefaultWsdl11Definition defaultContactsWsdl11Definition(XsdSchema contactsSchema){
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
wsdl11Definition.setPortTypeName("ContactsPort");
wsdl11Definition.setLocationUri("/ws/JDBC");
wsdl11Definition.setTargetNamespace("http://spring.io/guides/gs-producing-web-service");
wsdl11Definition.setSchema(contactsSchema);
return wsdl11Definition;
}
#Bean
public XsdSchema countriesSchema() {
return new SimpleXsdSchema(new ClassPathResource("countries/countries.xsd"));
}
#Bean
public XsdSchema contactsSchema(){
return new SimpleXsdSchema(new ClassPathResource("contacts/contact.xsd"));
}
StackTrace
java.lang.NullPointerException: null
at com.spring.contacts.dao.ContactDAOImpl.get(ContactDAOImpl.java:85) ~[ContactDAOImpl.class:na]
at com.spring.contacts.dao.ContactDAOImpl$$FastClassBySpringCGLIB$$f0feb335.invoke(<generated>) ~[spring-core-4.1.6.RELEASE.jar:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) ~[spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at com.spring.contacts.dao.ContactDAOImpl$$EnhancerBySpringCGLIB$$5f3048d3.get(<generated>) ~[spring-core-4.1.6.RELEASE.jar:na]
at com.spring.contacts.ContactEndpoint.getContact(ContactEndpoint.java:45) ~[ContactEndpoint.class:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_25]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_25]
at org.springframework.ws.server.endpoint.MethodEndpoint.invoke(MethodEndpoint.java:134) ~[spring-ws-core-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter.invokeInternal(DefaultMethodEndpointAdapter.java:291) ~[spring-ws-core-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.ws.server.endpoint.adapter.AbstractMethodEndpointAdapter.invoke(AbstractMethodEndpointAdapter.java:55) ~[spring-ws-core-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:236) [spring-ws-core-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:176) [spring-ws-core-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:89) ~[spring-ws-core-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:61) ~[spring-ws-core-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:293) ~[spring-ws-core-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) ~[spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868) ~[spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) ~[servlet-api.jar:na]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) ~[spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[servlet-api.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) ~[catalina.jar:8.0.21]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[catalina.jar:8.0.21]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-websocket.jar:8.0.21]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[catalina.jar:8.0.21]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[catalina.jar:8.0.21]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) ~[catalina.jar:8.0.21]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) ~[catalina.jar:8.0.21]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) ~[catalina.jar:8.0.21]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) ~[catalina.jar:8.0.21]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) ~[catalina.jar:8.0.21]
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610) ~[catalina.jar:8.0.21]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) ~[catalina.jar:8.0.21]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518) ~[catalina.jar:8.0.21]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091) ~[tomcat-coyote.jar:8.0.21]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668) ~[tomcat-coyote.jar:8.0.21]
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223) ~[tomcat-coyote.jar:8.0.21]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1517) ~[tomcat-coyote.jar:8.0.21]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1474) ~[tomcat-coyote.jar:8.0.21]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) ~[na:1.7.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) ~[na:1.7.0_25]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-util.jar:8.0.21]
at java.lang.Thread.run(Thread.java:724) ~[na:1.7.0_25]
I fixed it by injecting datasource to DAOImpl using #Autowired
#Autowired
public ContactDAOImpl(DataSource dataSource) {
jdbcTemplate = new JdbcTemplate(dataSource);
}