Go Premium for a chance to win a PS4. Enter to Win

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

Hi,

I'm currently facing the following issue with a javafx-application under NetBeans IDE.

When I'm adding a specific maven dependy (bcprov158- bouncycastle provider), I can't build program anymore:

failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project

Does anyone know how to solve this?

Klaus
0
Industry Leaders: We Want Your Opinion!
Industry Leaders: 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!

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
i have a hibernate entity class
class task

private tasktemplate

class tasktemplate
private contactinfo

now when i fetch a task.
i do get the tasktemplate object.
but the contactinfo i get as null.

whereas if i fetch the tasktemplate directly then i do get the contactinfo object.
this contactinfo is a custom type which i am storing as json.
what could be the reason for this that when i am fetching it directly i get the proper data and when its inside as a reference a foreign key then i get it as null.
also this is only for custom types
there are other attributes in tasktemplate like normal string etc. they do get fetched.
i am using hibernate here

thanks
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 a hibernate class :
@Entity(name = "form")
public class FormTemplate {

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

    @Column
    @Type(type = "com.utils.JSONUserType", parameters =
            {@org.hibernate.annotations.Parameter(name = "classType", value = "java.util.List")})
    private List<String> possibleValues;

//it has all the getters and setters.

}

Open in new window



Here is the jsonusertype class :

public class JSONUserType 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 = ReflectHelper.classForName(classTypeName, this.getClass());
        } catch (ClassNotFoundException cnfe) {
            throw new HibernateException("classType not found", cnfe);
        }
        String type = params.getProperty(TYPE);
        if (type != null) {
            this.sqlType = Integer.decode(type);
        }
    }

Open in new window

0
Hi,
I have a userinfo hibernate class
class userinfo {
@Id

@GeneratedValue(strategy = GenerationType.AUTO)

private Integer id;
@Column
String guid;
}

The guid is the unique userId for each user registered inside my application.
Now i use this class in another class Comments  which will be made by some user..
ex :
class comments {
 @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
   private Integer id;
   @Column
String comment;
@ManyToOne
userinfo user;
}

This is the current design. now i will get an api call when a user inside my application sends a comment.
so i was considering to send the following json from client side :
{
      "guid" : "sfsdf",
      "comment" : "random comment"
}

Now for storing this into the comments table.
I need the userinfo class element.
This will require a db query into userInfo table to fetch the userInfo corresponding to the guid. and then will insert the data
into comments table.
So there is an extra query involved. Is there any way to avoid it ?
Also is the above DB design good or there is an alternative better way ?

Thanks
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 have the following enum :
public enum FieldType {
    Input,
    TextArea,
    DropDown,
    MultiSelect,
    Attachment,
    DatePicker
}

And
@Enumerated(EnumType.STRING)

private FieldType fieldType;
I am using hibernate.
The table that gets created has the column :
FieldType : varchar(255)
It should have been an Enum. Why it didnt get created as enum.
Thanks
0
Hi,
I am having the following interface :
public interface WorkplateRepository extends CrudRepository<Workplate, Integer> {
    Workplate getWorkplateById(Integer id);
}

Open in new window

whats the use of CrudRepository ??

Also in the spring code i see it being used like :
@Service
public class Teice {

    private final WorkplateRepository workplateRepository;

    @Autowired
    public Teice(WorkplateRepository workplateRepository) {
        this.workflowTemplateRepository = workflowTemplateRepository;
    }
Where from the instance of workplateRepository is getting created. Its only an interface ?
Althought on debugging i see that an instance of SimpleJPARepository is assigned to this variable.

Thanks
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
Free Tool: Subnet Calculator
LVL 11
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.

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
I see the below exeception without much details. Not sure the root cause of it
javax.servlet.ServletException
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at some.other.package.RoleRestoreFilter.doFilter(RoleRestoreFilter.java:115)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at some.package.SecurityFilter.doFilter(SecurityFilter.java:321)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:203)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
      at …
0
I am working in a new project on a complex GUI with Java 8 and Swing. We use among others the Container class that has a void add(Component comp, Object constraints) method that adds the component with constraints information. I want to build a dialogue with three panels, where pressing a button would result in switching the constraint information of the components that do not include the button object. How is it possible to switch the constraint information easily?
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE
LVL 5
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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

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.