Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x

Java EE

17K

Solutions

9K

Contributors

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

Dear sirs,
I would like to have a sample code demonstrating how to download a ZIP file using Spring RestTemplate.
I can do it using Jersey, I have hard time doing with Spring RestTemplate.
Please, assist
0
[Webinar On Demand] Database Backup and Recovery
LVL 11
[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

HI,
Following are the logs when i start my spring web application in IntellIj Idea. It takes around 5 minutes to start it in debug mode!!.. Dont know how do i fix it. Shouldnt take that long. Whereas if i just start it normally it takes only 13 seconds.
Connected to the target VM, address: '127.0.0.1:51462', transport: 'socket'
23:20:55.358 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
23:20:55.364 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/]
23:20:55.365 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/Users/robinsuri/Checkout/workflow-app/target/classes/]

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.9.RELEASE)

2017-12-12 23:20:56.324  INFO 77876 --- [  restartedMain] c.f.a.w.WorkflowAppApplication           : Starting WorkflowAppApplication on DDVMACROBINSU with PID 77876 (/Users/robinsuri/Checkout/workflow-app/target/classes started

Open in new window

0
Hi,
I want to populate data into the model from inside a controller.
Suppose there is a controller method  fetchResponse(Task task) That takes some Task object...
and returns a json TaskResponse object.

now here could be one implementation :

fetchResponse(Task task  @(RequestParam))
{

TaskResponse taskResponse = new TaskResponse(task);
return serialize taskResponse.
}

TaskResponse {

attributes.
.
.
.
TaskResponse(Task task)
{
populate attributes
}

This is one way in which all the attributes of the TaskResponse object will be filled inside the TaskResponse object which will be serialized and sent .

Please suggest any pros and cons of this aproach... Also any alternatives.

Thanks
0
Hi,
A user can mention another user on my page.. That is he just writes something like hello @rohit.
So i need to save this comment in Database. If i save the exact comment "hello @rohit" the problem is that if the user changes its display name from rohit to rohit1 This wont get reflected on the page..
So i need to store hello someId  which corresponds to the user.. And while returning the response i need to replace the id's with the name.
Please suggest exact ways how i can accomplish this... As obviously in the above the user may actually type in hello someId and so there should not be any parsing.
I have one approach but dont know if its effecient or work well..
a cooment like hello @rohit  will go in the db like hello <user>id</user>
Basically we will use a xml tag . And also convert the rest of the string which is hello here... may be encode it so that it doesnt mix with xml...And then while returning the response we just parse the user tag and replace every id with name.

Please suggest pros and cons of the above. And any alternative ways.
Thanks
0
Hello all,

Currently, i am using smb server but now I want to change it into afp server.

what will be the exact way to change it and connect using afp server?

currently these library are used in the project:
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;


Thanks in advance.

Regards
Amzad
1
hi am having this error when seting my java home am in window 7
[code]C:\Users\userpc>java -version
Error occurred during initialization of VM
Unable to load native library: Can't find dependent libraries


C:\Users\userpc>java -version
Error occurred during initialization of VM
Unable to load native library: Can't find dependent librarie

C:\Users\userpc>set JAVA_HOME=C:\java6

C:\Users\userpc>SET PATH=PATH%JAVA_HOME%\BIN;

C:\Users\userpc>JAVA -VERSION
'JAVA' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\userpc>java -version
'java' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\userpc>set JAVA_HOME=C:\java6

C:\Users\userpc>SET PATH=PATH%JAVA_HOME%/BIN;

C:\Users\userpc>java -version
'java' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\userpc>SET PATH=PATH%JAVA_HOME%;

C:\Users\userpc>java -version
'java' is not recognized as an internal or external command,
operable program or batch file.

Open in new window

[/code]
0
I'm following this LDAP authentication code

LDAP Authentication code

replaced parameters with my own parameters to authenticate  with OpenLDAP 2.4.31


public static void main(String[] args)
	{
		String username = "jsmith";
		String password = "password@123"; 
		String base = "ou=people,dc=nodomain";
		String dn = "uid=" + username + "," + base;
		String ldapURL = "ldap://xx.xx.xx.xx:389";

		// Setup environment for authenticating
		
		Hashtable<String, String> environment = 
			new Hashtable<String, String>();
		environment.put(Context.INITIAL_CONTEXT_FACTORY,
				"com.sun.jndi.ldap.LdapCtxFactory");
		environment.put(Context.PROVIDER_URL, ldapURL);
		environment.put(Context.SECURITY_AUTHENTICATION, "simple");
		environment.put(Context.SECURITY_PRINCIPAL, dn);
		environment.put(Context.SECURITY_CREDENTIALS, password);

		try
		{
			DirContext authContext = 
				new InitialDirContext(environment);
			System.out.println("authentication success!");
			
			// user is authenticated
			
		}
		catch (AuthenticationException ex)
		{
			System.out.println("authentication failed!");   // I'm getting this print
			// Authentication failed

		}
		catch (NamingException ex)
		{
			ex.printStackTrace();
		}
	}
}

Open in new window


I am getting authentication failure message . ..what I'm doing wrong ?  ..unable to find the root cause.
Do I need to send password encrypted  ?
0
Hi all,

I get the error in the below code in .NET schema validation. The schema file is shared by some one else using J2EE.  My client is .NET.

"Attribute name="nonEmptyString"  not allowed" => in xs:simpletype


<xs:element name="ID" minOccurs="1" nillable="false">
        <xs:simpleType   name="nonEmptyString">
          <xs:restriction base="xs:string">
            <xs:pattern value="(\s*[^\s]\s*)+"/>
            <xs:maxLength value="15"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>

Open in new window

0
Hi,
I have the following piece of code :
 @Column
    @Type(type = "com.JSONUType", parameters =
            {@Parameter(name = "classType", value = "com.ContactInfo")})

    private ContactInfo initiator;

And this info is getting stored in the form {"type" : "ALL"} in the mysql table.
The contactinfo is like :

[b]@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
        setterVisibility = JsonAutoDetect.Visibility.NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)[/b]
public class ContactInfo implements Serializable {

    public enum Type {
        NOT_SET,
        ALL,
        ASK_INITIATOR,
        CHANNEL,
        USERS_LIST,
        USER
    }

Open in new window


And JsonUType is fairly complex :
public class JSONUType implements UserType, ParameterizedType, Serializable {

    private static final long serialVersionUID = 1L;

    private static final ObjectMapper MAPPER = new ObjectMapper();

    private static final String CLASS_TYPE = "classType";
    private static final String TYPE = "type";

    private static final int[] SQL_TYPES = new int[] { Types.LONGVARCHAR, Types.CLOB, Types.BLOB };

    private Class<?> classType;
    private int sqlType = Types.LONGVARCHAR; // before any guessing

    @Override
    public void setParameterValues(Properties params) {
        String classTypeName = params.getProperty(CLASS_TYPE);
        try {
            this.classType = 

Open in new window

0
Hi,
I am using hibernate for persistence.
Here are the two classes which i am using as entities :

@Entity(name = "workflow_template")

public class WorkflowTemplate {

    
@Id
   
 @GeneratedValue(strategy = GenerationType.AUTO)
    
private Integer id;

    @OneToMany(cascade = {CascadeType.ALL})
    
@JoinColumn(name = "workflow_id")
    
@OrderColumn(name = "task_idx")
   
 private List<TaskTemplate> taskTemplates;

-----
@Entity(name = "task_template")

public class TaskTemplate {

    
@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
  
  private Integer id;

    
@ManyToOne
    @JoinColumn(name = "workflow_id", nullable = false)
    
private WorkflowTemplate workflowTemplate;


Open in new window


Now for deletion of the workFlowTemplate row i first need to delete the task template row and then delete the workflow_template row.
Is there a way where i could just specify delete the workflowTemplate row and it automatically deletes all the rest of such things which have a join in them.
0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Hi,
Suppose i make a json like {"name" : "xya", "title" :"sample"}
Now suppose someone wants to make this json and send it to the server without the title element.
There are two ways {"name" : "xya"} or {"name" : "xya", "title": null}
Now obviously it is upto the code at server side how it handles. But ideally i feel they should be handled in the same way. Or there is any reason to handle the two different. I mean in a well designed codebase should there be any difference in how this should be handled ?

Thanks
0
I am try to connect to web services and this show that error:

ERROR App Error sin controlar ---> com.sun.xml.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection refused: connect
      at com.sun.xml.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:132)
      at com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:223)
      at com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:145)
      at com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:110)
      at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
      at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
      at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
      at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
      at com.sun.xml.ws.client.Stub.process(Stub.java:463)
      at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:191)
      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:92)
      at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:161)
      at com.sun.proxy.$Proxy41.updateEmail(Unknown Source)
      at com.bancoexterior.sf.SF.actualizarMail(SF.java:73)
      at com.bancoexterior.SF.updateMail(SF.java:317)
      at com.bancoexterior.App.accion(App.java:253)
      at com.bancoexterior.App.main(App.java:140)
Caused by: …
0
Dear,
What driver to choose below, when creating Database connection, to connect to SQL server DB?
18r.png
0
Hi,
How to resolve this?

18c.png
0
hi,
 let us say i give some random number like 81349 on console i should see output as by ascending order of each digit in each line how to achieve that as well

     1
    3 3
   4 4 4
 8 8 8 8
9 9 9 9 9

how to to achive this
please advise
0
public class Main2 {
  public static void main(String args[]) {

    int len = 100;
    int key = 50;
    int k = 0;
    out: {
      for (int i = 0; i < len; i++) {
        for (int j = 0; j < len; j++) {
          if (i == key) {
            break out;
          }
          k += 1;
        }
      }
    }
    System.out.println(k);
  }
}

Open in new window


above code produced below output

5000



i am not clear on logic how it produced 5000
please advise
0
public class MainClassIndefiniteLoop {
  public static void main(String[] args) {

    OuterLoop: for (int i = 2;; i++) {
      for (int j = 2; j < i; j++) {
        if (i % j == 0) {
          continue OuterLoop;
        }
      }

      System.out.println(i);
      if (i == 107) {
        break;
      }
    }
  }
}

Open in new window


above code gave below output

2
3
5
7
11
13
17
19
23
29
31
37
41
43
47
53
59
61
67
71
73
79
83
89
97
101
103
107



i wonder why output shows haphazard

2
3
5
7


did not understood the logic. why 3 came after2 then 5 then 7 etc. please advise
0
public class MainClass {
	public static void main(String[] args) {
		int count = 50;

		for (int j = 1; j < count; j++) {
			if (count % j != 0) {
				System.out.println("i is"+j);
				System.out.println("Breaking!!");
				break;
			}
		}
	}
}

Open in new window


above code produced below output

i is3
Breaking!!



how to obtain same above output without break statement. please advise if there is any other alternate way of doing this?
0
public class Main {

	public static void main(String[] args) {
		int i = 0;
		switch (i) {
		case 0:
			int j = 1;
			switch (j) {
			case 0:
				System.out.println("i is 0, j is 0");
				break;
			case 1:
				System.out.println("i is 0, j is 1");
				break;
			default:
				System.out.println("nested default case!!");
			}
			break;
		default:
			System.out.println("No matching case found!!");
		}
	}
}

Open in new window

why above code produced below output

i is 0, j is 1


i is zero here right
so it should go to below case

switch (i) {
            case 0:


then all of sudden how it picked case 1 systtem.out.println as below

case 1:
                        System.out.println("i is 0, j is 1");
                        break;



please advise
0
Concerto Cloud for Software Providers & ISVs
LVL 5
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Hi,

can you please point me to any links, resources on nested loop examples with 4 or more for loops. Please advise
0
public class TestNestedFor4 {

	public static void main(String[] args) {
		
		for (int i = 1; i <= 5; i++) {
			for (int j = 1; j <= (5 - i); j++) {
			System.out.print(" ");
			}
			for (int k = 1; k <= i; k++) {
			System.out.print(i);
			}
			System.out.println();
			}
		}
}

Open in new window


above code produced below output with 3 nested for loops


          1
        22
      333
    4444
  55555

how to produce below output instead? please advise

    1
   22
  333
 4444
55555
0
package com.bharaththippireddy.trainings.jaxrs;

public class NestedFor2 {

	public static void main(String[] args) {

		for (int i = 1; i <= 10; i++) {
			for (int j = 1; j <= 5; j++) {
			System.out.print(j);
			}
			System.out.println();
			}
	}
}

Open in new window


what is difference between above and below code
package com.bharaththippireddy.trainings.jaxrs;

public class NestedFor2 {

	public static void main(String[] args) {

		for (int i = 1; i <= 10; i++) {
			for (int j = 1; i <= 5; j++) {
			System.out.print(j);
			}
			System.out.println();
			}
	}
}

Open in new window


both cases not getting any output but console seems running some empty lines continuously.
please advise
0
package com.bharaththippireddy.trainings.jaxrs;

public class NestedFor2 {

	public static void main(String[] args) {
		for (int i = 1; i <= 4; i++) {
			for (int j = 1; j <= 5; j++) {
				System.out.print("*");
			}
			System.out.println();
		}

	}
}

Open in new window


when i wrote above code and ran
package com.bharaththippireddy.trainings.jaxrs;

public class NestedFor2 {

      public static void main(String[] args) {
            for (int i = 1; i <= 4; i++) {
                  for (int j = 1; j <= 5; j++) {
                        System.out.print("*");
                  }
                  System.out.println();
            }

      }
}

i got below output

*****
*****
*****
*****


i cannot get above output without nested for loops right?
1
package com.bharaththippireddy.trainings.jaxrs;

public class NestedFor2 {

	public static void main(String[] args) {
		for (int i = 1; i <= 3; i++) {
			for (int j = 1; j <= 2; j++) {
			System.out.print("six");
			}
			}
			

}
}

Open in new window


what is difference between above and below program


package com.bharaththippireddy.trainings.jaxrs;

public class NestedFor2 {

	public static void main(String[] args) {
		for (int i = 1; i <= 3; i++) {
			for (int j = 1; j <= 2; j++) {
			System.out.println("six");
			}
			}
			

}
}

Open in new window


both cases i am getting same output as
six
six
six
six
six
six


when i run inside main class
package com.bharaththippireddy.trainings.jaxrs;

public class NestedFor2 {

      public static void main(String[] args) {
            for (int i = 1; i <= 3; i++) {
                  for (int j = 1; j <= 2; j++) {
                  System.out.print("six");
                  }
                  }
                  

}
}

please advise
0
hi,

https://www.cs.utexas.edu/users/scottm/cs305j/handouts/slides/Topic6NestedForLoops_4Up.pdf

I wonder why there is not println in below example but simply print without ln


What is the output of the following nested What is the output of the following nested for
loop?
for (int i = 1; i <= 6; i++) {
for (int j = 1; j <= i; j++) {
System.out.print("*");
}
System.out.println();
}


please advise
0

Java EE

17K

Solutions

9K

Contributors

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
<
Monthly
>