Affichage des articles dont le libellé est Active questions tagged java - Stack Overflow. Afficher tous les articles
Affichage des articles dont le libellé est Active questions tagged java - Stack Overflow. Afficher tous les articles

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

Intellij Idea hint: Condition is always false - can that be true here? (Java)


I have the following code:

public String testExitPoints() {
    boolean myBoolean = false;
    try {
        if (getBoolean()) {
            return "exit 1";
        }
        if (getBoolean()) {
            throw new RuntimeException();
        }
    } finally {
        myBoolean = true;
    }
    if (getBoolean()) {
        return "exit 2";
    }
    return "exit 3";
}

public static boolean getBoolean() {
    Random rand = new Random();
    return rand.nextInt() > 100;
}

Now IntelliJ idea gives me for the second and third invocation of getBoolean() the following hint:

Condition 'getBoolean()' is always 'false'

Now to my understanding, that is not true, since getBoolean() can either be true or false, depending on the generated random value. Am I missing something here, or is that a bug in IntelliJ Idea?



via Chebli Mohamed

A regex that matches all L3_SW_xxxx,where xxxx are numbers


I am trying to create a java regex that matches all the words from a string that start with L3_SW_ and end with a set of numbers.The regex i came up with only matches the first word in the string.I am trying to get all the matches,but I can't figure it out.

My regex is : (L3_SW_)\d+

String sample :L3_SW_NORM_92 - L3_SW_NORM_100 L3_SW_691, L3_SW_694 L3_SW_844, L3_SW_845

L3_SW_882, L3_SW_883, L3_SW_884 L3_SW_790, L3_SW_3014, L3_SW_3015

The result i am getting :L3_SW_691



via Chebli Mohamed

Select text of li elements through JQuery


How can I select the text from list elements through JQuery.I want the same functionality as that of .select() in javascript,but that is only applicable to editable text areas/input boxes, can someone guide me ,for the same functionality with list elements

I want the list text to be selected on click



via Chebli Mohamed

org.apache.axis2.AxisFault: The system is attempting to engage a module that is not available: addressing


Hi I need to execute a jar file, but when I am executing, I get this error. Some help? I was googling lot of hours, but I can't find a solution.

org.apache.axis2.AxisFault: The system is attempting to engage a module that is not available: addressing
at org.apache.axis2.engine.AxisConfiguration.engageModule(AxisConfiguration.java:584)
at org.apache.axis2.engine.AxisConfiguration.engageGlobalModules(AxisConfiguration.java:705)
at org.apache.axis2.deployment.DeploymentEngine.engageModules(DeploymentEngine.java:831)
at org.apache.axis2.deployment.FileSystemConfigurator.engageGlobalModules(FileSystemConfigurator.java:142)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:94)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(ConfigurationContextFactory.java:210)
at es.spee.meyss.proveedorcentro.application.ws.impl.ProveedorCentroTFWSStub.getContextConfiguration(ProveedorCentroTFWSStub.java:189)
at es.spee.meyss.proveedorcentro.application.ws.impl.ProveedorCentroTFWSStub.<init>(ProveedorCentroTFWSStub.java:185)
at es.spee.meyss.proveedorcentro.application.ws.impl.ProveedorCentroTFWSStub.<init>(ProveedorCentroTFWSStub.java:198)
at es.spee.meyss.proveedorcentro.cliente.business.services.impl.ProveedorCentroSvcImpl.getProveedorCentroWS(ProveedorCentroSvcImpl.java:149)
at es.spee.meyss.proveedorcentro.cliente.business.services.impl.ProveedorCentroSvcImpl.validarObtenerDatosCentro(ProveedorCentroSvcImpl.java:193)
at es.spee.meyss.proveedorcentro.cliente.business.services.impl.ProveedorCentroSvcImpl.validarObtenerDatosCentro(ProveedorCentroSvcImpl.java:170)
at es.spee.meyss.proveedorcentro.validador.ProveedorCentroTFValidador.validarObtenerDatosCentro(ProveedorCentroTFValidador.java:159)
at es.spee.meyss.proveedorcentro.validador.ProveedorCentroTFValidador.main(ProveedorCentroTFValidador.java:49)



via Chebli Mohamed

SwipeView change the content of 2 pages


I'm new to android programming

I've created a new activity with swipe views, and added some code.

I have now two swipeable pages, but with the same content, how can i change the content of the second swipe page.

Do I have to create a new activity or just to redirect it to another xml?

import java.util.Locale;

import android.graphics.Bitmap;
import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;


public class ListItemClicked extends ActionBarActivity {

static Bundle extras;

SectionsPagerAdapter mSectionsPagerAdapter;
static ImageLoader imageLoader;
static DisplayImageOptions options;




ViewPager mViewPager;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.list_item_clicked);


    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    extras = getIntent().getExtras();

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    //Setup the ImageLoader, we'll use this to display our images
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).build();
    imageLoader = ImageLoader.getInstance();
    imageLoader.init(config);

    //Setup options for ImageLoader so it will handle caching for us.
    options = new DisplayImageOptions.Builder()
            .cacheInMemory()
            .cacheOnDisc()
            .build();

}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main_activity2, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    return id == R.id.action_settings || super.onOptionsItemSelected(item);

}



public class SectionsPagerAdapter extends FragmentPagerAdapter {

    public SectionsPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        return PlaceholderFragment.newInstance(position + 1);
    }

    @Override
    public int getCount() {
        return 2;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        Locale l = Locale.getDefault();
        switch (position) {
            case 0:
                return getString(R.string.title_section4).toUpperCase(l);
            case 1:
                return getString(R.string.title_section5).toUpperCase(l);
        }
        return null;
    }
}


public static class PlaceholderFragment extends Fragment {


    private static final String ARG_SECTION_NUMBER = "section_number";


    public static PlaceholderFragment newInstance(int sectionNumber) {
        PlaceholderFragment fragment = new PlaceholderFragment();
        Bundle args = new Bundle();
        args.putInt(ARG_SECTION_NUMBER, sectionNumber);
        fragment.setArguments(args);
        return fragment;
    }

    public PlaceholderFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState)
    {

        View rootView = inflater.inflate(R.layout.fragment_list_item_clicked, container, false);


        TextView pDate = (TextView) rootView.findViewById(R.id.textView);
        pDate.setText( extras.getString("pdate") );


        TextView ptitle = (TextView) rootView.findViewById(R.id.section_label);
        ptitle.setText(extras.getString("pname"));


        TextView pnText = (TextView) rootView.findViewById(R.id.textView2);
        pnText.setText( extras.getString("pText"));




        //Setup a listener we can use to swtich from the loading indicator to the Image once it's ready
        ImageLoadingListener listener = new ImageLoadingListener(){



            @Override
            public void onLoadingStarted(String arg0, View arg1) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onLoadingCancelled(String arg0, View arg1) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onLoadingComplete(String arg0, View arg1, Bitmap arg2) {
                // i/ndicator.setVisibility(View.INVISIBLE);
               // iconImg.setVisibility(View.VISIBLE);
            }
            @Override
            public void onLoadingFailed(String arg0, View arg1, FailReason arg2) {
                // TODO Auto-generated method stub

            }

        };

        //Load the image and use our options so caching is handled.
        final ImageView iconImg = (ImageView) rootView.findViewById(R.id.imageView);
        imageLoader.displayImage( extras.getString("pImage"), iconImg, options, listener);



        return rootView;
    }
}

}

thanks!



via Chebli Mohamed

Internet explorer : Authentication with a smart card


I am using windows/Internet explorer. What are the steps to create an html page for authentication using a smart card. Is there any middleware/active X needed ? And if so, how can one use it to authenticate and get informations about the card holder ?

Thank you



via Chebli Mohamed

What should pe POJO for given JSON


I am integrating 3rd party REST API.I have written pojo for given json. Form 3rd party I am getting response in form of json as

"custom_fields": {
            "Field_68092": {
                "type": "char", 
                "required": true, 
                "value": "1", 
                "label": "orderId"
            }
        }

I tried with following POJO

public class Field_68092 {
    private String type;
    private String value;
    private String label;
    private boolean required;

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public boolean isRequired() {
        return required;
    }

    public void setRequired(boolean required) {
        this.required = required;
    }
}

and custom filed's pojo is

public class Custom_fields {
    private Field_68092 Field_68092;

    public Field_68092 getField_68092() {
        return Field_68092;
    }

    public void setField_68092(Field_68092 field_68092) {
        Field_68092 = field_68092;
    }
}

Field_68092 every time coming null. can some one help me to find ut what is wrong with POJO structure?



via Chebli Mohamed

Dynamically change Logback level for web app running on tomcat


I have a logback.xml in the resources folder of my java web application which is running on Tomcat 7. Is there a way to change the debug level of some class of the application dynamically as the application is running?

The standard thing to do it is a normal java jar running from the CLI is to just edit logback.xml with say vim and after a while the log is updated. Is this possible with tomcat as I tried it and id does not seem to work.

Is there any better way?



via Chebli Mohamed

Maven 4.0.0 Swagger 1.3.12 build fails


I'm trying to get maven to build with swagger. But I get this error:

Failed to execute goal com.github.kongchen:swagger-maven-plugin:2.3.4:generate (default) on project web: Execution default of goal com.github.kongchen:swagger-maven-plugin:2.3.4:generate failed: An API incompatibility was encountered while executing com.github.kongchen:swagger-maven-plugin:2.3.4:generate: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/LockModeType

The pom.xml dependency:

    <dependency>
        <groupId>com.wordnik</groupId>
        <artifactId>swagger-annotations</artifactId>
        <scope>compile</scope>
        <version>1.3.12</version>
        <exclusions>
            <exclusion>
                <groupId>javax.ws.rs</groupId>
                <artifactId>jsr311-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

The pom.xml Plugin:

<plugin>
            <groupId>com.github.kongchen</groupId>
            <artifactId>swagger-maven-plugin</artifactId>
            <version>2.3.4</version>
            <configuration>
                <apiSources>
                    <apiSource>
                        <supportSpringMvc>false</supportSpringMvc>
                        <locations>package.rest</locations>
                        <apiVersion>0.1</apiVersion>
                        <basePath>/api</basePath>
                        <outputTemplate>${basedir}/swaggerTempl/strapdown.html.mustache</outputTemplate>
                        <mustacheFileRoot>${basedir}/swaggerTempl</mustacheFileRoot>
                        <outputPath>${project.build.directory}/swaggerFolder/document.html</outputPath>
                        <swaggerDirectory>${project.build.directory}/swaggerFolder</swaggerDirectory>
                    </apiSource>
                </apiSources>
            </configuration>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

Can anyone help me? What do I have to change to build it correctly? Do I have to install swagger on my PC? These folders don't exist, do I have to create them or should maven/swagger do it automatically?:

${basedir}/swaggerTempl/strapdown.html.mustache

${basedir}/swaggerTempl



via Chebli Mohamed

ASTRewrite for a QuickFix: How to position the cursor?


I work on a Eclipse Plugin and create a QuickFix using ASTRewrite. Briefly it's constructed in the following way:

public class MyQFXProcessor implements IQuickFixProcessor {
    public IJavaCompletionProposal[] getCorrections(IInvocationContext context,
                                                    IProblemLocation[] locations) {
        AST ast = context.getASTRoot().getAST();
        ASTRewrite rw = ASTRewrite.create(ast);
        ASTNode replacement = astRoot.getAST().newSimpleName("Test");
        rewrite.replace(context.getCoveringNode(), replacement);
        IJavaCompletionProposal p = new ASTRewriteCorrectionProposal("My QFX",
                                                     context.getCompilationUnit(), rw, 10);
        return new IJavaCompletionProposal[]{p};
    }
}

This works fine so far. But what I didn't manage to achieve yet is to set the desired cursor position after the proposal is applied. For example this is how it's solved in JDT for add argument quick fix:

enter image description here

enter image description here

I think there should be an API for doing that, because Eclipse uses this kind of behavior for different use-cases (in auto-completion among others). Does anybody have an idea how to implement that?



via Chebli Mohamed

Inject Spel parameter on annotation parameter (like what is done with @Value on a field)


I'm using this annotation provided by spring-starter-elastic-searchto create a document and I would like to inject the parameter indexname dynamically:

@Entity
@Document(indexName = "myindex")
public class StockQuotation 

In another bean I have successfully done that by using @Valueon a field:

@Value("${elasticsearch.index.name}")
public String indexName;

However, I have tried to inject it in the same way in the annotation and the translation is not done:

@Entity
@Document(indexName = "${elasticsearch.index.name}")
public class StockQuotation

As I get this exception:

Caused by: org.elasticsearch.indices.IndexMissingException: [${elasticsearch.index.name}] missing

What would be the appropriate approach to do this?

Thanks



via Chebli Mohamed

Custom extended Android DatePickerDialog without title


I've an extended DatePickerDialog, but I'm not able to hide the title (on 5.+).

I tried the requestWindowFeature function on some places, but I don't know where the right is.

public MyDatePickerDialog(Context context, OnDateSetListener listener, Reklamation reklamation, int year, int monthOfYear, int dayOfMonth) {
    super(context, listener, year, monthOfYear, dayOfMonth);
    // Check if we're running on Android 5.0 or higher
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Log.d(getClass().getSimpleName(), "noTitle:" + requestWindowFeature(Window.FEATURE_NO_TITLE));
    }
}



via Chebli Mohamed

Spring declaration for interfaces with the same implementation


I have a problem with Spring.

I have two separate interfaces, findUnconditionalDiscountValuesStrategy and findConditionalDiscountValuesStrategy. These interfaces are implemented in the same class MmfgFindPricingWithCurrentPriceFactoryStrategy.

This is declared in the spring configuration file like this:

<alias name="mmfgFindPricingWithCurrentPriceFactoryStrategy" alias="currentFactoryFindPricingStrategy"/>
<bean id="mmfgFindPricingWithCurrentPriceFactoryStrategy" class="com.mmfg.mmfgacceleratorcore.order.strategies.calculation.impl.MmfgFindPricingWithCurrentPriceFactoryStrategy" parent="abstractBusinessService">
    <property name="findPricingWithCurrentPriceFactoryStrategy" ref="original-currentFactoryFindPricingStrategy"/>
    <property name="configurationService" ref="configurationService"/>
    <property name="mmfgSessionService" ref="mmfgSessionService"/>
    <property name="mmfgUtilsDao" ref="mmfgUtilsDao" />
</bean>

Now, I use the two interfaces in a class

private FindUnconditionalDiscountValuesStrategy findUnconditionalDiscountValuesStrategy;
private FindConditionalDiscountValuesStrategy findConditionalDiscountValueStrategy;

with getter and setter (getter protected and setter @Required).

Now I have declared this class in this way in the spring configuration file:

<bean id="mmfgOrderCalculationStrategy" class="com.mmfg.mmfgacceleratorcore.order.strategies.calculation.impl.DefaultMmfgOrderCalculationStrategy">
    <property name="findUnconditionalDiscountValuesStrategy" ref="currentFactoryFindPricingStrategy"/>
    <property name="findConditionalDiscountValuesStrategy" ref="currentFactoryFindPricingStrategy"/>
    <property name="modelService" ref="modelService" />
    <property name="commonI18NService" ref="commonI18NService" />
    <property name="calculationService" ref="calculationService"/>
</bean>

the ref is the same for the two interfaces, because the implementation class is the same.

But at runtime I obtain this error:

org.springframework.beans.factory.BeanInitializationException: Property 'findConditionalDiscountValueStrategy' is required for bean 'mmfgOrderCalculationStrategy'

How I have to declare the ref in the two properties?



via Chebli Mohamed