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

I have create Database in my Localhost in mysql Server by phpmyadmin. where i have define no any privileges for the database. when i made live this db on the Hostech Server provider phpmyadmin al tables where successfully imported and  in the Case of views it is showing  me the following error.
"#1227 - Access denied; you need (at least one of) the SUPER privilege(s) for this operation".

This is the example of the views query that i have to upload on my live DB server from my local server .
"CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `crqry_bomoils`  AS  select
`qry_bom`.`FormulaID` AS `FormulaID`,`qry_bom`.`Code` AS `Code`,`qry_bom`.`MaxOfRevision` AS `MaxOfRevision`,`qry_bom`.`Revision` AS
`Revision`,`qry_bom`.`FormulaName` AS `FormulaName`,`qry_bom`.`Group` AS `Group`,`qry_bom`.`FragranceID` AS
`FragranceID`,`qry_bom`.`Qty` AS `Qty`,`qry_bom`.`FragranceName` AS `FragranceName`,`qry_bom`.`Flag` AS `Flag`,`qry_bom`.`CAS1` AS
`CAS1` from `qry_bom` where (`qry_bom`.`Group` = 'ESSENTIAL OIL') order by `qry_bom`.`FragranceName` ".

1:Main Question is that how can i make live my database with my views that i have created on my Localhost server.??
2:How can i import my  database with views  from my localhost server that should be import on any other mysql server without any privileges errors ??

Thanks In Advance!
0
Cloud Training Guides
Cloud Training Guides

FREE GUIDES: In-depth and hand-crafted Linux, AWS, OpenStack, DevOps, Azure, and Cloud training guides created by Linux Academy instructors and the community.

import java.util.*;
import java.util.stream.*;
public class X {
	public static void main(String[] args) {
		List<String> list = Arrays.asList("xxax", "xbxbx", "xxcx", "zzz");
		System.out.println(noX(list));
	}
	public static List<String> noX(List<String> strings) {
		return strings.stream().map(s -> s.replaceAll("x","")).collect(Collectors.toList());
    }	
}

Open in new window

in above program what are Collectors , stream, collect methods. And why map is used in this lamda functional examples
0
Hi,

http://codingbat.com/prob/p105967

I wrote my code as below and failing some tests
public List<String> noX(List<String> strings) {
   strings.replaceAll(x -> "");
  return strings;
}

Open in new window



Expected	Run		
noX(["ax", "bb", "cx"]) → ["a", "bb", "c"]	["", "", ""]	X	
noX(["xxax", "xbxbx", "xxcx"]) → ["a", "bb", "c"]	["", "", ""]	X	
noX(["x"]) → [""]	[""]	OK	
noX([""]) → [""]	[""]	OK	
noX([]) → []	[]	OK	
noX(["the", "taxi"]) → ["the", "tai"]	["", ""]	X	
noX(["the", "xxtxaxixxx"]) → ["the", "tai"]	["", ""]	X	
noX(["this", "is", "the", "x"]) → ["this", "is", "the", ""]	["", "", "", ""]	X	
other tests
		X	

Open in new window


how to fix and improve my code, please advise
0
Hi,

I am trying to double list numbers using functionala lamda programming


http://codingbat.com/prob/p117665
Given a list of integers, return a list where each integer is multiplied by 2.

doubling([1, 2, 3]) → [2, 4, 6]
doubling([6, 8, 6, 8, -1]) → [12, 16, 12, 16, -2]
doubling([]) → []

Open in new window


Solution:

public List<Integer> doubling(List<Integer> nums) {
  nums.replaceAll(n -> n * 2);
  return nums;
  
  // OR the equivalent java streams solution:
  // return nums.stream()
  //  .map(n -> n * 2)
  //  .collect(Collectors.toList());
}

Open in new window

i am trying to write a java a program to execute it in exclipse to see result in eclipise consoel

import java.util.List;

public class FuncProgDouble {
	public static void main(String[] args) {
		List<Integer> li=[1, 2, 3];
		System.out.println(doubling(li));
	}

	
	public static List<Integer> doubling(List<Integer> nums) {
	  nums.replaceAll(n -> n * 2);
	  return nums;
}

	
}

Open in new window


i am getting below compilation error.

Multiple markers at this line
      - Syntax error on token "]", } expected
      - Type mismatch: cannot convert from int[] to
       List<Integer>
      - Syntax error on token "[", { expected

canont i add primitives as below to Integer list


import java.util.ArrayList;
import java.util.List;

public class FuncProgDouble {
      public static void main(String[] args) {
            
            
            ArrayList<Integer> al=new ArrayList<Integer>();  
            al.add("1");  
            al.addAll("3");  
            al.addAll("8");  
            //al.add(1,"Sachin");
            
            //List<Integer> li=[1, 2, 3];
            System.out.println(doubling(al));
      }

      
      public static List<Integer> doubling(List<Integer> nums) {
        nums.replaceAll(n -> n * 2);
        return nums;
}

      
}

please advise
0
padserver/padErr.txt

==> /usr/local/pad/padserver/padOut.txt <==

---- java.library.path   ../lib/dll;/usr/local/pad\lib\dll\sys32

---- java.ext.dirs   /usr/java/jdk1.7.0_79/jre/lib/ext:/usr/local/pad/lib/ext



 checkFileInPath jspWin.dll   exists false

 checkFileInPath x25lyra.dll   exists false




==> /usr/local/pad/padserver/padErr.txt <==

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space


Hi Experts

we get above Java heap space error on our servers due to this we face other issues on server. kindly help.
0
I am doing below challenge

http://codingbat.com/prob/p128270
public int[] front11(int[] a, int[] b) {
   //int[] z;
  if(a.length>0&&b.length>0){
 
 // z[0]=a[0];
 // z[1]=b[0];
 // return z;
   return new int[]{a[0],b[0]};
  }
   else if(a.length>=0&&b.length==0){
  // int[] z=new int[2];
  //z[0]=a[0];
  //z[1]=b[0];
  return new int[]{a[0]};
  }
  else if(a.length==0&&b.length>=0){
  // int[] z=new int[2];
 // z[0]=a[0];
 // z[0]=b[0];
 // return z;
   return new int[]{b[0]};
  }
  return new int[0];
  
}

Open in new window


i am failing one
how to improrve my code
Expected      Run            
front11([1, 2, 3], [7, 9, 8]) → [1, 7]      [1, 7]      OK      
front11([1], [2]) → [1, 2]      [1, 2]      OK      
front11([1, 7], []) → [1]      [1]      OK      
front11([], [2, 8]) → [2]      [2]      OK      
front11([], []) → []      ArrayIndexOutOfBoundsException: 0 (line:14)      X      
front11([3], [1, 4, 1, 9]) → [3, 1]      [3, 1]      OK      
front11([1, 4, 1, 9], []) → [1]      [1]      OK      
other tests
OK      
please advise
0
Hi,

I was working on below challenge again

http://codingbat.com/prob/p151359
public String withoutX2(String str) {
  
  if(str.length()==1&&str.charAt(0)=='x'){
    return "";
  }
  if(str.length()>=2){
  if ( str.charAt(0)=='x' && str.charAt(1)=='x' ){
  return str.substring(2);
  }else if(str.charAt(0)=='x'){
      return str.substring(1);
  }else if(str.charAt(1)=='x'){
      return str.substring(0,1)+str.substring(2);
  }
  }
  return str;
}

Open in new window

below code passes all tests
Expected      Run            
withoutX2("xHi") → "Hi"      "Hi"      OK      
withoutX2("Hxi") → "Hi"      "Hi"      OK      
withoutX2("Hi") → "Hi"      "Hi"      OK      
withoutX2("xxHi") → "Hi"      "Hi"      OK      
withoutX2("Hix") → "Hix"      "Hix"      OK      
withoutX2("xaxb") → "axb"      "axb"      OK      
withoutX2("xx") → ""      ""      OK      
withoutX2("x") → ""      ""      OK      
withoutX2("") → ""      ""      OK      
withoutX2("Hello") → "Hello"      "Hello"      OK      
withoutX2("Hexllo") → "Hexllo"      "Hexllo"      OK      
withoutX2("xHxllo") → "Hxllo"      "Hxllo"      OK      
other tests
OK      

But if i have input say z what would be output and my code fails in that scenario right

withoutX2("z") → z
public class WithoutX2 {

	public static void main(String[] args) {
		
		// TODO Auto-generated method stub
		System.out.println("Value is"+withoutX2("z"));//should get true but getting false
	}
	
	public static String withoutX2(String str) {
		  
		  if(str.length()==1&&str.charAt(0)=='x'){
		    return "";
		  }
		  if(str.length()>=2){
		  if ( str.charAt(0)=='x' && str.charAt(1)=='x' ){
		  return str.substring(2);
		  }else if(str.charAt(0)=='x'){
		      return str.substring(1);
		  }else if(str.charAt(1)=='x'){
		      return str.substring(0,1)+str.substring(2);
		  }
		  }
		  return str;
		}


}

Open in new window

0
Difference Between Path Parameter and query parameter in web service
0
Hello Sirs,

I have CSRF protection enabled, and CSRF parameters added to my login JSP view.
My question is the following: Should add CSRF parameters to the rest of my JSP view that involve form submission?

I am looking forward to hearing from you.
0
Hi,

What is the use of below command from eclipse project by right clicking and run as "maven build.."

what is meaning of shade why we need to give in the goal?

please advise
0
Use Filtering Commands to Process Files in Linux
Use Filtering Commands to Process Files in Linux

Learn how to manipulate data with the help of various filtering commands such as `cat`, `fmt`, `pr`, and others in Linux.

How to visualize call hierarchy in java using a pencil and paper all the way from beginning till end from UI to say model to controllers to dao to db calls etc including which object go in method and where the values changing etc in the new project

Please advise
0
Hi,
I am looking for String Format Method example using various date formats
https://www.javatpoint.com/java-string-format.

I found above link but no example there using the date format though like MMDDYYYY or YYYYMMDD etc to represent date?
please advise
0
HI,
If i have a class anotated with say @Component or @Service annotation...
And i autowire this in two other classes will the class hold the same object  or does spring creates a new instance of class everytime we do autowire ?

Thanks
0
Hi,
I have a class in which i am Autowiring a controller object like this :

@Component
public class Test {

@Autowired
XController xController;


public String method() {
    return xController.method();
}

Are there any issues with this approach as generally i dont see any controller object autowired anywhere..
Thanks
0
Hi,

When i right click on junit test(say ProductWeightTest.java) and run as Junit test from eclipse i keep getting popup with error

error could not create the java virtual machine error a fatal exception has occurred. program will exit



when i run individual test (checkWeightLessthan10Lb) in above test ProductWeightTest.java  i keep getting initialization error in eclipse console.

i tried changing eclise .ini entries but still getting same error. please advise
0
when i run junit test class getting initializationError Runner: Junit 4

not sure why suddenly i am getting that error and how to resolve it.

please advise
0
Hi,

I have a setter method(setBeginDate) that changed by some one from calendar date object to String object.

now i have to change my unit test to reflect that by changing to String.

articleVisibleData.setBeginDate(setDateMonthYear(30, 1, 2015));

How i edit method above so that i get String

earlier method is

            public Calendar setDateMonthYear(int day, int month, int year) {
            Calendar cal = GregorianCalendar.getInstance();
            cal.clear();
            cal.set(Calendar.DAY_OF_MONTH, day);
            cal.set(Calendar.MONTH, month);
            cal.set(Calendar.YEAR, year);
            return cal;
      }

now i am trying like below but wont work


      public String setDateMonthYear(int day, int month, int year) {
            String str="";
            str= str.concatenate(date).concatenate(month).concatenate(year)
            return str;
      }


earlier from test case i used to call like

articleVisibleData.setDate(setDateMonthYear(30, 1, 2015));

please advise
0
HI,
I have a class :
@Service
public class BotMessage {
        private ExecutorService executorService = Executors.newFixedThreadPool(1);
  public void SendMessage(String message) {
        executorService.submit(() -> sendMessage(message));
    }
}

And i have the following code in a differnt class: 
    private ExecutorService executorService = Executors.newFixedThreadPool(10);
    List<User> userList;
for(int i = 0;i<100;i++){
    User user = userList.get(i);
    executorService.submit(new Task(user));
}

Inside Task there is a run function :

run()  {
    
for(int i = 0; i<100;i++){
    botMessage.sendMessage(i.toString());
}

}


Now for each Task.. As the executorService in BotMessage is having a ThreadPool size of 1 .. The messages passed to sendMessage will be queued and will run one after the other... Which is what i want.. The actual scenario is that theses message will be sent to botMessage based on timestamp and so want it to send in the exact order of timestamp therefore the fixedPool of size 1 is required in botMessage.. Otherwise messages may be delivered out of order...


But The issue is this also blocks the other Tasks... Although each user Task runs in a separte thread of its own but internally calls botMessage.sendMessage... So the same queue will contain messages for user1 and user 2,.....

In an ideal case i would only want a queue per user... And not have it mingled like in the above case..
How do i achieve this..
One way i can think of is probably to …
0
HI,
I have the following code : 
The below code is set to execute every 15 minutes.... 
query table for state, date
if(state === completed) {
    update state to pending
    process()
}
Once the process() function is called it internaly invokes ExecutorService.submit(task)..around 100 such tasks in a loop.
What i want to do is after all the threads are processed i want to update the table state and date to completed, now()
There is an issue with it
     What if say for some reason while inside process()  the program crashes... or the system say shutsdown leaving the table state in pending state forever... Now in this case as state will always be pending state... And the code will never get executed again..
     How to avoid this situation...
     Thanks
0
More Than Just A Video Library
More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Hi,
There is a function process which does the following
        for(i = 0;i<100;i++){
        executorservice.submit(task);
        }
       once all the threads have finished there tasks i want to update a table.. How do i know if all the threads have finished the tasks...As the process function will comeout once the threads have finished the task. so probably i need to put a listener somewhere.

Thanks

Thanks
0
Hi,

I have a table which stores date and a state = pending or completed

what i want to do is query the table fetch the date and state...
If the state = completed...
    updates the state to pending
    Then call process()  which in turn invokes threads..
     Once the process() is done execution of all threads..
    update the state to completed and date to now()

    This is what i want to achieve...

    There is following issue with it.

 If my code is running on two different servers...They both will query the same table.. and may see the state as completed... And may start the process().... The issue is both will start the process() which is not what i want...
    The two servers are just for redundancy... And at a time only one should be executing the proces...
    How do i achieve this ?

Thanks
0
HI,
In my spring web application there is a class like : 

[code]
@Service
class BotMessage {
    private ExecutorService executorService = Executors.newFixedThreadPool(1);
     public void sendMessage(message) {
     executorService.submit(() -> sendMessage(message));
}
}
[/code]

In another class : 
[code]
@Service
Public class PullService {
    private ExecutorService executorService = Executors.newFixedThreadPool(10);
   public void pull(Date date) {
        List<UserInfo> getAllUsers = userTokenService.getAllUsers();
        getAllUsers.forEach((o) -> {
                        pullGlobalNotification(o, date, accessToken);
                  }
}
}


 private void pullGlobalNotification(UserInfo userInfo, Date date, String accessToken) {
            GitHub gitHub = githubCache.getIfPresent(userInfo.getUserId());
            executorService.submit(notificationTask);
}[/code]

Now this notificationTask has a run function() {
for(int i = 0;i<10;i++)
botMessage.sendMessage(i.toString());
}

What i am wondering is since botMessage.sendMessage uses an executor with size 1.
now at i = 0 sendMessage will internally call  [b]executorService.submit(() -> sendMessage(message));
[/b]
At i = 1... Will the call to [b]executorService.submit(() -> sendMessage(message));[/b] block if the previous call is still running  as the size of executor is 1. Also will it get queued in the executor and the loop will still continue ? What should be the ideal size in this case.. As this function may be …
0
Hi,

I am reading below link on EJB
https://examples.javacodegeeks.com/enterprise-java/ejb3/ejb-tutorial-beginners/

It is less resource intensive as compared to entity beans. Session bean gets destroyed as soon as user session terminates.

i wonder why session bean is less resource intensive compared to entity bean.

The EJB 3.1 specification introduces @Stateless annotation that enables you to easily create stateless session beans. A stateless session bean as per its name does not have any associated client state, but it may preserve its instance state.



what is difference between client state and instance state?

5. Create a sample Session Bean
The EJB 3.1 specification introduces @Stateless annotation that enables you to easily create stateless session beans. A stateless session bean as per its name does not have any associated client state, but it may preserve its instance state. EJB Container normally creates a pool of few stateless bean’s objects and use these objects to process client’s request.
To create the stateless session bean, perform the following steps.
Right-click the EJB module and choose New > Other to open the New File wizard.
Select Session Bean in the Enterprise JavaBeans category. Click Next.

i do not see option like Session Bean as attached .

i do not see below option
Browse Customer entity for the Return Type and add parameter firstName and lastName.
i cannot see Customer being autopopulated?

please advise
sessionBean.PNG
sessionBean2.PNG
0
Hi,
I have around 3-4 Html pages... This is basically a Thymeleaf document in a spring web application...
The only thing that differs in all the three. is the top line... Some dont have any...
Some have a different sentence  and some have a different color in the sentence...
Now i obviously dont want to keep all the 4 html pages.. As this would be a lot of duplicacy...
What are the ways i can handle such a case...
One i can think of is a set of if else statement in the html page... And depending on the parameter being passed choose the approapriate heading...

Is there any alternative better way for the same ?

Thanks
0
HI,
In my java spring application... There are soem files of around 800 lines...
Does that indicate a bad code design.. What are the factors i should consider to shorten the files and split them into two ?
Whats the ideal maximum file length ?

Thanks
0

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.