Java EE





Java Enterprise Edition (Java EE) is a specification defining a collection of Java-based server and client technologies and how they interoperate. Java EE specifies server and client architectures and uses profiles to define technology sets targeted at specific classes of applications. All Java EE profiles share a set of common features, such as naming and resource injection, packaging rules and security requirements.

Share tech news, updates, or what's on your mind.

Sign up to Post

Websocket or TCP or Push Notification ????

I am planning to build a mobile app to see the updates of stocks being added by the user as soon the price got updated.

1. Do we need to use Websocket or TCP or push notification in this case? Which one is better ?
2. Do we have any stock market test API's which supports Websocket or TCP or Push notification to cross check the feasibility, stability, reliability and latency ?
3. What are the differences between websocket vs TCP vs Push Notification ???

Need answers for the above three questions and the final decision as well. Please Suggest.
Cloud Class® Course: Amazon Web Services - Basic
LVL 12
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Hello there,

I have a 3 web application which I want to run one 1 instance of Tomcat on Ubuntu server. Now at present when i type in the browser from my laptop I can connect to my tomcat server and the web page is shown. Now I went a step forward by, instead of the ip i want to enter the some name like but it is not working, i get a white screen and on the browser title it says Site under construction(dont know where it gets this title from). I am referring to this link for help Can somebody please help me.

Hi Team,

I need an help on Scanner class in java . I need some help on how to use the Scanner(Readable src) , Scanner(ReadableByteChannel src , String charSetName). with an example
Any help is really appreciated.
I have installed apache tomcat 7.0.90 on my windows 8 64bit system. This is how I have configured my tomcat-users.xml -

<?xml version='1.0' encoding='utf-8'?>
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  See the License for the specific language governing permissions and
  limitations under the License.
  NOTE:  By default, no user is included in the "manager-gui" role required
  to operate the "/manager/html" web application.  If you wish to use this app,
  you must define such a user - the username and password are arbitrary. It is
  strongly recommended that you do NOT use one of the users in the commented out
  section below since they are intended for use with the examples web
  NOTE:  The sample user and role entries below are intended for use with the
  examples web application. They 

Open in new window

what are differences between

mdb enterprise java beans.

when to use which one

any practical examples on them to see differences.

any links, resources, videos?
please advise
Hi Experts,

List<String> list = new ArrayList<String>();
i have to iterate the list
split the string into two  parts as below
String countries = 'gh','sg','hk','ke';
int custId = 123,456,789,968;
Hi Experts,

i want to know table having data or not
in select query i will pass account no dynamically
can i use executeUpdate() for select queries or i have to use execute method

in executeupdate if the table having data it will return>1
else it will return 0.

i have a doubt is it good practive to use or i have to use execute()?
Hi Experts,

HashSet<TestData> hashset = new HashSet<>();

using select query getting data from Test1 table and adding data in TestData Object, then finally adding it in hashset.
now hashset is haviing 1000 records.

i want to insert this data in Test2 table(different database).

in Test2 table might have the same record if the record is available need to do update the values
if no data available in Test2 table need to do insetion.

Can some suggest me best way to do insert or update in Test2 table using jdbc.
Hi Team,

According to my work, I have to run 7000+ sql statements in DB2 .I have the java code of the same.But by default DB2 java can only run 1338 dynamic statements at one time.
So what I was doing that Split the input data (7000 + ) into mulitiple txt files and run program more than 7 times .Each time I have to change the input path file.

Now  instead of running program 7+ times and manually changing input path everytime,I m trying to dynamically read all the input files from that folder.
Here I am attaching a part of my program only..only the method to read input file.
Below is the code for single input file case. Assume I have files named as a.txt,b.txt,c.txt.....etc.
Text file contains data in the below format:-
Existing code which executes fine  for single input file

declared input file path
static String fileName="C:\\Users\\john\\Desktop\\policies.txt";

Open in new window

main method.
 public static void main(String[] args)
    Pre pd = new Pre();

//other methods as a part of my work

Open in new window

read+policy method
public void read_Policy_list_file (String fileName)
				BufferedReader br = new BufferedReader(new FileReader(fileName));
				try {
				    StringBuilder sb = new StringBuilder();
				    String line = br.readLine();

				    while (line != null) 

Open in new window


Wonder why screen 2 approach better than screen 1 approach.
Please advise
Cloud Class® Course: Microsoft Windows 7 Basic
LVL 12
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

how utf-8, unicode are different for latin kind of characters with carrot or cap etc on them

in java are those both same?
are they different in other languages?

how html decimal code is different?
what other formats out there?
which one to use when?
which one to use to support sms on emails, sms text and different browsers, gif. pdf kind of reports etc without having to see some junk ?? kind of display issues
I am writing java code to make api calls to dynamics 365...
Is there any standard library that i can use to for this...
Especially with the case when in the response i get a new link :
],"@odata.nextLink":"[Organization URI]/api/data/v9.0/accounts?$select=name&$filter=contains(name,'sample')&$skiptoken=%3Ccookie%20pagenumber=%222%22%20pagingcookie=%22%253ccookie%2520page%253d%25221%2522%253e%253caccountid%2520last%253d%2522%257b695EAF89-F083-E511-80D3-00155D2A68D3%257d%2522%2520first%253d%2522%257b655EAF89-F083-E511-80D3-00155D2A68D3%257d%2522%2520%252f%253e%253c%252fcookie%253e%22%20istracking=%22False%22%20/%3E"  

Normally i would fetch the result and then check for nextLink and make an http call then again check ...
Whats the best way to do this... Is there any spring framework.


I would like to know how to disable the Java security warning screen below from coming up each time run a jnlp file from my desktop.  The users complain that this is distracting because you always have to click the check box and the run button every time before the Java program starts.  To run the file you need to enable Java security HIGH and add this site to the exception site which we already did but it still isn't disabled.  

What additional setting or command line parameters would disable the warning screen below?

Java Security Warning Screen
I am using OAuth for Microsoft dynamics CRM.
For some strange reason its not returning accesToken when i used a refreshToken to generate a new token.
Its only retruning refreshToken and idToken. What could be the reason for that ?

Here is the screen shot of postman request -
Is this a valid OaUth protocl response ??

I was making a spring web application. Where there are lot of handlers for GET request etc.
One thing came to my mind -
Suppose I make a GET request from my chrome browser from a particular tab.
And then in the response i add some values which gets back to this same chrome tab and machine.
How exactly does that happen.
How does a response object gets linked to a particular tab in a chrome broswer.

Also is it possible to send a response object without receiving a request object from spring to a particular machine and application.
I guess it should not be possible... But what makes it impossible.
Here is my code:

(assume that inFS, habitat, habitatData and i are already created/initialized, as they are initialized earlier in the code)


case "aquarium":


            habitat = inFS.nextLine();


            while(!habitat.contains("Aquarium")) {


               habitat = inFS.nextLine();



            for (i = 1; i <= 4; i++) {


               habitatData = habitatData + habitat + "\n";

               habitat = inFS.nextLine();



            habitatData = habitatData.substring(4, habitatData.length());


            return habitatData;



The habitats.txt file it is looking at is attached.  The two other habitats, using identical code to the above (with the exception of !habitat.contains(“Aquarium”) being “Bird” or “Penguin” instead) and they both work.


When I hit the “aquarium” case, I get:


                at java.util.Scanner.nextLine(

                at zooprogram.FileParser.habitatInfo(

                at zooprogram.ZooProgramMenus.habitatMenu(

                at zooprogram.ZooProgramMenus.mainMenuDecision(

                at zooprogram.ZooProgram.main(

<redacted>\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1

How to license each module in Spring MVC application ?

We need to develop several modules and each modules should be licensed separately

1. How to create license for each module?
2. How to enable/activate/disable the license dynamically?
3. Which open source softwares are available to license modules in J2EE spring mvc application?
If i have a rest controller in spring boot how can I validate the contract that comes in if certain values of the parameters need to have certain values??? ANy code examples are appreciated!
I am using a Mule Enterprise Service Bus for one of our integration project.I keep  getting  WeaveExecutionException everytime I test  it.Can any one please help or point me to the right direction?Below is the error details:-

Caused by: com.mulesoft.weave.mule.exception.WeaveExecutionException: Exception while executing: 
[row,col]: [1,1]
Unexpected character '[' (code 91) in prolog; expected '<'
 at [row,col {unknown-source}]: [1,1].
	at com.mulesoft.weave.mule.exception.WeaveExecutionException$.apply(WeaveExecutionException.scala:10) ~[mule-plugin-weave-3.8.5.jar:?]
	at com.mulesoft.weave.mule.WeaveMessageProcessor.execute(WeaveMessageProcessor.scala:121) ~[mule-plugin-weave-3.8.5.jar:?]

Open in new window

Cloud Class® Course: Certified Penetration Testing
LVL 12
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

I want to make a Bean in context of my Junit code of a spring web application. Here is the class in the project that i want to instantiate.
This has no constructor and also uses @Value annotation. How to do it.

public class AppEnvironment {

    private String appId;
    private String appSecret;
    private boolean isProd;
    private String baseUrl;
    private String botGUID;
    private String botToken;
    private String appIconUrl;
    private String fontColor;
    private String reminderBotHost;

Open in new window

I am trying to make a Junit test for a spring project. There is a @Service class in project which has CRUDRepository objects as its member variables.
How do I get this object in My Junit context. Normally I can instantiate an Object but here there is no clear way of instantiating CRUDRepository Objects.
@ContextConfiguration(classes = ApplicationConfig.class)
public class WorkflowTemplateTest {

    private static final ObjectMapper mapper = new ObjectMapper();

    private WebApplicationContext webApplicationContext;

    private ApplicationConfig applicationConfig;

    private MockMvc mockMvc;

    public void setUp() throws Exception {
        this.mockMvc = MockMvcBuilders.webAppContextSetup(this.webApplicationContext).build();

Open in new window

public class ApplicationConfig {
    public TemplateService getTemplateService() {
        return templateService;

    public ApplicationConfig setTemplateService(TemplateService templateService) {
        this.templateService = templateService;
        return this;

    private TemplateService templateService;

Open in new window

public class TemplateService {

    private final WorkflowRepository workflowRepository;
    public TemplateService(
                           WorkflowRepository workflowRepository,
                          ) {
        this.workflowRepository = workflowRepository;


    public Workflow saveWorkflow(Workflow workflow) {

    public Workflow getWorkflow(Integer id) {
        return workflowRepository.getWorkflowById(id);

Open in new window

In the spring web application i think spring automatically initializes the workflowRepository but how will i do that when instantiating in the Junit.
What do i pass in the templateService constructor.

public interface WorkflowRepository extends CrudRepository<Workflow, Integer> {
    Workflow getWorkflowById(Integer id);

    List<Workflow> getWorkflowByWorkflowTemplate(WorkflowTemplate workflowTemplate);

    List<Workflow> getWorkflowByInitiatorOrderByCreatedOnDesc(WorkflowUser workflowUser);

Open in new window


Please help in getting me the Whole templateService Object.
I have written own OwnInterceptor extending HandlerInterceptorAdapter

Below are the two cases where error needs to be throw

1. URL is not protected where the URL is typed on the browser tab and hit by the user
2. URL is not protected where the URL is being invoked when a user clicks the button on submit on a form

a. i have used throw new ModelAndViewDefiningException(modelAndView); which doesn't work in all cases where i can redirected to error page in modelAndView

b. so i have added response.setStatus(HttpServletResponse.SC_FORBIDDEN);
response.setHeader("Location", errorPageURL);

after adding the header it seems works fine and not sure whether any of the use cases will break.

Please let me know your feedback and comments

I am completely new to Java and have installed Netbeans, however when I select File then New Project it doesn't do anything.
If I click on File then open Project it does open an explorer window, but I have nothing to open and I can;t get started
Before Spring Boot version 2.0 and Spring 5.0 we used the following code and it works perfectly fine without any issues.

public TomcatEmbeddedServletContainerFactory
tomcatEmbeddedServletContainerFactory() {
return new TomcatEmbeddedServletContainerFactory(){
    protected void customizeConnector(Connector connector) {
We have upgraded to Spring boot version 2.0 and Spring 5.0

Now after upgrading to Spring boot 2.0 and Spring 5.0 we no longer find the corresponding classes.

Can somebody help me with the equivalent package or newer maven pom.xml information to fix it ?

Equivalent interceptor to (org.jboss.resteasy.spi.interception.PreProcessInterceptor ) (

Trying to find a interceptor with code snippet to get the user and check whether he has permission to access the requested URL

1. Equivalent interceptor to in Spring MVC
2. Interceptor code to authorize user action

Java EE





Java Enterprise Edition (Java EE) is a specification defining a collection of Java-based server and client technologies and how they interoperate. Java EE specifies server and client architectures and uses profiles to define technology sets targeted at specific classes of applications. All Java EE profiles share a set of common features, such as naming and resource injection, packaging rules and security requirements.

Top Experts In
Java EE