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

Can an application use a JDBC driver that can contain the IP to both a primary and Standby instnace, so that the client can switch to standby if the primary IP is no longer reachable.

Or is there some other way an application can perform this

We are using an Oracle DB (Data Guard, primary and standby), but I am asking this from a client application failover to the correct DB instance, as opposed to a db failover
Free Tool: Subnet Calculator
LVL 12
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

I'm currently using Roaster to generate a rest class, but i don't know how to implements http annotation (Get, Post,..) ?

Here's what I was trying to generate them with :

public class RestGenerator {
     public static void main(String[] args) {  

    JavaClassSource source = Roaster.create(JavaClassSource.class);
    source.addMethod().setName("Create").setPrivate().setBody("return null;")

    source.addMethod().setName("Delete").setPrivate().setBody("return null;")

output :

public class RestController

   private void Create()
      return null;

   private void Delete()
      return null;
Best Approach to validate the current action

1. Saving user details on login in the user session. For every action after login, check whether user has roles and permissions every time. DB needs to be queried since an administrator can change the privilege of the user any time. Query the roles and permissions of the current user and verify the operation every time.

2. Saving user details on login in the user session. For every action after login, check just the roles/permission associated with the session. DB doesn't needs to be queried. However if Administrator or any user changes the permission of the current user from different country invalidate the current user session which should be stored somewhere.

Which one would be the best approach on the above ?

Need sample code snippet for the above approaches and how to achieve it
When I deploy my ionic 2 application on the production server, I am getting the errors below. But when I run the application on the localhost, it runs fine.

vendor.js:1349 Uncaught SyntaxError: Unexpected token ?
main.js:1 Uncaught ReferenceError: webpackJsonp is not defined
    at main.js:1

Open in new window

hi am in oracle form 11gR2 i what to display a down arrow on top of my button how can i do that this arrow ↓ without using image
How to Write a simple application which will register a user and authenticate the user. You can use default H2 for database. Once authenticated, the user should be able to give a string to translate into the language he desires (French, German, Tamil versa. You can use Google or Microsoft Translate API.
We have a boolean column and we defined it as isActive.

The ajax request is success. However unable to bind the variable and exception is thrown

getter name is isActive() and setter name is setIsActive()

1. We don't want to rename the column as isActive to active
2. What should be the good setter and getter when the column is isActive ?
3. What should be the good setter and getter when the column is active ?

We are iterating 100k+ records from global temporary table.below stored procedure will iterate all records from glogal temp table one by one and has to process below 3-steps.

1)to see whether product is exists or not 2)to see whether product inside the assets are having the 'category' or not. 3)to see whether the assets are having file names starts with '%pdf%' or not.

So each record has to prcoess these 3-steps and final document names will be stored in the table for the successful record.if any error comes in any of the steps then error message will be stored for that record.

Below stored procedure is taking long time to process Because its processing sequentially.

1)Is there any way to make this process faster in the stored procedure itself by doing batch process? 2)If its not possible in stored procedure then Can we change this code into Java and run this code in multi threaded mode like creating 10 threads and each thread will take 1 record concurrently and process this code.I would be happy if somebody gis some pseudo code.

which approach is going to suggest?



CURSOR C2(v_isbn in varchar2) IS
        table1 ANP,
        table2 ANPP,
        table3 AN

Open in new window

1. What is BindingResult?
2. When to use BindingResult?
3. Assume @ControllerAdvice is used in a project to handle errors. How BindingResult can be retrieved or processed in @ControllerAdvice
4. Is BindingResult is used for only presentation validations or can be used for business validations as well ?
hi am in window 7 having this error The JDK wasn't found in directory C:\PROGRA~1\Java\jdk1.6.0_43. am not able to install or untill the java software am geting this error
Hire Technology Freelancers with Gigs
LVL 12
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Spring SAML security: I need assistance to separate saml authentication with granting authorities. After authenticating against AD, I need to execute a web service call to retrieve user roles , prompt the user to select a role atnd then grant authorities to the user based on the role selected.
How do I go about achieving this?
Can  anyone please  help?I am new to Ant Builds.......Ant doesnt tell me which Class file is missing.

C:\DEV\WebappCOBRA\int\ECSBuild\build\masterbuild.xml:107: The following error occurred while executing this line:
C:\DEV\WebappCOBRA\int\ECSBuild\build\masterbuild.xml:113: The following error occurred while executing this line:
C:\DEV\WebappCOBRA\int\ECSBuild\build\masterbuild.xml:331: The following error occurred while executing this line: C:\DEV\WebappCOBRA\int\${target-project}\build\build.xml (The system cannot find the path specified.)....

Open in new window

Dear sirs,
I am setting up a global exception handler in Spring. Once an exception is caught, a method in the @ControllerAdvice is called in, and returns a specific view with exception details. Among info returned with the view, I have the HttpStatus, that can get. Actually I keep getting 200, while the right HttpStatus should be 500, 404, etc.
Here is my code
public class AppGlobalExceptionHandler {
       * Note: You can either point to Exception Types or Http ResponseStatus
       * @ExceptionHandler({MyException.class})
       * public String ...
       * @ExceptionHandler
       * @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
       * public String
       * */
      public String handleAnyException(Exception exception, Model model,
                  HttpServletRequest request, HttpServletResponse response) {
            log.error("Request raised " + exception.getClass().getSimpleName());
            String details = ExceptionUtils.getStackTrace(exception);
            AppError error = new AppError();
            model.addAttribute(AppStringHandler.VARIABLE_URL_SUBMIT, AppStringHandler.URL_TASKS_SEND_EMAIL_500);
            model.addAttribute(AppStringHandler.VARIABLE_URL_REDIRECT, AppStringHandler.URL_ADMIN_REDIRECT);
            model.addAttribute(AppStringHandler.VIEW_ERROR_MODEL_ATTRIBUTE, error);
hi am having this error when starting node manager in window
my java version is
C:\Users\rdp>java -version
Picked up JAVA_TOOL_OPTIONS: -Djava.vendor="Sun Microsystems Inc."
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) Client VM (build 20.45-b01, mixed mode, sharing)
Can we follow the below approach for Spring MVC application ??

Accessing thread local for http session...Note: Each http session request will be bind to one thread...
Assume we have the following code

@RequestMapping("books", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public final class BookController {
  private final Map<String, Book> books = new HashMap<>();
  public ResponseEntity<Book> addBook(@RequestParam String title, @RequestParam String authorName) {
    String id = generateId();
    Book book = new Book(id, title, authorName);
    books.put(id, book);
    return ResponseEntity.created(URI.create("/books/" + id)).body(book);
  public ResponseEntity<Book> getBook(@PathVariable String id) {
    Book book = books.get(id);
    if (book == null)
      return ResponseEntity.notFound().build();
    return ResponseEntity.ok(book);
  public ResponseEntity<Book> updateBook(@PathVariable String id, @RequestParam String title, @RequestParam String authorName) {
    Book book = books.computeIfPresent(id, book -> book.withTitle(title).withAuthorName(authorName));
    if (book == null)
      return ResponseEntity.notFound().build();
    return ResponseEntity.ok(book);
  public ResponseEntity<Book> removeBook(@PathVariable String id) {
    Book book = map.remove(id);
    if (book == null)
      return ResponseEntity.notFound().build();
    return ResponseEntity.ok(book);

If I request DELETE /books/bbcff625a88e45fcaf28f2a535997982 …
Hi All,
I have created a maven project using IntelliJ IDEA.
The problem is that the dependencies are not downloading at all. My company has a proxy server which is configured in the IDE but still not downloading or updating anything.
Can u guys suggest some solution for this pls?

why we need below kind of entries in ejb.jar.xml for MDBs

					<activation-config-property-value>Ixy 'aaa'</activation-config-property-value>

Open in new window

what is importance of activation-config-property-value and how that is related to XSD and incoming messages to the system through the Active MQ of IBM

Please advise.
Assume we have login controller where we identify user, company, session id, time etc.,

Now we want to add all these info by default in logger messages

Do we need to use MDC variable to put the key and values and log4j properties file needs to be defined as {sessionId}

MDC.put("sessionId", "121212");

Is this is the right approach or we need to do in a different way ?

Free Tool: Site Down Detector
LVL 12
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

How to do log4j configuration to include the HttpServlet session variables to any log by default.

Assume i have 3 variables - session id, user name, user id, company id

I want all these variables to be printed in the log with date and logger severity for any log.

How to configure it to print all the above values ?

I am struggling with a problem on JSF Primefaces 6.0 where in I have main page which has the list of addresses and main save button. The list of addresses in displayed in data table and the user can click on the edit button to edit any row of the data table. The edit button opens a dialog popup where user can change the address attributes and the click on "OK" button which should updated the list grid data as well as updated the address object in the listgrid of the main bean.
Currently I am facing the problem where my changes in the address popup are not visible in the backing bean method.

Sample code :-

      <addresslistTable> bean:addressList
            <addressline1> value="variable.addressline1" onclick--> bean.getAddressById(

      <addressline1> value="bean.otherAddress.addressline1"  --> user can change this value
      <p:commandButton value="#{msg.common_save}" process="@this" action="#{bean.submit}" update=":main:addresslistTable" oncomplete="PF('addressDialog').hide()"/>

class bean {
Address otherAddress;

public getAddressById(addressId){
      otherAddress = getAddressFromDatabaseById(addressId);

public void submit(){
// here I am accesing the otherAddress.addressLine1 which is still showing be the old value


I am trying below example

When i try to run the MEssageSender class how it ran even though there is existing Queue on ActiveMQ called JCG_QUEUE

package com.activemq.sender;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;

public class MessageSender {
	//URL of the JMS server. DEFAULT_BROKER_URL will just mean that JMS server is on localhost
	private static String url = ActiveMQConnection.DEFAULT_BROKER_URL;
	// default broker URL is : tcp://localhost:61616"
	private static String subject = "JCG_QUEUE"; // Queue Name.You can create any/many queue names as per your requirement.	
	public static void main(String[] args) throws JMSException {		
		// Getting JMS connection from the server and starting it
		ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
		Connection connection = connectionFactory.createConnection();
		//Creating a non transactional session to send/receive JMS message.
		Session session = connection.createSession(false,
		//Destination represents here our queue 'JCG_QUEUE' on the JMS server. 

Open in new window

I write the code to print the pdf file using PrintService. but my printer has id and password. how should i set id and password in my code.

PrintService service = PrintServiceLookup.lookupDefaultPrintService();

                      System.out.println("Default printer: " + service);
                      FileInputStream in = new FileInputStream(new File("filepath"));

                      PrintRequestAttributeSet  pras = new HashPrintRequestAttributeSet();
                      pras.add(new Copies(1));

                      DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
                      Doc doc = new SimpleDoc(in, flavor, null);

                      DocPrintJob job = service.createPrintJob();
                      PrintJobWatcher pjw = new PrintJobWatcher(job);
                      job.print(doc, pras);
Using @ControllerAdvice we can create a global exception handler but not sure how to handle the following

1. Throw error and stays in the same page in some cases
2. Throws error and redirect to an error page in some cases

#1 - not sure how it is possible as the page should not be re-loaded fully. The user might have encountered a error on the internal form in a page. We are doing ajax calls.

I'm working in MVC application. I need to put/pass couple of values in the controller level and retrieve the same in the service or business layer or persistence layer.

Few said we need to defined security context which is accessible in presentation or in any layer.

Please let me know how to define and access it. Is there is a better way then security context?


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