Event handlling in JavaFX Port for Android - gluon

I am using a mouse event handler on my java fx solitaire application. It was design for desktop only. Then I discover JavaFx Port. So I tried to test if my application will work on mobile device. It display good like the image below.
My problem is when I try to drag and drop the card. It crashes the app. Is it maybe because of my event handling?
I tried it on real device(Kindle Fire) and VM (Blue Stacks)
Below is the error log of Blue Stacks VM.
07-24 13:59:51.313 6441 6474 I System.out: don't add points, primary = -1
07-24 13:59:51.313 6441 6474 I System.out: Top Card: 9H
07-24 13:59:51.313 6441 6474 I System.out: Source Card: 8S
07-24 13:59:51.313 6441 6474 I System.out: createNewCard(): Creating card...
07-24 13:59:51.313 6441 6474 I System.out: createNewCard(): Setting card images...
07-24 13:59:51.333 6441 6474 I System.out: createNewCard(): Setting card name...
07-24 13:59:51.333 6441 6474 I System.out: createNewCard(): Setting card Event Filter...
07-24 13:59:51.333 6441 6474 I System.out: createNewCard(): Setting card location..
07-24 13:59:51.333 6441 6474 I System.out: createNewCard(): Setting card color...
07-24 13:59:51.333 6441 6474 I System.out: createNewCard(): Returning card...
07-24 13:59:51.333 1881 1963 D BstCommandProcessor-Application: Application crash has been observed.
07-24 13:59:51.333 6441 6474 I Process : Sending signal. PID: 6441 SIG: 9
07-24 13:59:51.333 6441 6474 D AndroidRuntime: procName from cmdline: com.gluonapplication2
07-24 13:59:51.333 6441 6474 E AndroidRuntime: in writeCrashedAppName, pkgName :com.gluonapplication2
07-24 13:59:51.333 6441 6474 D AndroidRuntime: file written successfully with content: com.gluonapplication2 StringBuffer : ;com.gluonapplication2
07-24 13:59:51.333 6441 6474 E AndroidRuntime: FATAL EXCEPTION: JavaFX Application Thread
07-24 13:59:51.333 6441 6474 E AndroidRuntime: Process: com.gluonapplication2, PID: 6441
07-24 13:59:51.333 6441 6474 E AndroidRuntime: java.lang.NoSuchMethodError: java.util.ArrayList.stream
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.gluonapplication2.views.SolitaireEvent.lambda$dragDropped$5(SolitaireEvent.java:142)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.gluonapplication2.views.SolitaireEvent.access$lambda$4(SolitaireEvent.java)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.gluonapplication2.views.SolitaireEvent$$Lambda$7.handle(Unknown Source)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at javafx.event.Event.fireEvent(Event.java:198)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at javafx.scene.Scene$DnDGesture.fireEvent(Scene.java:2937)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at javafx.scene.Scene$DnDGesture.processTargetDrop(Scene.java:3163)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at javafx.scene.Scene$DnDGesture.access$6400(Scene.java:2913)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at javafx.scene.Scene$DropTargetListener.drop(Scene.java:2877)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler.lambda$handleDragDrop$291(GlassSceneDnDEventHandler.java:95)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler.access$lambda$2(GlassSceneDnDEventHandler.java)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler$$Lambda$3.run(Unknown Source)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at java.security.AccessController.doPrivileged(AccessController.java:52)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.tk.quantum.GlassSceneDnDEventHandler.handleDragDrop(GlassSceneDnDEventHandler.java:92)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleDragDrop$345(GlassViewEventHandler.java:672)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.tk.quantum.GlassViewEventHandler.access$lambda$7(GlassViewEventHandler.java)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.tk.quantum.GlassViewEventHandler$$Lambda$10.get(Unknown Source)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:391)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleDragDrop(GlassViewEventHandler.java:671)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.glass.ui.View.handleDragDrop(View.java:712)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.glass.ui.View.notifyDragDrop(View.java:1037)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.glass.ui.monocle.MonocleView.notifyDragDrop(MonocleView.java:163)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.glass.ui.monocle.MouseInput.notifyMouse(MouseInput.java:248)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.glass.ui.monocle.MouseInput.lambda$postMouseEvent$100(MouseInput.java:227)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.glass.ui.monocle.MouseInput.access$lambda$3(MouseInput.java)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.glass.ui.monocle.MouseInput$$Lambda$4.run(Unknown Source)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:92)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.glass.ui.monocle.RunnableProcessor.enterNestedEventLoop(RunnableProcessor.java:107)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.glass.ui.monocle.MonocleApplication._enterNestedEventLoop(MonocleApplication.java:144)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.glass.ui.monocle.MonocleApplication.enterDnDEventLoop(MonocleApplication.java:371)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.glass.ui.monocle.MonocleDnDClipboard.pushToSystem(MonocleDnDClipboard.java:54)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.glass.ui.SystemClipboard.flush(SystemClipboard.java:51)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.glass.ui.ClipboardAssistance.flush(ClipboardAssistance.java:59)
07-24 13:59:51.333 6441 6474 E AndroidRuntime: at com.sun.java
07-24 13:59:51.343 1881 1963 W BstCommandProcessor-Application: in sendHttpRequest, requestType is of CRASH_APP type but one of the requiredInfo is NULL, crashedApp = com.bluestacks.BstCommandProcessor.BstCrashedAppInfo#4e79b1e8
07-24 13:59:51.343 1881 1963 D BstCommandProcessor-Application: in sendHttpRequest, request to send to (fqdn): http://10.0.2.2:2861/AppCrashedInfo
07-24 13:59:51.343 1881 1963 D BstCommandProcessor-Application: data: {"packageName":"com.gluonapplication2","shortPackageName":"com.gluonapplication2","versionCode":1,"versionName":"1.0"}
07-24 13:59:51.363 1677 1924 I ActivityManager: Process com.gluonapplication2 (pid 6441) has died.
07-24 13:59:51.363 1677 1880 I WindowState: WIN DEATH: Window{4e8b30d8 u0 com.gluonapplication2/javafxports.android.FXActivity}
07-24 13:59:51.363 1677 1924 W ActivityManager: Force removing ActivityRecord{4eaf8ee8 u0 com.gluonapplication2/javafxports.android.FXActivity t9}: app died, no saved state
Here is my SolitaireEvent.Java code. I commented where the line 142 that the error log is telling
public class SolitaireEvent {
Pane tempPane;
double locationY;
EventHandler mouseDrag;
DataFormat cardDataFormat;
AlertDialog alert;
static ArrayList<Card> cardList;
ArrayList<Pane> topPanes;
public SolitaireEvent(Pane tempPane, double locationY, EventHandler mouseDrag, DataFormat cardDataFormat) {
this.tempPane = tempPane;
this.locationY = locationY;
this.mouseDrag = mouseDrag;
this.cardDataFormat = cardDataFormat;
}
public SolitaireEvent(ArrayList<Pane> topPanes, Pane tempPane, double locationY, EventHandler mouseDrag, DataFormat cardDataFormat) {
this.topPanes = topPanes;
this.tempPane = tempPane;
this.locationY = locationY;
this.mouseDrag = mouseDrag;
this.cardDataFormat = cardDataFormat;
}
public SolitaireEvent(DataFormat cardDataFormat) {
this.cardDataFormat = cardDataFormat;
}
public void dragDetected(Object object) {
final Card card = (Card) object;
card.setOnDragDetected((MouseEvent event) -> {
// drag was detected, start drag-and-drop gesture
System.out.println("onDragDetected");
cardList = new ArrayList<>();
Dragboard db = card.startDragAndDrop(TransferMode.ANY);
for (int i = tempPane.getChildren().indexOf(card); i < tempPane.getChildren().size(); i++) {
Card cardMove = (Card) tempPane.getChildren().get(i);
System.out.println("cardList Source Pane: " + tempPane + " Source Card: " + cardMove.getName());
cardList.add(cardMove);
}
Image [] image = new Image[cardList.size()];
//db.setDragView(image);
// put a string on dragboard
ClipboardContent content = new ClipboardContent();
content.put(cardDataFormat, cardList);
db.setContent(content);
event.consume();
});
}
public void dragOver(Object e) {
//System.out.println("onDragOver");
Pane targetPane = (Pane) e;
targetPane.setOnDragOver((DragEvent event) -> {
// data is dragged over the target
// accept it only if it is not dragged from the same node
// and if it has a string data
if (event.getGestureSource() != targetPane
&& event.getDragboard().hasContent(cardDataFormat)) {
// allow for both copying and moving, whatever user chooses
event.acceptTransferModes(TransferMode.ANY);
}
event.consume();
});
}
public void dragEntered(Object e) {
Pane targetPane = (Pane) e;
targetPane.setOnDragEntered((DragEvent event) -> {
// the drag-and-drop gesture entered the target
System.out.println("onDragEntered");
// show to the user that it is an actual gesture target
if (event.getGestureSource() != targetPane && event.getDragboard().hasContent(cardDataFormat)) {
//targetPane.setBackground(new Background(new BackgroundFill(Color.GREEN, CornerRadii.EMPTY, Insets.EMPTY)));
}
event.consume();
});
}
public void dragExited(Object e) {
//System.out.println("onDragExited");
Pane target = (Pane) e;
target.setOnDragExited((DragEvent event) -> {
// mouse moved away, remove the graphical cues
// target.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY)));
event.consume();
});
}
public void dragDropped(Object e) {
Pane targetPane = (Pane) e;
targetPane.setOnDragDropped((DragEvent event) -> {
// Get the Dragboard data
Dragboard db = event.getDragboard();
boolean success = false;
// if there is an image data on dragboard, read it and use it
if (db.hasContent(cardDataFormat)) {
Card targetTopCard = getTargetTopCard(targetPane);
ArrayList<Card> cardSourceList = (ArrayList<Card>) db.getContent(cardDataFormat);
if (checkCards(cardSourceList, targetPane, targetTopCard)) {
// Line 142 is the next line
cardList.stream().forEach((sourceCard) -> {
dragDone(sourceCard);
});
targetTopCard = null;
cardList = null;
}
}
// transferred and used
event.setDropCompleted(success);
event.consume();
});
}
private boolean checkCards(ArrayList<Card> cardSourceList, Pane targetPane, Card targetTopCard) {
boolean success = false;
SolitaireRule solRule = new SolitaireRule();
for (Card sourceCard : cardSourceList) {
if (!checkTopPanes(targetPane)) {
if (!targetPane.getChildren().isEmpty()) {
if (!solRule.sameColor(sourceCard.getName(), targetTopCard.getName())) {
if (solRule.compareRank(sourceCard.getName(), targetTopCard.getName())) {
locationY = getLocationY(targetPane);
Card card = createNewCard(sourceCard.getName());
targetPane.getChildren().add(card);
success = true;
} else {
//alert = new AlertDialog(Alert.AlertType.WARNING, "Warning", "Same Color", "The cards are the same colors.");
success = false;
break;
}
} else {
//alert = new AlertDialog(Alert.AlertType.WARNING, "Warning", "Same Color", "The cards are the same colors.");
success = false;
break;
}
} else {
success = acceptKing(targetTopCard, sourceCard, targetPane);
}
targetTopCard = sourceCard;
} else {
success = acceptAce(targetTopCard, sourceCard, targetPane);
break;
}
}
return success;
}
private boolean checkTopPanes(Pane targetPane) {
boolean found = false;
for (Pane pane : topPanes) {
if (pane == targetPane) {
found = true;
System.out.println("Found Pane: " + targetPane);
break;
}
}
return found;
}
public void dragDone(Card sourceCard) {
System.out.println("cardList Source Pane: " + tempPane + " cardList Source Card: " + sourceCard);
tempPane.getChildren().remove(sourceCard);
if (!tempPane.getChildren().isEmpty()) {
// Flip the last
new SolitaireAnimation().flipCard(tempPane, mouseDrag);
}
}
private Card createNewCard(String cardName) {
System.out.println("createNewCard(): Creating card...");
Card card = new Card();
System.out.println("createNewCard(): Setting card images...");
card.setImage(new Image(SolitaireEvent.class.getResourceAsStream("/" + cardName + card.IMGEXT)));
System.out.println("createNewCard(): Setting card name...");
card.setName(cardName);
System.out.println("createNewCard(): Setting card Event Filter...");
card.addEventFilter(MouseDragEvent.MOUSE_PRESSED, mouseDrag);
System.out.println("createNewCard(): Setting card location..");
card.setLayoutY(locationY);
System.out.println("createNewCard(): Setting card color...");
if (cardName.endsWith("H") || cardName.endsWith("D")) {
card.setIsRed(true);
} else if (cardName.endsWith("S") || cardName.endsWith("C")) {
card.setIsBlack(true);
}
System.out.println("createNewCard(): Returning card...");
return card;
}
private boolean acceptKing(Card topCard, Card sourceCard, Pane targetPane) {
boolean success = false;
Card card = new Card();
if (sourceCard.getName().substring(0, 1).equals("K")) {
System.out.println("acceptKing()[Accepted, this is a " + sourceCard.getName().substring(0, 1) + "]");
card = createNewCard(sourceCard.getName());
targetPane.getChildren().add(card);
success = true;
}
return success;
}
private boolean acceptAce(Card topCard, Card sourceCard, Pane targetPane) {
boolean success = false;
Card card = new Card();
if (targetPane.getChildren().isEmpty()) {
System.out.println("acceptAce()[Pane is empty]");
if (sourceCard.getName().substring(0, 1).equals("A")) {
System.out.println("acceptAce()[This is Ace]");
card = createNewCard(sourceCard.getName());
targetPane.getChildren().add(card);
success = true;
}
} else {
System.out.println("acceptAce()[Not Ace]");
SolitaireRule solRule = new SolitaireRule();
if (solRule.foundationRank(sourceCard.getName(), topCard.getName())) {
card = createNewCard(sourceCard.getName());
targetPane.getChildren().add(card);
success = true;
}
}
return success;
}
private double getLocationY(Pane targetPane) {
double returnLocation = 0.0;
double layoutY = 0.0;
// Get the y location and the last card of the last index
if (!tempPane.getChildren().isEmpty()) {
for (Node children : targetPane.getChildren()) {
layoutY = children.getLayoutY();
}
}
// Check if the target pane is empty, if true
// set the location of y to 0 else add 30
if (targetPane.getChildren().isEmpty()) {
returnLocation = 0;
} else if (targetPane == tempPane) {
returnLocation = layoutY;
} else {
returnLocation = layoutY + 30;
}
return returnLocation;
}
private Card getTargetTopCard(Pane targetPane) {
Card topCard = null;
// Get the y location and the last card of the last index
if (!tempPane.getChildren().isEmpty()) {
for (Node children : targetPane.getChildren()) {
topCard = (Card) children;
}
}
return topCard;
}
}

The error has nothing to do with events.
If you check the code you have commented out:
cardList.stream().forEach((sourceCard) -> {
dragDone(sourceCard);
});
it contains stream, and since JavaFXPorts is running on Android/iOS with Java 7 versions, Java 8 streams are not supported yet. Lambda expressions are supported, though, thanks to the retrolambda project.
Use an old for-nested loop instead.
If you really need full support for Streams, you may have a look at the streamsupport project. Also Android N will support streams and other Java 8 features as well, but it is still in preview.

Related

Getting Randomly Error:Caused by: org.hibernate.ObjectNotFoundException: No row with the given identifier exists:

In my program code and entity are working fine, but randomly at any point of time this error comes.
If i restart the server's it starts working but after some days again same issue is coming.
Below are the log scripts of the error:
com.pb.gpp.backoffice.job.Exception.GPPBackOfficeException: Error occured during select operation in following method and tablegetFileTypeDetail, transactionfiletype and transactionfiledetail
at com.pb.gcs.backoffice.transaction.controller.DaoImpl.getFileTypeDetail(DaoImpl.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy178.getFileTypeDetail(Unknown Source)
at com.pb.gcs.backoffice.transaction.filecreate.writer.TransactionFileWriter.getCompletePath(TransactionFileWriter.java:178)
at com.pb.gcs.backoffice.transaction.filecreate.writer.TransactionFileWriter.initializeItemWriter(TransactionFileWriter.java:163)
at com.pb.gcs.backoffice.transaction.filecreate.writer.TransactionFileWriter.beforeStep(TransactionFileWriter.java:61)
... 16 more
Caused by: org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.pb.gcs.backoffice.transaction.model.configuration.TransactionfiledetailEntity#311]
at org.hibernate.internal.SessionFactoryImpl$1$1.handleEntityNotFound(SessionFactoryImpl.java:244)
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:212)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:262)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:150)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1098)
at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:1025)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:671)
at org.hibernate.type.EntityType.resolve(EntityType.java:489)
at org.hibernate.type.ComponentType.resolve(ComponentType.java:667)
at org.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:349)
at org.hibernate.type.ManyToOneType.hydrate(ManyToOneType.java:190)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2926)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1673)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1605)
at org.hibernate.loader.Loader.getRow(Loader.java:1505)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:713)
at org.hibernate.loader.Loader.processResultSet(Loader.java:943)
at org.hibernate.loader.Loader.doQuery(Loader.java:911)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(
public FileTypeDetail getFileTypeDetail(String partnerId, String carrier) throws GPPBackOfficeException {
try {
Session session = configurationSessionFactory.getCurrentSession();
session.clear();
String query = " Select tft.*, tfd.*" +
"from transactionfiletype tft " +
"join transactionfiledetail tfd " +
"on tft.filetype=tfd.filetype " +
"where tfd.activeflag=1 and tfd.filetype ='transactionfile' and tfd.partnerid =:partnerId and tfd.carrier =:carrier";
Query queryFileTypeMapping = session.createSQLQuery(query)
.addEntity("transactionfiletype", TransactionfiletypeEntity.class)
.addEntity("transactionfiledetail", TransactionfiledetailEntity.class);
queryFileTypeMapping.setParameter("partnerId", partnerId);
queryFileTypeMapping.setParameter("carrier", carrier);
List<Object[]> resultList = queryFileTypeMapping.list();
session.flush();
List<FileTypeDetail> fileTypeDetailList = new ArrayList<FileTypeDetail>();
FileTypeDetail fileTypeDetail;
for (Object[] fileDetail : resultList) {
fileTypeDetail = new FileTypeDetail();
fileTypeDetail.setTransactionfiletypeEntity((TransactionfiletypeEntity) fileDetail[0]);
fileTypeDetail.setTransactionfiledetailEntity((TransactionfiledetailEntity) fileDetail[1]);
fileTypeDetailList.add(fileTypeDetail);
}
return fileTypeDetailList.get(0);
} catch (Exception ex) {
GPPBackOfficeException gppBackOfficeException = new GPPBackOfficeException(Constants.SYSTEM_PREFIX, Constants.ERROR_CODE_0019, helper.getExceptionInfo(Constants.SYSTEM_PREFIX, Constants.ERROR_CODE_0019).getErrorclientmessage()
+ "getFileTypeDetail, transactionfiletype and transactionfiledetail", ex);
throw gppBackOfficeException;
}
}

ASM - java.lang.VerifyError: Operand stack overflow Exception

I am using ASM 5.0.3 byte code library with Tomcat 8 and JDK 8.
Also I am using
ClassWriter classWriter = new ClassWriter(classReader, ClassWriter.COMPUTE_FRAMES);
and
classReader.accept(myClassVisitor, ClassReader.SKIP_FRAMES);
Below exception is thrown by ASM
Caused by: java.lang.VerifyError: Operand stack overflow
Exception Details:
Location: org/apache/tomcat/websocket/server/WsServerContainer.addEndpoint(Ljavax/websocket/server/ServerEndpointConfig;)V #0: aload_0
Reason:
Exceeded max stack size.
Current Frame:
bci: #0
flags: { }
locals: { 'org/apache/tomcat/websocket/server/WsServerContainer', 'javax/websocket/server/ServerEndpointConfig' }
stack: { }
Bytecode:
0x0000000: 2ab4 000a 9900 1a2a b400 0b9a 0013 bb01
0x0000010: 3d59 b200 4412 45b6 0046 b700 47bf 2ab4
0x0000020: 000e c700 13bb 0043 59b2 0044 1248 b600
0x0000030: 46b7 0047 bf2b b900 4901 004d bb00 4a59
0x0000040: 2bb9 004b 0100 2bb9 004c 0100 2cb7 004d
0x0000050: 4e2d b600 4ec7 0018 2db6 004f c700 112d
0x0000060: b600 50c7 000a 2db6 0051 9900 122b b900
0x0000070: 5201 0012 532d b900 5403 0057 bb00 5559
0x0000080: 2cb7 0056 3a04 1904 b600 5799 0087 1904
0x0000090: b600 58b8 0059 3a05 2ab4 0008 1905 b600
0x00000a0: 5ac0 005b 3a06 1906 c700 29bb 005c 59b8
0x00000b0: 005d b700 5e3a 062a b400 0819 0519 06b6
0x00000c0: 005f 572a b400 0819 05b6 005a c000 5b3a
0x00000d0: 0619 06bb 0060 592b 1904 b700 61b9 0062
0x00000e0: 0200 9a00 2dbb 0043 59b2 0044 1263 06bd
0x00000f0: 0064 5903 2c53 5904 2bb9 004b 0100 5359
0x0000100: 052b b900 4b01 0053 b600 65b7 0047 bfa7
0x0000110: 0043 2ab4 0007 2c2b b900 5403 00c0 0066
0x0000120: 3a05 1905 c600 2ebb 0043 59b2 0044 1263
0x0000130: 06bd 0064 5903 2c53 5904 1905 b900 4b01
0x0000140: 0053 5905 2bb9 004b 0100 53b6 0065 b700
0x0000150: 47bf 2a04 b500 0db1
at org.apache.tomcat.websocket.server.WsSci.init(WsSci.java:131)
at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:47)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5244)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
How to resolve this issue without using -noverify option?
Edit #1: I also tried using simply COMPUTE_FRAMES as in:
ClassWriter classWriter = new ClassWriter(classReader, ClassWriter.COMPUTE_FRAMES);
and I omitted the below SKIP_FRAMES statement:
//classReader.accept(myClassVisitor, ClassReader.SKIP_FRAMES);
I continue to get the same "Caused by: java.lang.VerifyError: Operand stack overflow" error.
Edit #2: I have tried all of the following combinations and am getting the same error: java.lang.VerifyError: Operand stack overflow Reason:Exceeded max stack size.
ClassWriter.COMPUTE_FRAMES with ClassReader.EXPAND_FRAMES and mv.visitMaxs(maxStack, maxLocals);
ClassWriter.COMPUTE_FRAMES with ClassReader.EXPAND_FRAMES and mv.visitMaxs(-1, -1);
ClassWriter.COMPUTE_FRAMES with ClassReader.SKIP_FRAMES and mv.visitMaxs(maxStack, maxLocals);
ClassWriter.COMPUTE_FRAMES with ClassReader.SKIP_FRAMES and mv.visitMaxs(-1, -1);
Edit #3. Here is my Advice adapter code
public class PojoMethodAdviceAdapter extends AdviceAdapter {
private String methodName;
private String className;
private String description;
private boolean excludeCheckFlag = false;
private int okFlag = newLocal(Type.getType("Z")); //newLocal(Type.BOOLEAN_TYPE);
private int classFileVersion;
Label startFinally = new Label();
private static Hashtable excludeMethods = new Hashtable();
private static final String yesString = "Yes";
private boolean isValid;
static{
excludeMethods.put("<clinit>", yesString);
excludeMethods.put("<init>", yesString);
}
public PojoMethodAdviceAdapter(int access , MethodVisitor mv , String methodName, String description, String className, int classFileVersion){
super(Opcodes.ASM5 , mv, access, methodName, description);
this.className = className;
this.methodName = methodName;
this.description = description;
this.excludeCheckFlag = true;
this.isValid = true;
this.classFileVersion = classFileVersion;
String yesStr = (String)excludeMethods.get(this.methodName);
if(yesStr!=null && yesStr.equals(yesString))
isValid = false;
if(this.methodName.indexOf("$") > 0)
isValid = false;
if(isValid){
System.out.println(" [POJO MethodAdviceAdapter] :"+className+" \t "+methodName +" \t "+description);
}
}
public void visitCode() {
super.visitCode();
mv.visitLabel(startFinally);
}
protected void onMethodEnter(){
if(isValid) {
mv.visitInsn(Opcodes.ICONST_0);
mv.visitVarInsn(ISTORE, okFlag);
mv.visitLdcInsn(className);
mv.visitLdcInsn(methodName);
mv.visitLdcInsn(description);
mv.visitMethodInsn(Opcodes.INVOKESTATIC, "com/mini/agent/trace/RootTracer", "pojoMethodBegin", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z", false);
mv.visitVarInsn(ISTORE, okFlag);
}
}
protected void onMethodExit(int opcode){
if(opcode!=ATHROW) {
onFinally(opcode);
}
}
public void visitMaxs(int maxStack, int maxLocals){
Label endFinally = new Label();
mv.visitTryCatchBlock(startFinally, endFinally, endFinally, null);
mv.visitLabel(endFinally);
onFinally(ATHROW);
mv.visitInsn(ATHROW);
if(classFileVersion <= 50){
mv.visitMaxs(maxStack, maxLocals);
}
else{
mv.visitMaxs(0, 0);
}
}
private void onFinally(int opcode){
if(isValid){
if(opcode == ATHROW){
mv.visitInsn(Opcodes.DUP);
mv.visitLdcInsn(className);
mv.visitLdcInsn(methodName);
mv.visitLdcInsn(description);
mv.visitVarInsn(ILOAD, okFlag);
mv.visitMethodInsn(Opcodes.INVOKESTATIC, "com/mini/agent/trace/RootTracer", "recordPOJOException", "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V", false);
}
mv.visitLdcInsn(className);
mv.visitLdcInsn(methodName);
mv.visitLdcInsn(description);
mv.visitVarInsn(ILOAD, okFlag);
mv.visitLdcInsn(opcode);
mv.visitMethodInsn(Opcodes.INVOKESTATIC, "com/mini/agent/trace/RootTracer", "pojoMethodEnd", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZI)V", false);
}
}
}
Try using the TraceClassVisitor to see where it is getting messed up. In my experience this happens when a Label is written incorrectly, forcing it to write jsr/ret instructions (the JVM should simply reject the class in that case though along with asm crashing when calculating frames), and most often, forgetting to call visitMaxs in the methodVisitor before calling visitEnd. In my code I'm using
visitMaxs(mv.getMaxLocals(),mv.getMaxLocals());
I don't remember what my reasoning for doing that was but my ClassWriter works when I do, but I hope this helps.

Could not synchronize database state with session org.hibernate.exception.LockAcquisitionException: could not update:

Hi I am getting the error in the logs, please let me know hwat is wrong with session.
[9/17/15 12:49:12:127 BST] 00000015 SystemOut O 2015-09-17 12:49:12 WARN JDBCExceptionReporter:100 - SQL Error: -911, SQLState: 40001
[9/17/15 12:49:12:128 BST] 00000015 SystemOut O 2015-09-17 12:49:12 ERROR JDBCExceptionReporter:101 - DB2 SQL Error: SQLCODE=-911, SQLSTATE=40001, SQLERRMC=2, DRIVER=3.58.81
[9/17/15 12:49:12:136 BST] 00000015 SystemOut O 2015-09-17 12:49:12 ERROR AbstractFlushingEventListener:324 - Could not synchronize database state with session
org.hibernate.exception.LockAcquisitionException: could not update: [*********]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:105)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2443)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2325)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2625)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:115)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
at com.persistance.ApplicationDAOImpl.getUniqueId(ApplicationDAOImpl.java:573)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy52.getCapeUniqueId(Unknown Source)
at com.util.CapeSequenceGenerator.getCapeUniqueId(SequenceGenerator.java:32)
at com..serviceimpl.CreditApplicationServiceImpl.processAppMessage(ApplicationServiceImpl.java:148)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
Caused by:
com.ibm.db2.jcc.am.to: DB2 SQL Error: SQLCODE=-911, SQLSTATE=40001, SQLERRMC=2, DRIVER=3.58.81
at com.ibm.db2.jcc.am.ed.a(ed.java:663)
at com.ibm.db2.jcc.am.ed.a(ed.java:60)
at com.ibm.db2.jcc.am.ed.a(ed.java:127)
at com.ibm.db2.jcc.am.tm.c(tm.java:2523)
at com.ibm.db2.jcc.t4.fb.s(fb.java:940)
at com.ibm.db2.jcc.t4.fb.k(fb.java:390)
at com.ibm.db2.jcc.t4.fb.a(fb.java:61)
at com.ibm.db2.jcc.t4.t.a(t.java:50)
at com.ibm.db2.jcc.t4.vb.b(vb.java:218)
at com.ibm.db2.jcc.am.um.jc(um.java:2860)
at com.ibm.db2.jcc.am.um.b(um.java:3795)
at com.ibm.db2.jcc.am.um.ac(um.java:709)
at com.ibm.db2.jcc.am.um.executeUpdate(um.java:692)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteUpdate(WSJdbcPreparedStatement.java:1185)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeUpdate(WSJdbcPreparedStatement.java:802)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:46)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2421)
... 45 more
Below is my code which is causing the above error
Criteria criteria = session.createCriteria(Sequence.class);
List capeSequence = criteria.list();
for (Iterator iterator = capeSequence.iterator(); iterator.hasNext();) {
Sequence uniqueSequence = (Sequence)iterator.next();
existingId = uniqueSequence.getSequence();
minVal = uniqueSequence.getMinVal();
maxVal = uniqueSequence.getMaxVal();
}
if (existingId == maxVal) {
existingId = minVal;
} else {
existingId = existingId+1;
}
Sequence eequenceObj = (CSequence) session.get(Sequence.class, SEQUENCE_NAME, LockMode.UPGRADE);
SequenceObj.setSequence(existingId);
session.update(capeSequenceObj);
session.flush();

Hive Odbc "Error from Hive: ETIMEDOUT"

Getting error while connecting to hiveserver2
Hive server 2 & hadoop is up and running in my local machine
Trying the below code
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
Connection con = DriverManager.getConnection("jdbc:odbc://dsn=hello;driver=Microsoft Hive ODBC Driver;Host=127.0.0.1;Port=5000;HiveServerType=2;AuthMech=0");
Statement stmt = con.createStatement();
ResultSet res = stmt.executeQuery("SHOW TABLES");
ResultSetMetaData rsmdData = res.getMetaData();
int count = rsmdData.getColumnCount();
while (res.next()) {
for (int i = 1; i <= count; i++) {
System.out.print(res.getString(i) + "\t");
}
System.out.println();
}
I am getting the below error
Exception in thread "main" java.sql.SQLException: [Microsoft][HiveODBC] (34) Error from Hive: ETIMEDOUT.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at hivedev.HiveODBC.main(HiveODBC.java:20)
However I am able to connect through beeline cli

MDB stop working after this exception

I have an enterprise event-driven application.
I have 16 MDBs that read from a JMS queue. When I got some uncontrolled exceptions I receive this stack :
####<Apr 18, 2011 11:47:15 AM CEST> <Error> <WebLogicServer> <sapmop11> <cont0Server11> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1303120035886> <BEA-000337> <[STUCK] ExecuteThread: '8' for queue: 'weblogic.kernel.Default (self-tuning)' h
as been busy for "647" seconds working on the request "weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl#16b13f90", which is more than the configured time (StuckThreadMaxTime) of "600" seconds. Stack trace:
java.lang.Thread.sleep(Native Method)
weblogic.ejb.container.internal.JMSPollerManager.waitForPollersToStop(JMSPollerManager.java:82)
weblogic.ejb.container.internal.JMSConnectionPoller.waitForMessagePollerExit(JMSConnectionPoller.java:795)
weblogic.ejb.container.internal.JMSConnectionPoller.disconnect(JMSConnectionPoller.java:920)
weblogic.ejb.container.internal.MDConnectionManager.timerExpired(MDConnectionManager.java:166)
weblogic.timers.internal.TimerImpl.run(TimerImpl.java:273)
weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
>
####<Apr 18, 2011 11:48:15 AM CEST> <Error> <WebLogicServer> <sapmop11> <cont0Server11> <[ACTIVE] ExecuteThread: '9' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1303120095935> <BEA-000337> <[STUCK] ExecuteThread: '8' for queue: 'weblogic.kernel.Default (self-tuning)' h
as been busy for "707" seconds working on the request "weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl#16b13f90", which is more than the configured time (StuckThreadMaxTime) of "600" seconds. Stack trace:
java.lang.Thread.sleep(Native Method)
weblogic.ejb.container.internal.JMSPollerManager.waitForPollersToStop(JMSPollerManager.java:82)
weblogic.ejb.container.internal.JMSConnectionPoller.waitForMessagePollerExit(JMSConnectionPoller.java:795)
weblogic.ejb.container.internal.JMSConnectionPoller.disconnect(JMSConnectionPoller.java:920)
weblogic.ejb.container.internal.MDConnectionManager.timerExpired(MDConnectionManager.java:166)
weblogic.timers.internal.TimerImpl.run(TimerImpl.java:273)
weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
>
After this all the MDBs stop reading from the queue and the application need to be restarted.
This is the MDB onMessage code:
#Override
#TransactionAttribute(TransactionAttributeType.REQUIRED)
public void onMessage(Message message) {
OnlineEventMessage<? extends Serializable> eventMessage = null;
try {
TextMessage textMessage = (TextMessage) message;
String stringMessage = textMessage.getText();
logger.debug("e' stato ricevuto il messaggio {}", stringMessage);
logger.debug("eventMessageParser {}", onlineEventMessageParser);
logger.debug("legacyEventMessageService {}", legacyEventMessageService);
EventMessageAnagrafica anagrafica = anagraficaParser.parse(stringMessage, true);
String multichannelId = anagrafica.getMultichannelId();
eventMessage = onlineEventMessageParser.parse(stringMessage, true);
MDC.put("multichannelId", multichannelId);
MDC.put("eventType", eventMessage.getEventType().getEventCode());
legacyEventMessageService.handle(eventMessage);
} catch (JMSException e) {
retryJmsTemplate.send(destination, new RedeliveryMessageCreatorUtil(message));
logger.error("si e' verificato un errore JMS nel processamento dell'evento {}, riaccodamento in corso...", e);
} catch (RuntimeException e) {
logger.error("si e' verificata una runtime exception per il messaggio {}", e);
legacyErrorHandlerService.handle(eventMessage);
} catch (Exception e) {
logger.error("si e' verificato un errore inaspettato per il messaggio {}", e);
if (eventMessage != null && eventMessage.getIdEventMessage() != null) {
logger.error("Il messaggio gia' presente nelle catene di elaborazione");
OnlineEventMessage<?> onlineMessage = eventMessageDao.getItemByID(eventMessage.getIdEventMessage());
if (onlineMessage != null) {
onlineMessage.setEventState(EventState.PROCESSING_ERROR);
eventMessageDao.updateItem(onlineMessage);
eventMessageDao.flush();
}
}
context.setRollbackOnly();
}
}
Any idea?
Kind regards
Massimo
This seems like a transaction issue. Try taking a Thread Dump next time this happens and take a look at what the threads are doing. You can do this through the Admin Console.

Resources