mercredi 5 août 2015

java.lang.IllegalArgumentException: Can not handle managed/back reference


I am having the following entity relationship

@Entity
@Table(name = "PRODUCTS")
public class Product implements Serializable {

@Id
@Column(name = "prod_id", nullable = false)
private String prodId;

@Column(name = "prod_name")
private String prodName;

@JsonManagedReference("prods")
@ManyToOne
@JoinColumn(name = "prod_id", referencedColumnName = "prod_id")
private ProductDetail productDetail;

@Entity
@Table(name = "PRODUCT_DETAILS")
public class ProductDetail implements Serializable {

@Id
@Column(name="prod_id", nullable = false)
private String prodId;

@JsonBackReference("prods")
@OneToMany(mappedBy = "productDetail")
private List<Product> productList;

And in REST service, I have

@PUT
@Produces(MediaType.APPLICATION_JSON)
@Path("/mypath")
public Object update(Product product)  {
    System.out.println("params "+product.getProdName());
    return json;
}   

When I invoke update method using REST, I am getting error

java.lang.IllegalArgumentException: Can not handle managed/back reference 'prods': back reference type (java.util.List) not compatible with managed type (test.entity.Product)

How can I resolve this issue?

Edit 1

I have tried using

@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
property="prodId")

However this resulted in the following error

org.codehaus.jackson.map.JsonMappingException: Infinite recursion (StackOverflowError) (through reference chain:



via Chebli Mohamed

java applet slow on window 7 (64bit) machine


I am running java applet on windows 7 64bit (firefox 39.0). It take 10 second to load(showing java process icon meanwhile ) where as it take 1 second to run on window 8 64bit machine(firefox 39.0). it's also fine on 32(bit) window 7.

Why it is slow on window 7(64bit).



via Chebli Mohamed

jar not launching - UnsatisfiedLinkError


I have exported my java project into a jar in my desktop (chose the option that creates a project.jar and a project_lib).

When I run java -jar project.jar on cmd, I get this exception:

    Exception in thread "main" java.lang.RuntimeException: Application launch error
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:122)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.UnsatisfiedLinkError: com.sun.glass.ui.win.WinApplication._invokeLater(Ljava/lang/Runnable;)V
    at com.sun.glass.ui.win.WinApplication._invokeLater(Native Method)
    at com.sun.glass.ui.Application.invokeLater(Application.java:338)
    at com.sun.javafx.tk.quantum.QuantumToolkit.defer(QuantumToolkit.java:620)
    at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:173)
    at com.sun.javafx.application.PlatformImpl.runAndWait(PlatformImpl.java:212)
    at com.sun.javafx.application.PlatformImpl.tkExit(PlatformImpl.java:320)
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:421)
    at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
    ... 1 more

I guess it is probably caused by my project's paths but I don't know how to fix this.

EDIT: It works fine in eclipse and in my /Desktop directory. Everywhere else, this exception is thrown.

EDIT2: This is the MANIFEST.MF file built:

Manifest-Version: 1.0
Class-Path: . wfmgr_lib/jfxrt.jar wfmgr_lib/junit.jar wfmgr_lib/org.ha
 mcrest.core_1.3.0.v201303031735.jar wfmgr_lib/gson-2.3.1.jar
Main-Class: main.screens.ScreenFramework

EDIT3: I have both jdk 7 and 8 installed. I set up my eclipse project so its compliance level is java-7, building compatible code for the latter.

I also tried using launcher4J and it only worked (in any directory) with the following configurations:

launch4J.log:

    Version:    3.8
    CmdLine:    C:\Users\a51217\Desktop\wfmgr_final\wfmgrexe.exe --l4j-debug
    WOW64:      yes
    Working dir:    C:\Users\a51217\Desktop\wfmgr_final\.
    Bundled JRE:    C:\Program Files\Java\jre7
    Check launcher: C:\Program Files\Java\jre7\bin\javaw.exe (OK)
    Substitute: PATH = C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\AXALTO\Access Client\v5\;C:\Program Files (x86)\AXALTO\Access Client\v5\;C:\Program Files (x86)\Common Files\Check Point\UIFramework 3.0\Bin\;C:\Program Files (x86)\CheckPoint\Endpoint Security\Endpoint Common\bin;C:\Users\a51217\Downloads\jdk-8u51\bin;C:\Users\a51217\Downloads\mysql-5.6.25-winx64\mysql-5.6.25-winx64/bin;C:\Users\a51217\Downloads\apache-tomcat-8.0.24\apache-tomcat-8.0.24\bin;C:\Users\a51217\Downloads\apache-maven-3.3.3-bin\apache-maven-3.3.3\bin;C:\Program Files\Java\jre7\bin;C:\Program Files\Java\jre7\bin
    Substitute: JAVA_HOME = C:\Users\a51217\Downloads\jdk-8u51
    Substitute: C:\Program Files\Java\jre7\lib\jfxrt.jar = 
    Add classpath:  .
    Add classpath:  wfmgr_lib\jfxrt.jar
    Add classpath:  wfmgr_lib\junit.jar
    Add classpath:  wfmgr_lib\org.hamcrest.core_1.3.0.v201303031735.jar
    Add classpath:  C:\Program Files\Java\jre7\lib
    Add classpath:  C:\Program Files\Java\jre7\bin
    Launcher:   C:\Program Files\Java\jre7\bin\javaw.exe
    Launcher args:  -Denv.path="C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\AXALTO\Access Client\v5\;C:\Program Files (x86)\AXALTO\Access Client\v5\;C:\Program Files (x86)\Common Files\Check Point\UIFramework 3.0\Bin\;C:\Program Files (x86)\CheckPoint\Endpoint Security\Endpoint Common\bin;C:\Users\a51217\Downloads\jdk-8u51\bin;C:\Users\a51217\Downloads\mysql-5.6.25-winx64\mysql-5.6.25-winx64/bin;C:\Users\a51217\Downloads\apache-tomcat-8.0.24\apache-tomcat-8.0.24\bin;C:\Users\a51217\Downloads\apache-maven-3.3.3-bin\apache-maven-3.3.3\bin;C:\Program Files\Java\jre7\bin;C:\Program Files\Java\jre7\bin" -Denv.java.home="C:\Users\a51217\Downloads\jdk-8u51" -Denv.c:\program.files\java\jre7\lib\jfxrt.jar="" -classpath "C:\Users\a51217\Desktop\wfmgr_final\wfmgrexe.exe;.;wfmgr_lib\jfxrt.jar;wfmgr_lib\junit.jar;wfmgr_lib\org.hamcrest.core_1.3.0.v201303031735.jar;C:\Program Files\Java\jre7\lib;C:\Program Files\Java\jre7\bin" main.screens.ScreenFramework
    Args length:    1008/32768 chars
    Exit code:  0


    Version:    3.8
    CmdLine:    C:\Users\a51217\Desktop\wfmgr_final\wfmgrexe.exe --l4j-debug
    WOW64:      yes
    Working dir:    C:\Users\a51217\Desktop\wfmgr_final\.
    Bundled JRE:    C:\Program Files\Java\jre7
    Check launcher: C:\Program Files\Java\jre7\bin\javaw.exe (OK)
    Substitute: PATH = C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\AXALTO\Access Client\v5\;C:\Program Files (x86)\AXALTO\Access Client\v5\;C:\Program Files (x86)\Common Files\Check Point\UIFramework 3.0\Bin\;C:\Program Files (x86)\CheckPoint\Endpoint Security\Endpoint Common\bin;C:\Users\a51217\Downloads\jdk-8u51\bin;C:\Users\a51217\Downloads\mysql-5.6.25-winx64\mysql-5.6.25-winx64/bin;C:\Users\a51217\Downloads\apache-tomcat-8.0.24\apache-tomcat-8.0.24\bin;C:\Users\a51217\Downloads\apache-maven-3.3.3-bin\apache-maven-3.3.3\bin;C:\Program Files\Java\jre7\bin;C:\Program Files\Java\jre7\bin
    Substitute: JAVA_HOME = C:\Users\a51217\Downloads\jdk-8u51
    Substitute: C:\Program Files\Java\jre7\lib\jfxrt.jar = 
    Add classpath:  .
    Add classpath:  wfmgr_lib\jfxrt.jar
    Add classpath:  wfmgr_lib\junit.jar
    Add classpath:  wfmgr_lib\org.hamcrest.core_1.3.0.v201303031735.jar
    Add classpath:  C:\Program Files\Java\jre7\lib
    Add classpath:  C:\Program Files\Java\jre7\bin
    Launcher:   C:\Program Files\Java\jre7\bin\javaw.exe
    Launcher args:  -Denv.path="C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\AXALTO\Access Client\v5\;C:\Program Files (x86)\AXALTO\Access Client\v5\;C:\Program Files (x86)\Common Files\Check Point\UIFramework 3.0\Bin\;C:\Program Files (x86)\CheckPoint\Endpoint Security\Endpoint Common\bin;C:\Users\a51217\Downloads\jdk-8u51\bin;C:\Users\a51217\Downloads\mysql-5.6.25-winx64\mysql-5.6.25-winx64/bin;C:\Users\a51217\Downloads\apache-tomcat-8.0.24\apache-tomcat-8.0.24\bin;C:\Users\a51217\Downloads\apache-maven-3.3.3-bin\apache-maven-3.3.3\bin;C:\Program Files\Java\jre7\bin;C:\Program Files\Java\jre7\bin" -Denv.java.home="C:\Users\a51217\Downloads\jdk-8u51" -Denv.c:\program.files\java\jre7\lib\jfxrt.jar="" -classpath "C:\Users\a51217\Desktop\wfmgr_final\wfmgrexe.exe;.;wfmgr_lib\jfxrt.jar;wfmgr_lib\junit.jar;wfmgr_lib\org.hamcrest.core_1.3.0.v201303031735.jar;C:\Program Files\Java\jre7\lib;C:\Program Files\Java\jre7\bin" main.screens.ScreenFramework
    Args length:    1008/32768 chars
    Exit code:  0


    Version:    3.8
    CmdLine:    C:\Users\a51217\Desktop\wfmgr_final\wfmgrexe.exe --l4j-debug
    WOW64:      yes
    Working dir:    C:\Users\a51217\Desktop\wfmgr_final\.
    Bundled JRE:    C:\Program Files\Java\jre7
    Check launcher: C:\Program Files\Java\jre7\bin\javaw.exe (OK)
    Substitute: PATH = C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\AXALTO\Access Client\v5\;C:\Program Files (x86)\AXALTO\Access Client\v5\;C:\Program Files (x86)\Common Files\Check Point\UIFramework 3.0\Bin\;C:\Program Files (x86)\CheckPoint\Endpoint Security\Endpoint Common\bin;C:\Users\a51217\Downloads\jdk-8u51\bin;C:\Users\a51217\Downloads\mysql-5.6.25-winx64\mysql-5.6.25-winx64/bin;C:\Users\a51217\Downloads\apache-tomcat-8.0.24\apache-tomcat-8.0.24\bin;C:\Users\a51217\Downloads\apache-maven-3.3.3-bin\apache-maven-3.3.3\bin;C:\Program Files\Java\jre7\bin;C:\Program Files\Java\jre7\bin
    Substitute: JAVA_HOME = C:\Users\a51217\Downloads\jdk-8u51
    Substitute: C:\Program Files\Java\jre7\lib\jfxrt.jar = 
    Add classpath:  .
    Add classpath:  wfmgr_lib\jfxrt.jar
    Add classpath:  wfmgr_lib\junit.jar
    Add classpath:  wfmgr_lib\org.hamcrest.core_1.3.0.v201303031735.jar
    Add classpath:  C:\Program Files\Java\jre7\lib
    Add classpath:  C:\Program Files\Java\jre7\bin
    Add classpath:  C:\Program Files\Java\jre7\lib\jfxrt.jar
    Launcher:   C:\Program Files\Java\jre7\bin\javaw.exe
    Launcher args:  -Denv.path="C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\AXALTO\Access Client\v5\;C:\Program Files (x86)\AXALTO\Access Client\v5\;C:\Program Files (x86)\Common Files\Check Point\UIFramework 3.0\Bin\;C:\Program Files (x86)\CheckPoint\Endpoint Security\Endpoint Common\bin;C:\Users\a51217\Downloads\jdk-8u51\bin;C:\Users\a51217\Downloads\mysql-5.6.25-winx64\mysql-5.6.25-winx64/bin;C:\Users\a51217\Downloads\apache-tomcat-8.0.24\apache-tomcat-8.0.24\bin;C:\Users\a51217\Downloads\apache-maven-3.3.3-bin\apache-maven-3.3.3\bin;C:\Program Files\Java\jre7\bin;C:\Program Files\Java\jre7\bin" -Denv.java.home="C:\Users\a51217\Downloads\jdk-8u51" -Denv.c:\program.files\java\jre7\lib\jfxrt.jar="" -classpath "C:\Users\a51217\Desktop\wfmgr_final\wfmgrexe.exe;.;wfmgr_lib\jfxrt.jar;wfmgr_lib\junit.jar;wfmgr_lib\org.hamcrest.core_1.3.0.v201303031735.jar;C:\Program Files\Java\jre7\lib;C:\Program Files\Java\jre7\bin;C:\Program Files\Java\jre7\lib\jfxrt.jar" main.screens.ScreenFramework
    Args length:    1049/32768 chars
    Exit code:  0

image4j.xml

<?xml version="1.0" encoding="UTF-8"?>
-<launch4jConfig> <dontWrapJar>false</dontWrapJar> <headerType>gui</headerType> <jar>C:\Users\a51217\Desktop\wfmgr.jar</jar> <outfile>C:\Users\a51217\Desktop\wfmgr_final\wfmgrexe.exe</outfile> <errTitle/> <cmdLine/> <chdir>.</chdir> <priority>normal</priority> <downloadUrl>http://ift.tt/KJJukw; <supportUrl/> <stayAlive>false</stayAlive> <restartOnCrash>false</restartOnCrash> <manifest/> <icon/> -<classPath> <mainClass>main.screens.ScreenFramework</mainClass> <cp>.</cp> <cp>wfmgr_lib/jfxrt.jar</cp> <cp>wfmgr_lib/junit.jar</cp> <cp>wfmgr_lib/org.hamcrest.core_1.3.0.v201303031735.jar</cp> <cp>C:\Program Files\Java\jre7\lib</cp> <cp>C:\Program Files\Java\jre7\bin</cp> <cp>C:\Program Files\Java\jre7\lib\jfxrt.jar</cp> </classPath> -<jre> <path>C:\Program Files\Java\jre7</path> <bundledJre64Bit>true</bundledJre64Bit> <bundledJreAsFallback>false</bundledJreAsFallback> <minVersion>1.6.0</minVersion> <maxVersion>1.9.0</maxVersion> <jdkPreference>preferJre</jdkPreference> <runtimeBits>64/32</runtimeBits> <opt>-Denv.path="%PATH%"</opt> <opt>-Denv.java.home="%JAVA_HOME%"</opt> <opt>-Denv.c:\program.files\java\jre7\lib\jfxrt.jar="%C:\Program Files\Java\jre7\lib\jfxrt.jar%"</opt> </jre> -<messages> <startupErr>An error occurred while starting the application.</startupErr> <bundledJreErr>This application was configured to use a bundled Java Runtime Environment but the runtime is missing or corrupted.</bundledJreErr> <jreVersionErr>This application requires a Java Runtime Environment</jreVersionErr> <launcherErr>The registry refers to a nonexistent Java Runtime Environment installation or the runtime is corrupted.</launcherErr> <instanceAlreadyExistsMsg>An application instance is already running.</instanceAlreadyExistsMsg> </messages> </launch4jConfig>



via Chebli Mohamed

What happens to an event and the memory it uses when it's fired an no handler is registered?


What happens to a Reactor-EventBus event and especially the memory itself and its data payload use when it's fired and there's no handler registered?

Is it going to be disposed? Or will those Event objects be collected in the ringbuffer?

My guess is that it will be disposed, but I'd like to be sure about that.



via Chebli Mohamed

Cut string inside " "


Suppose i have a

  string [] tag;

Lets say

 for tag[0] = {["I","am","fine","thank","you"]}
     tag[1] = {["hello","world"]}

how can i get all string out from the above string?? i wanna get "I" , "hello" individually

also as a newbie, wanna know how can i display "
when i type " " " error appears



via Chebli Mohamed

Silently stopping Liquibase at mid-update


Is there any way I can cancel a Liquibase update after I started it?

I've a list with around 5000 changesets, and I need to prevent all changesets from a specific point forward, to not be executed if a specific condition occurs in one of those scripts.

Since putting < preConditions > in all of the existing scripts, and to all the new ones that will be created until the end of days, is not a doable approach, I was looking into an alternative and already tried the following:

  • Created a < customChange > and throw an exception
  • Created an invalid < sql > statement
  • Added < stop /> in the < changeset >

All cases work, but they also throw thousands of log lines (that I can't have), because I need a silent stop.



via Chebli Mohamed

Java: Using created string as loop parameter?


In short, the user will input a number (say 1 through 3). This will decide which range of numbers the loop should search through.

switch(input){
case 1:
    searchTerm = "i<10 && i>5";
case 2:
    searchTerm = "i>=10 && i<19";
case 3:
    searchTerm = "i>19 && i<24";
}
while(searchTerm){
    //some function
}


Is this possible? I I've not been able to find a way to use a string as search parameters.

EDIT: I don't think I did a very good job of explaining why I needed this. What is one to do if there are different numbers of parameters? For example:

case 1:
    searchTerm = "i<5"
case 2:
    searchTerm = "i>25 && i<29"
case 3:
    searchTerm = "(i<50 && i>25) && (i>55 && i<75)"
case 4:
    searchTerm = "(i<20 && i>15) && (i>300 && i<325) && (i>360 && i<380)

Then how does one do it? Multiple loops that call the same function?



via Chebli Mohamed