How to handle `SOAPFault` when `` throws an exception in Java?

I’m using javax.xml.soap classes to handle SOAP communication. Now I want to handle SOAPFailt, but a call of throws an exception instead of returning the response. The server returns fault message , but with the HTTP status 400, which is probably the cause of this:

com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (400Bad Request

Reading the SOAP 1.2 specification I’ve found that the server should return HTTP status 500 instead. Now, I can’t change the server behavior (I’m using the ‘happytime’ simulation server for the development), but can I do something to make ‘’ to return the response instead to throw an exception?

How to force a subclass to provide specific data within an overridden method

I have a base class called Feature, and another two classes Feature1 which is extension to the base calss.
in other words, Feature1 extends Feature as shown in the code.

what i want to do is, since feature1 extends the base Feature class it should override the capture() method, but what i want to do also is,
to force feature1 also to provide a variable called captureId within the capture() method. which mean I want to force each feature extends Feature class
must privide captureId within the overriden capture() method


class Feature {

public void capture() {


class Feature1 extends Feature {
public void capture() {
//captureId must be mandatory to be provided by each class extends Feature

JPA (Hibernate): “ORA-02289 Sequence does not exist”, but it does

I’m working with JPA entities.

I created a new one like this:

public class Entity {
    @GeneratedValue(generator = "Entity_Sequence", strategy = GenerationType.SEQUENCE)
    @SequenceGenerator(name = "Entity_Sequence", sequenceName = "Entity_Seq")
    private Long id;

    // ... other fields

Generated SQL I used to create DB Objects:


  ID     NUMBER(19, 0) NOT NULL,
  -- ... other fields

Now, I am able to query the nextval of the sequence from SQL Developer and from IntelliJ, but Hibernate throws the following exception:

15:21:11,022 INFO  [stdout] (EJB default - 2) Hibernate: select ENTITY_SEQ.nextval from dual
15:21:11,037 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (EJB default - 2) SQL Error: 2289, SQLState: 42000
15:21:11,037 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (EJB default - 2) ORA-02289: Sequence ist nicht vorhanden.

(“Sequence ist nicht vorhanden” translates to “Sequence does not exist”.)

Why is Hibernate not able to find the sequence while I am?

Sample code use for (moa PairedLearners)

Hello I am new into using MOA and WEKA,

I need to test paired learners concept using this code and I have been able to locate the code but I cannot find any example online and
I am having a hard time figuring how to pas my data into the code and run a test and see my results.
Pls can anyone point my in a right direction or give me a few pointers that I could follow to implement this.


Best Regards.


I try to use Google Speach Api

and I have big problem witch authentication.

I fallow this tutorial, and i export GOOGLE_APPLICATION_CREDENTIALS, and i check it use echo, and all ok.

But when I start code from first link I get error:

Exception in thread "main" The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See for more information.
at com.example.speech.QuickstartSample.main(

Ofcourse i chcek path in environment variable, even i get this file chmod 777, and nothing help.

anyone have similar problem?

Java – Sort an array with Extreme Minimum or maximun values

I want to get the maximum or minimum values from an Arraylist.

For example I have follwing values in my Arraylist,
1.22 , 2.55 , 6.00 , 3.00 , 4.77 , 9.88 , 7.23 , 8.22

I would like to get it sorted like

9.88, 1.22 , 8.22 , 2.55 , 7.45 … … …

Currently i am sorting the values in decessending order using following code,

Collections.sort(characterPairs, new Comparator<Pair<String, Double>>() {

        public int compare(Pair<String, Double> o1, Pair<String, Double> o2) {
                return -1;
                return 1;
            return 0;

Attempt to invoke virtual method-FAILURE : App Crashed

Blockquote–> While trying to run the app , it crashes and says that “Attempt to invoke virtual method” ..
below is the error found in the logcat.

                                                                          Process: com.example.sayantan.moviebugs, PID: 1694
                                                                          java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List com.example.sayantan.moviebugs.model.MoviesResponse.getResults()' on a null object reference
                                                                              at com.example.sayantan.moviebugs.MainActivity$2.onResponse(
                                                                              at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$
                                                                              at android.os.Handler.handleCallback(
                                                                              at android.os.Handler.dispatchMessage(
                                                                              at android.os.Looper.loop(
                                                                              at java.lang.reflect.Method.invoke(Native Method)

Blockquote–> Below is the Json code snippet from file:

eCall<MoviesResponse> call = apiService.getPopularMovies(BuildConfig.THE_MOVIE_DB_API_TOKEN);
        call.enqueue(new Callback<MoviesResponse>() {
            public void onResponse(Call<MoviesResponse> call, Response<MoviesResponse> response) {
                List<Movie> movies = response.body().getResults();

                //Collections.sort(movies, Movie.BY_NAME_ALPHABETICAL);
                recyclerView.setAdapter(new MoviesAdapter(getApplicationContext(), movies));
                if (swipeContainer.isRefreshing()){

Blockquote–>Below is the snippet from the model file :

  public void setPage(int page) { = page;

public List<Movie> getResults()
    return results;

public List<Movie> getMovies() {
    return results;

public void setResults(List<Movie> results) {
    this.results = results;

Instanciation depending on type, generics, inheritance or both?

I have a method instanciating a specific class depending on type send as parameter of this method. This works perfectly but I really don’t like this if(c == class_name.class) way to deal with this and I’m pretty sure there is a better way to do this using generics and inheritance. The method I use looks (maybe mistakenly…) dirty to me.

I followed several tutorials regarding generics and inheritance but even if I think I more or less understand these two concepts separately I’m strugling understanding the mix of both… And I think these both concepts could resolve my problem once mixed. Could anybody show me the right track to follow, generics, inheritance, both or keep my code like this. Is there a better way to do this ?

This is my actual method :

private void addData(String csvFile, char separator, Class<?> c) {
        int lineNumber = 1;
        CSVReader reader;

        try {
            reader = new CSVReader(new InputStreamReader(getAssets().open(csvFile)), separator);
            String[] line;

            if(c == FlagDef.class) {
                while ((line = reader.readNext()) != null) {
                    FlagDef flagDef = new FlagDef(Long.parseLong(line[0]), line[1], line[2]);
                    Log.d(TAG, String.format("%s %s %s", line[0], line[1], line[2]));
            if(c == Picture.class) {
                while ((line = reader.readNext()) != null) {
                    Picture picture = new Picture(Long.parseLong(line[0]), line[1]);
                    Log.d(TAG, String.format("%s %s", line[0], line[1]));

        } catch (FileNotFoundException ex) {
            Log.e(TAG, String.format("File %s not found : %s", csvFile, ex));
        } catch (IOException ex) {
            Log.e(TAG, String.format("Error parsing line number %s : %s", lineNumber, ex));

How can execute a sequence in JpaRepository?

how can execute a sequence in JpaRepository?

and then read the id from the Entity.

public interface EmailRepository extends JpaRepository<Email, Long> {


emailService.persistEmail(from, to, subject, content);
    private EmailRepository emailRepository;

    public void persistEmail(String mailFrom, String mailTo, String subject, String content) {
        Email email = new Email(mailFrom, mailTo, content, subject);
        Email persisted =;
        log.debug("Persisted Information for Mail: {}", persisted.getMailFrom());

i can’t persist because the id is null. Any ideas