How do I use an event to return true in an if condition in Java

I am new to Java and I am making an app where I need to have multiple containers do the same kind of thing. What I plan to do is use the event objects to find out which one was selected and then call the same function. I don’t have any code at the moment.
How would I use the event object to do so? Or is there a better way?

Go to Source
Author: Dan Morrissey

Deployment of Docker containers on ECS(Tcp Server Java)

The given problem:

  • Created a Java Tcp Server with Eclipse vertx(Toolkit for building
    reactive,event driven)applications on JVM. The applicatino has two
    Tcp Servers which are running on port numbers:
    server1(port:5050);server2(5051)

  • I created a Docker image and was running the application inside a
    container and all works fine locally.

  • I want to deploy the docker container on ECS(Amazon Container
    Service) and to use Network Load balancer,the question is how can i
    assign different ports to different containers if in the Java code i
    was setting up explicity

//tcp server 1 listens on port 5050

server..listen(5050)
  • and how does ECS manages what ports to assign to what container?

    The tcp client is always targeting one ip adress and one port number
    it cannot be changed.

    Thanks!

Go to Source
Author: user581026

How to get Json [object Object] type in Jsp?

actually I got that Json from Java to jsp.

$.ajax({
url:”MovieList.me”,
method:”get”,
dataType :”json”,
success:function(data){
$.each(data.Data,function(idx,item){

                    $.each(item.Result,function(idx,item2){
                        $.each(item2,function(idx,item3){
                         $('table').append("<tr><th>"+item3+"</th></tr>")
                        });
                      });

this is Jsp Jquery Code.

JsonParser jsonParser = new JsonParser();
JsonObject jsonObject = (JsonObject) jsonParser.parse(json);

this is java code and return jsonObject

Thank you for read

Go to Source
Author: 이태윤

Pattern name for “Platform independant class with Hooks + sub class implementing platform specific”?

I am developing an android app to process jpg exif meta data in a workflow.

The Workflow class is implemented platform independant (i.e. code runs on android and on j2se).

The Workflow contains and calls protected virtual methods that do nothing for android specific .functions (i.e save changes to android media database)

package de.k3b.media;

// platform independant
public class Workflow {
    public void processPhoto(...) {
        ...
        saveChangesToMediaDatabase(....);
        ...
    }
    
    protected void saveChangesToMediaDatabase(...) {    
        // to nothing in platform independant version
    }
}

I also have a android platform specific sub class that implements the platform specific code

package de.k3b.android.media;

// android platform dependant
public class AndroidWorkflow extends Workflow {
    @Override
    protected void saveChangesToMediaDatabase(...) {    
        ... do something with android media database
    }
}

I can use Workflow.processPhoto(...) in non-android j2se apps and in automated unit or integration tests
and i can use AndroidWorkflow.processPhoto(...) in my android app

My question: Is this an established pattern and is there a name for this pattern?
My current pattern name “Platform independant class with Hooks” and “Platform specific Hook implementation”.

I hope to find a better (??established??) name for this pattern.


Remarks:

One established pattern to have platformindependat code is by using a Facade pattern.

Example: I use a FileFacade with a j2se implementation based on java.io.File and AndroidFileFacade which is based on android specific DocumentFile.

Although the goal of platform independance is the same the way how this is achieved is different.

Go to Source
Author: k3b

Integrating TeX into a Java desktop application

Looking to integrate TeX equations in a TeX-agnostic fashion, suitable for either ConTeXt or LaTeX, into a Java-based desktop Markdown editor. The possibilities are numerous, but I’m not sure what approach to take.

JMathTex outputs to MathML, which must be transformed. JEuclid can transform MathML to BufferedImages (not 100% sure). Neither are JDK 14-friendly and may be too slow to render in real-time. I haven’t looked because I read that they didn’t work with Java 9 (without porting effort), much less 14. Also, the licensing isn’t LGPL, which probably won’t work with the MIT licensing.

The NTS library is reported to compile gentle.tex in about 3 seconds. The spin-off project, εχTEX improves upon NTS, but I don’t know to what extent.

Java LaTeX Report requires a TeX engine.

Yet another possibility is to try JavaTex or rework the project using web2java to transpile WEB files into Java files.

JLaTeXMath does an exceptional job at rendering, though investigation would be required to see if it can perform real-time renders, output as SVG, or otherwise determine if it can integrate with FlyingSaucer.

The HTML preview panel uses FlyingSaucer. The SVG documents are rendered using SVG Salamander. If it was possible to go from TeX to SVG, that could work quite handily, architecturally. Some documentation stated FlyingSaucer can also render MathML, but I suspect the doc is wrong. FlyingSaucer doesn’t integrate with JavaScript. For that I’d have to add a JavaScript Engine.

If a JavaScript Engine is necessary, then using KaTeX may be an option.

Still another possibility is the TeX to MathML service. This is written in Java, but the source code is not available anywhere. I’ve reached out to some people involved in the project.

For native speeds, there may be a (cross-platform?) C-based TeX engine that can generate MathML or SVG from a TeX input. If so, it may be possible to integrate with the JNI.

Here’s a demo video of the app, to give you an idea of what is needed:

The goal is to produce real-time rendering of math, ideally in pure Java (no JavaScript).

What approach would you take and what do you see as its benefits and drawbacks?

Go to Source
Author: Dave Jarvis

Applicability of Java skills to Groovy development

Hi all: if you have meaningful Java experience, was it enough to develop basic Groovy code as well?

Leverice opened up its platform API and wondering how much overlap there is between Java and Groovy skills. If you’ve made the transition, how much time/work did it require to get up to speed with Groovy?

Go to Source
Author: deevee

Port Forwarding – Server responds to remote Java request, responds via local browser, can’t be reached in remote browser

I am hosting an Apache Tomcat instance on a server which is used to display a web page.
It needs to be remotely accessible via a browser.
The web page runs normally via localhost and I have setup port forwarding to make it remotely accessible.
I have tested the port forwarding with Java and successfully connected to the sockets.
Despite being able to connect to the socket, when I attempt to access it via a remote browser is returns “site can’t be reached”.

Locally
Local Browser – Web page runs as expected on localhost:8080

Remotely
Socket test – pass
Remote Java Request – Responds with full html of web page
Remote Browser – Site can’t be reached

Does anyone know why only the remote browser portion would fail, while remote requests sent through Java would work?

Go to Source
Author: jorbo

Getting exception when trying to suppress a constructor with PowerMockito

Trying to mock an instance creation:

//Class
final InformationSection infoSec = new InformationSection("123");

with

//Test
PowerMockito.suppress(MemberMatcher.constructorsDeclaredIn(InformationSection.class));
InformationSection infoSec = mock(InformationSection.class);
when(InformationSection.class).withArguments(Mockito.anyString()).thenReturn(infoSec);

The constructor of InformationSection which I am trying to suppress is internally doing
Integer.parseInt("123") to call another constructor of the same class with Integer argument and that is throwing NumberFormatException:

java.lang.NumberFormatException: null
at java.lang.parseInt(Integer.java:615)
InformationSection.<init>(InformationSection.java:40)

So my confusion is if I am suppressing the constructor, why is it still doing that parsing?
I am referring to:
What does <init> signify in a Java exception?
Is this happening before suppressing the constructor?

Go to Source
Author: Ssk92

I am completely new to Java 8 and unable to refactor my Java 7 code:

my java 7 code is as below:

List reviewList=new ArrayList<>();

if(!reviewList.isEmpty()  &&  !(reviewList.contains(bookReview.getBookReview().get(0)))) {
    boolean flag=false;

   for(Review review:reviewList)
    {
      if(review.getUserId().equals(bookReview.getBookReview().get(0).getUserId()))
      {
        review.setRating(bookReview.getBookReview().get(0).getRating());
        review.setReviewText(bookReview.getBookReview().get(0).getReviewText());
        review.setBookId(bookReview.getBookReview().get(0).getBookId());
        review.setUserId(bookReview.getBookReview().get(0).getUserId());
        flag=true;
        break;
      }
    }
    if(flag==false)
    {
      reviewList.add(bookReview.getBookReview().get(0));
    }
}

Can anyone please help me

Go to Source
Author: Tanay Rahangdale

How to convert a ArrayList into 2D array jn Java 7

I am trying to convert a Integer list in a 2D array in java 7. I first converted a String list to Integer and then Integer list to 2D array. Then I will do more operations as required.
What I tired is

List<String> list = Arrays.asList("1", "2", "3", "4");
    List<Integer> intList = new ArrayList<>();
    for (String s : list) {
        intList.add(Integer.valueOf(s));
    }
    //the problem is from here
    int[][] array = new int[intList.size()][];
    for (int i = 0; i < list.size(); i++) {
        for (int j = 0; j < list.size(); j++) {
            array[i][j] = intList.get(j + (list.size() * i));
        }
    }

I tried solving my issue looking at this Converting an ArrayList into a 2D Array and this Convert ArrayList into 2D array containing varying lengths of arrays but majority of the answers are given in java 8 which I don’t want! i know its a basic problem but i am stuck! Can someone help me to fix this? Thanks in advance!

Go to Source
Author: Code Dexter

How to apply MVC pattern in JavaFX with nested classes

I am trying to create a Calendar application in JavaFX using MVC. What I have in mind is something as what is shown in the image below:

Calendar draft

Basically:

  • I have a CalendarView (red background) showing the title of the calendar (“Calendar for today”) and the labels of the hours of the day. This CalendarView includes a container (blue background), that works as a holder for the individual appointments.
  • I have an AppointmentView (green background) which is generated for each and every appointment in the calendar.

Based on this scenario, my idea would be doing something as follows:

  1. Create an AppointmentModel class as model for the appointment
  2. Create a CalendarModel class as model for the calendar. This class includes a list of AppointmentModel
  3. Create a controller for the appointment, called AppointmentController. This controller will include an instance of an AppointmentModel class and an AppointmentView class
  4. Create a controller for the calendar, called CallendarController. This controller will include an instance of a CalendarModel class and CalendarView class

I have written the following pseuocode to describe this scenario:

public class AppointmentModel {
    ...
}

public class CalendarModel {
    List<AppointmentModel> appointments;
    
    ...
}

public class AppointmentController {
    AppointmentModel model;
    AppointmentView view;

    ...
}
public class CalendarController {
    CalendarModel model;
    CalendarView view;

    ...
}

The problem I find now is how to link the calendar and the appointments. In the code above I have included List<AppointmentModel> appointments; inside CalendarModel, but by doing this, I do not know what to do with AppointmentController. Only thing I could think of is including a List<ApointmentControllers> ... in CalendarController and removing the List<AppointmentModel> ... from CalendarModel, but this does not make sense for me, as the CalendarModel, by definition, implies a list of appointments.

What am I missing in my reasoning?

Go to Source
Author: Fernando Cereijo

Spring-webflow SnapshotCreationException Error after login

I am working with a java project with spring-webflow and fimefaces 3.3.
The version of primefaces cannot be increased due to menu developments and other components that generate an error when trying to upload the version. The problem is not this.

The problem comes from setting the max-execution-snapshots property. If I put a value other than 0, it generates the exception indicated by the statement.

I thought that it could be the objects that some were not serialized, but I have implemented serialization and it continues with the same result.
Before refactoring the project, passing it from ant build to Maven, it was not necessary to indicate in the flow-executor the flow-execution-repository. The most curious thing is that they are the same libraries that are used:
spring-faces-2.4.1.RELEASE, spring-webflow-2.4.1.RELEASE and the rest of spring are 4.3.16.RELEASE.

When the application loads, it makes a call to return a list, but this is not the fault. I guess the problem must be in the call to the WebService because the error it throws in the rootcase is: java.io.NotSerializableException: org.apache.cxf.jaxws.JaxWsClientProxy

I don’t know if it’s also a problem with the filters, I don’t know exactly. I have been looking for a solution for several days, but it has not been possible.

I put here the stacktrace and the spring-webflow configuration
Thanks in advance!

spring-webflow.xml

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:webflow="http://www.springframework.org/schema/webflow-config"
   xmlns:faces="http://www.springframework.org/schema/faces"
   xsi:schemaLocation="
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/webflow-config
        http://www.springframework.org/schema/webflow-config/spring-webflow-config.xsd
        http://www.springframework.org/schema/faces 
        http://www.springframework.org/schema/faces/spring-faces.xsd">

    <faces:resources/>

    <!-- Spring Webflow central configuration component -->
    <webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry">
        <webflow:flow-execution-repository max-executions="10" max-execution-snapshots="-1"/>
        <webflow:flow-execution-listeners>          
            <webflow:listener ref="facesContextListener"/>          
            <webflow:listener ref="securityListener"/>
        </webflow:flow-execution-listeners>
    </webflow:flow-executor>
    
    <!-- Installs a listener that creates and releases the FacesContext for each request. -->   
    <bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener"/>   
    
    <webflow:flow-registry id="flowRegistry" flow-builder-services="facesFlowBuilderServices" 
        base-path="/WEB-INF/flows/" >
        <webflow:flow-location-pattern value="/**.xml" />
        <webflow:flow-location id="parent-flow" path="parent-flow.xml" />
    </webflow:flow-registry>
    
    <!-- Configures the Spring Web Flow JSF integration --> 
    <faces:flow-builder-services id="facesFlowBuilderServices" development="true" />
    
    <bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
        <property name="viewResolvers">
            <list>
                <ref bean="viewResolver"/>
            </list>
        </property>     
    </bean>
    
    <bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver">
          <property name="prefix" value="/WEB-INF/views/"/>
          <property name="suffix" value=".xhtml" />
    </bean>
          
    <!-- Dispatches requests mapped to flows to FlowHandler implementations --> 
    <bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">      
        <property name="flowExecutor" ref="flowExecutor" /> 
    </bean>
    
    <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
        <property name="flowRegistry" ref="flowRegistry"/>
        <property name="order" value="1"/>
    </bean>
    
</beans>

The filters shown in the stacktrace are from third parties, we don’t have the code

StackTrace

JBWEB000065: HTTP Status 500 - Request processing failed; nested exception is org.springframework.webflow.execution.repository.snapshot.SnapshotCreationException: Could not serialize flow execution; make sure all objects stored in flow or flash scope are serializable


JBWEB000309: type JBWEB000066: Exception report

JBWEB000068: message Request processing failed; nested exception is org.springframework.webflow.execution.repository.snapshot.SnapshotCreationException: Could not serialize flow execution; make sure all objects stored in flow or flash scope are serializable

JBWEB000069: description JBWEB000145: The server encountered an internal error that prevented it from fulfilling this request.

JBWEB000070: exception 
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.webflow.execution.repository.snapshot.SnapshotCreationException: Could not serialize flow execution; make sure all objects stored in flow or flash scope are serializable
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    com.jeveris.web.core.filter.log.PerformanceLogFilter.doFilter(PerformanceLogFilter.java:55)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    com.axa.ca.caem.credentials.IamAuthenticationFilter.doFilter(IamAuthenticationFilter.java:116)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
    org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)



JBWEB000071: root cause 
org.springframework.webflow.execution.repository.snapshot.SnapshotCreationException: Could not serialize flow execution; make sure all objects stored in flow or flash scope are serializable
    org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshot.<init>(SerializedFlowExecutionSnapshot.java:75)
    org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshotFactory.createSnapshot(SerializedFlowExecutionSnapshotFactory.java:70)
    org.springframework.webflow.execution.repository.snapshot.AbstractSnapshottingFlowExecutionRepository.snapshot(AbstractSnapshottingFlowExecutionRepository.java:75)
    org.springframework.webflow.execution.repository.impl.DefaultFlowExecutionRepository.putFlowExecution(DefaultFlowExecutionRepository.java:126)
    org.springframework.webflow.executor.FlowExecutorImpl.launchExecution(FlowExecutorImpl.java:145)
    org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:238)
    org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:57)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    com.jeveris.web.core.filter.log.PerformanceLogFilter.doFilter(PerformanceLogFilter.java:55)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    com.axa.ca.caem.credentials.IamAuthenticationFilter.doFilter(IamAuthenticationFilter.java:116)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
    org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)



JBWEB000071: root cause 
java.io.NotSerializableException: org.apache.cxf.jaxws.JaxWsClientProxy
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
    java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
    java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
    java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
    java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
    java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
    java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
    java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
    java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
    java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
    java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
    java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
    java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
    java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
    java.util.HashMap.internalWriteEntries(HashMap.java:1793)
    java.util.HashMap.writeObject(HashMap.java:1363)
    sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:498)
    java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1140)
    java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)
    java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
    java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
    java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:441)
    org.springframework.webflow.core.collection.LocalAttributeMap.writeObject(LocalAttributeMap.java:333)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:498)
    java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1140)
    java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)
    java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
    java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
    org.springframework.webflow.engine.impl.FlowSessionImpl.writeExternal(FlowSessionImpl.java:162)
    java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1459)
    java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1430)
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
    java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
    java.util.LinkedList.writeObject(LinkedList.java:1131)
    sun.reflect.GeneratedMethodAccessor54.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:498)
    java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1140)
    java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)
    java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
    java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
    org.springframework.webflow.engine.impl.FlowExecutionImpl.writeExternal(FlowExecutionImpl.java:311)
    java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1459)
    java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1430)
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
    java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
    org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshot.serialize(SerializedFlowExecutionSnapshot.java:173)
    org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshot.<init>(SerializedFlowExecutionSnapshot.java:70)
    org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshotFactory.createSnapshot(SerializedFlowExecutionSnapshotFactory.java:70)
    org.springframework.webflow.execution.repository.snapshot.AbstractSnapshottingFlowExecutionRepository.snapshot(AbstractSnapshottingFlowExecutionRepository.java:75)
    org.springframework.webflow.execution.repository.impl.DefaultFlowExecutionRepository.putFlowExecution(DefaultFlowExecutionRepository.java:126)
    org.springframework.webflow.executor.FlowExecutorImpl.launchExecution(FlowExecutorImpl.java:145)
    org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:238)
    org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:57)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    com.jeveris.web.core.filter.log.PerformanceLogFilter.doFilter(PerformanceLogFilter.java:55)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    com.axa.ca.caem.credentials.IamAuthenticationFilter.doFilter(IamAuthenticationFilter.java:116)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
    org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)

Go to Source
Author: Marco Osorio

How to visualise Inheritance and Polymorphism?

I want to make diagrams that explain how Inheritance and Polymorphism work conceptually.

Assume that we have a Cat class that inherits from the Animal class. The way that I can think of a Cat object is that it is an object that contains a copy of the members of the Cat class and also it have an Animal object inside of it.

Note: technically, I think that all Cat objects share the same copy of the methods of the Cat class, however, it is clearer to conceptually think of every Cat object as if it contains its own copy of the methods of the Cat class.

Now when we do:

Cat cat1 = new Cat();

Then cat1 will point to the Cat object, this is how the diagram would look like:

enter image description here

The operations that are allowed on the cat1 variable are the following:

  • cat1.x (will access the x variable inside the Cat object).

  • cat1.move() (will call the move() method inside the Cat object).

  • cat1.jump() (will call the jump() method inside the Animal object).

And when we do:

Animal animal1 = cat1;

Then animal1 will point to the Animal object that is inside the Cat object, this is how the diagram would look like:

enter image description here

Note: the arrow pointing at the Animal object doesn’t mean that animal1 actually point to a different location in memory than cat1, the truth is that animal1 and cat1 point to the same location in memory, the arrow pointing at the Animal object is just to indicate that animal1 can only access the members inside the Animal object (unless we have an overridden method).

The operations that are allowed on the animal1 variable are the following:

  • animal1.x (will access the x variable inside the Animal object).

  • animal1.move() (now if the move() method is not overridden in the Cat class, then animal1.move() should call the move() method inside the Animal object, however, since the move() method is overridden in the Cat class, then animal1.move() would call the move() method inside the Cat object).

  • animal1.jump() (will call the jump() method inside the Animal object).

Is my understanding correct?

Go to Source
Author: Tom

What’s in THIS environment?

We work on multiple java web projects going on at the same time and those are all being tested on several different QA environments. Id like to show on our support portal what projects are in what environments without having to manually updated it all the time. I was thinking of some what to tag the build so I could just query tomcat or those linux servers themselves and show the results. The tags would be something like “August Release”, “Project 1”, “Project 2”, etc.. Has anyone done something similar? I’m looking for different options.

Go to Source
Author: DaveTX

Using a domain model to persist metrics

I am currently developing a spring boot web application in which no entity is persistent, and hence will not be saved on a database.

Although, I need to be able to query some business metrics from it. Suppose the following scenario:

  1. EntityA belongs to a third party API.
  2. An user on my web app requests to see some details of EntityA.
  3. My app then requests EntityA from the third party API, does some processing (could be combining that data with some other available on the web), and returns the desired info to the requesting user.

I am not required to persist EntityA because it is already being persisted inside the third party API. All the processing done is transient. But, I want to be able to check how many times EntityA was requested by an user on my web application, and what data it contained on each request. This metric is useful for audit purposes, for example, since the third party accepts input and output of data. I want to be able to check who input a certain piece of data, and how many times it was done.

If I were to persist EntityA, I would not need all fields that the domain model contain. Also, I would have to add some metadata fields to it (date of request, requesting user, etc.).

What is the correct approach to it?

  1. Persist the domain model of EntityA in my web app, adding the metadata fields on, for example, a superclass?
  2. Create a new entity that express the desired metric, for example RequestedEntity, and map the desired fields of EntityA to RequestedEntity before persisting?

Go to Source
Author: Gabriel Robaina