Add OrganizationalGroup from a Java Class
Hi,
I want to add a new Organizational Group with two roles.
How could I do it from a java class?
This is the code to add a role, but to add a Group with two roles??
DirOrganizationalRole organizationalRole = null;
organizationalRole = DirOrganizationalRole.create(directorySession, "Nombre del Rol", false, "Desc. del Rol");
Thanks in advance!!
This is the JAVA code to add a role:
DirOrganizationalRole organizationalRole = null;
organizationalRole = DirOrganizationalRole.create(directorySession, "Nombre del Rol", false, "Desc. del Rol");
And this to verify if the role exist:
DirOrganizationalRole organizationalRole = null;
organizationalRole = DirOrganizationalRole.fetch(directorySession, rol);
I have tried to do this with a DirOrganizationalGroup but I can't....
Exist any documentation about this classes?
Could anybody write a simple code example?
I think it's very easy....
DirOrganizationalGroup organizationalGroup = null;
organizationalGroup = DirOrganizationalGroup.create(directorySessionRol, "DirSubdir", "Grupo Directores y Subdirectores", null, null, true, true);
And the RoleAssigment??
Thanks!!
Similar Messages
-
Any difference in creating a web service from a java class or session bean?
Hi,
The JDeveloper tutorial at http://www.oracle.com/technology/obe/obe1013jdev/10131/devdepandmanagingws/devdepandmanagingws.htm demonstrates creating a web service from a plain java class. I'm wondering:
- Is it possible to create a web service from a stateless session bean instead of a java class? If so, what's the proper way to do this in JDeveloper? When I tried doing so in JDeveloper 10.1.3.0.4 (SU5) using the J2EE Web Service wizard, the wizard did not list the session bean in the Component To Publish dropdown (it does list any java classes available in the project). I can proceed by manually typing in the name of the session bean. After the wizard completes though, the @Stateless annotation that had been in my session bean class code is removed and replaced by a @WebService annotation. The end result is that it looks like it made no difference whether I had tried to create the web service from a session bean or plain java class as the annotations in the resulting web service code are the same (although if I had started from a session bean, the class for the web service still implements the Local/Remote EJB interface that the session bean originally implemented).
- Assuming it's possible to create a web service from a stateless session bean, is there any advantage/disadvantage creating a web service from a java class vs a stateless session bean? I'm creating the web service from scratch so I also need to either build the java class or stateless session bean the web service would be based on from scratch too.
Thanks for any ideas about this.Hi,
EJB Session beans (EJB 3.0) are deployed as WebServices by annotating the class with @WebService and the methds with @WebMethod (both tags require you to add the JSR-181 library to your project (available in the JDeveloper list of libraries)). Unlike the J2E WebService, the EJB session bean service is turned into a WebService upon deployment. This means you obtain teh WSDL file after deployment
- Assuming it's possible to create a web service from a stateless session bean, is there any advantage/disadvantage creating a web service from a java class vs a stateless session bean?
The difference is that EJB Session bean based web services are integrated with the J2EE container, which means that they can leverage container services like transaction handling, data sources, security, JMS etc.
Frank -
Executing one system command from one java class. ERROR. Please help me
Hello i am trying to add users into one linux machine using one jaav program but when i execute the java class the system doesn't show me any error and dont make anything.
The linux command, in the main of the class, is correct; from thelinux shell it runs well, but from the java class it doesn't run.
Can you help me please?
thanks
import java.io.*;
public class ejecutaUsuario {
/** Creates a new instance of ejecutaUsuario */
public ejecutaUsuario(String cmdline) {
try {
String line;
Process p = Runtime.getRuntime().exec(cmdline);
BufferedReader input =
new BufferedReader
(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
System.out.println(line);
input.close();
catch (Exception err) {
err.printStackTrace();
System.out.println(err);
public static void main(String argv[]) {
String passwd="hola";
String usuarioInterno="xxxxxx";
new ejecutaUsuario("/bin/sh useradd -p `openssl passwd -1 -salt 12345678 " + passwd + "` -d /home/" + usuarioInterno + " -m -s /bin/bash " + usuarioInterno);Try gettting the error input stream as well (getErrorStream()). Maybe you are getting output there.
You might want to try just executing the 'useradd' part, getting the output stream of that process, and then put the parameters of useradd into the outputstream.
Later
Cardwell -
How can I call a pop up window from a java class ?
Hi,
I am developing a web app. I would like to call a windoz pop up from a java class.
How can i do that ?
Thanksuser504072 wrote:
It was possible to do it in ASP .NET even from the server side with the method Page.ClientScript. What do you think what Page.ClientScript stands for?
I's an encapsulation for the JavaScript code required and hides the separation between frontend and backend. There was a reason why so many developers stick to the MVC-pattern wich ist violated here.
I did not know it is not possible to do the same thing in Java.I'ts not a task of the backend to layout the user interaction GUI.
bye
TPD -
How to call a Java class from another java class ??
Hi ..... can somebody plz tell me
How to call a Java Class from another Java Class assuming both in the same Package??
I want to call the entire Java Class (not any specific method only........I want all the functionalities of that class)
Please provide me some slotuions!!
Waiting for some fast replies!!
Regards
Smita MohantyHi Smita,
you just need to create an object of that class,thats it. Then you will be able to execute each and every method.
e.g.
you have developed A.java and B.java, both are in same package.
in implementaion of B.java
class B
A obj = new A();
//to access A's methods
A.method();
// to access A's variable
//either
A.variable= value.
//or
A.setvariable() or A.getvariable() -
Problem with return a ColdFusion query object from a Java class
Hi!
I need to return a ColdFusion query object from a Java class
using a JDBC result set ( java.sql.ResultSet);
I have tried to pass my JDBC result set in to the constructor
of the coldfusion.sql.QueryTable class with this code:
ColdFusion code
<cfset pra = createObject("java","QueryUtil").init()>
<cfset newQuery = CreateObject("java",
"coldfusion.sql.QueryTable")>
<cfset newQuery.init( pra.getColdFusionQuery () ) >
My java class execute a query to db and return QueryTable
Java code (QueryUtil.java)
import coldfusion.sql.QueryTable; // (CFusion.jar for class
QueryTable)
import com.allaire.cfx //(cfx.jar for class Query used from
QueryTable)
public class QueryUtil
public static coldfusion.sql.QueryTable
getColdFusionQuery(java.sql.ResultSet rs)
return new coldfusion.sql.QueryTable(rs);
but when i run cfm page and coldfusion server tries to
execute : "<cfset pra =
createObject("java","QueryUtil").init()>" this error appears:
Object Instantiation Exception.
An exception occurred when instantiating a java object. The
cause of this exception was that: coldfusion/sql/QueryTable.
If i try to execute QueryUtil.java with Eclipse all it works.
Also I have tried to return java.sql.ResultSet directly to
coldfusion.sql.QueryTable.init () with failure.
Do you know some other solution?ok
i print all my code
pratica.java execute a query to db and return a querytable
java class
import java.util.*;
import java.sql.*;
import coldfusion.sql.*;
public class Pratica {
private HashMap my;
private String URI,LOGIN,PWD,DRIVER;
private Connection conn=null;
//funzione init
//riceve due strutture converite in hashmap
// globals
// dbprop
public Pratica(HashMap globals,HashMap dbprop) {
my = new HashMap();
my.put("GLOBALS",globals);
my.put("DBPROP",dbprop);
URI = "jdbc:sqlserver://it-bra-s0016;databaseName=nmobl";
LOGIN = "usr_dev";
PWD = "developer";
DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
try{
// Carico il driver JDBC per la connessione con il database
MySQL
Class.forName(DRIVER);
/* Connessione alla base di dati */
conn=DriverManager.getConnection(URI,LOGIN,PWD);
if(conn!=null) System.out.println("Connection Successful!");
} catch (ClassNotFoundException e) {
// Could not find the database driver
System.out.print("\ndriver non trovato "+e.getMessage());
System.out.flush();
catch (SQLException e) {
// Could not connect to the database
System.out.print("\nConnessione fallita "+e.getMessage());
System.out.flush();
//funzione search
//riceve un hash map con i filtri di ricerca
public QueryTable search(/*HashMap arg*/) {
ResultSet rs=null;
Statement stmt=null;
QueryTable ret=null;
String query="SELECT * FROM TAN100pratiche";
try{
stmt = conn.createStatement();// Creo lo Statement per
l'esecuzione della query
rs=stmt.executeQuery(query);
// while (rs.next()) {
// System.out.println(rs.getString("descrizione"));
catch (Exception e) {
e.printStackTrace();
try {
ret = Pratica.RsToQueryTable(rs);
} catch (SQLException e) {
e.printStackTrace();
this.close();
return(ret);
// ret=this.RsToQuery(rs);
// this.close(); //chiude le connessioni,recordset e
statament
//retstruct CF vede HashMap come struct
//METODO DI TEST
public HashMap retstruct(){
return(my);
//conversione resultset to querytable
private static QueryTable RsToQueryTable(ResultSet rs)
throws SQLException{
return new QueryTable(rs);
//chiura resultset statament e connessione
private void close(){
try{
conn.close();
conn=null;
catch (Exception e) {
e.printStackTrace();
coldfusion code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN">
<html>
<head>
<title>Test JDBC CFML Using CFScript</title>
</head>
<body>
<cftry>
<cfset glb_map =
createObject("java","java.util.HashMap")>
<cfset dbprop_map =
createObject("java","java.util.HashMap")>
<cfset glb_map.init(glb)> <!---are passed from
another page--->
<cfset dbprop_map.init(glb["DBPROP"])>
<cfset pra =
createObject("java","Pratica").init(glb_map,dbprop_map)>
<cfset ourQuery
=createObject("java","coldfusion.sql.QueryTable").init(pra.search())>
<cfcatch>
<h2>Error - info below</h2>
<cfdump var="#cfcatch#"><cfabort>
</cfcatch>
</cftry>
<h2>Success - statement dumped below</h2>
<cfdump var="#ourQuery#">
</body>
</html>
error at line <cfset pra =
createObject("java","Pratica").init(glb_map,dbprop_map)>
An exception occurred when instantiating a java object. The
cause of this exception was that: coldfusion/sql/QueryTable.
----------------------------------------------------------------------- -
Help me which JNDIFactory to use to access EJB from a java class of JAR
I am confused in understanding the different JNDI factories
RMIInitialContextFactory, ApplicationInitialContextFactory and ApplicationClientInitialContextFactory
And the different namespaces like global, container local and component local.
Especially is there any relationship between the JNDI factories and the namespaces?
Or are they related to the deployment descriptors.
Because in application specific deployment descriptors (orion-ejb-jar.xml), we just map the JNDI location with the object (or its reference from ejb-jar.xml). We dont specify it can be accessed from this factory or that.
Shall we access an EJB from using any JNDI factory?
Specifically, I am stuck with what Factory to use to access an EJB from a Java class in a library (jar). The JAR is packaged with the EAR which contains the EJB Jar that I am trying to access.
THANK YOUEd,
As Robin said, I think you need code similar to this:
Context c = new InitialContext();
Object o = c.lookup("java:comp/env/Name");where Name is the name of your EJB as it appears in the "ejb-jar.xml"
deployment descriptor XML file.
Good Luck,
Avi. -
How to pass a "object" as a prameter from one java class to another java
hi experts, I want to know "How to pass and get object as a parameter from one java class to another java class". I tried follwoing code just check it and give suggetions..
import Budget.src.qrybean;
public class ConfirmBillPDF extends HttpServlet
qrybean db = new qrybean();
SimplePDFTable pdfTable = new SimplePDFTable();
pdfTable.simplePDFTableShow("2010","2011","1","2","1","131","102");
}Here i want to pass db with simplePDFTableShow method. simplePDFTableShow is in another java class. So how can i do this.
And also i want to know, how this obj will get.
please help me.
Edited by: andy_surya on Jul 14, 2010 7:51 AMHi andy_surya
what is this i am not understand
pdfTable.simplePDFTableShow("2010","2011","1","2","1","131","102");but i am try to solve your problem try this
qrybean db = new qrybean();
SimplePDFTable pdfTable = new SimplePDFTable();
pdfTable.simplePDFTableShow(db);and access like this in SimplePDFtable class update your method
simplePDFTable(qrybean tempDB)
// write your code
} -
Call Bean from normal java class
Dear Friends,
Is it ok to call an entity bean or session bean frm normal Java class.
(Java class is in the same application as the beans).
Is there a special way to lookup the beans from normal java classes.
Thanking You,
Chamal.it is ok and very commonly done.
Note that the simple java program must be running in the same local network. You cannot have the java program and EJBs distributed over internet. (I m not certain of it, but mostly I shoudl be correct. If you have the resources, try it out and let me know)
In most of the cases, EJBs are called by
1. A servlet
2. Another EJB
3. a simple java program.
In the first 2 cases, you can go for Local Interfaces (more so in the second case than the first). The reason being that the the client and server will be in the same JVM (typically the Application server). Thus, in the first case, if the Web container and the ejb container are in the same app server, EJBs can be local.
However, in the third case, it is unlikey that you will have the client runnng and the same jvm as the server, because the app server has its own jvm.
sample code (this method is being called from the main method of a simple java program. it is self explanatory):
public void processRequestForSessionBean()
System.out.println("REQUEST RECEIVED");
try
Hashtable nameHashtable = new Hashtable();
nameHashtable.put( Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory" );
nameHashtable.put( Context.PROVIDER_URL, "t3://localhost:7001" );
InitialContext context = new InitialContext(nameHashtable);
System.out.println("created initial context");
Object lookupObject = context.lookup("CustomerBean");
System.out.println("Got the lookup object");
CustomerDataHome home = (CustomerDataHome) PortableRemoteObject.narrow(lookupObject,
Class.forName("com.shiv.business.CustomerDataHome"));
System.out.println("Home interface");
customerData = home.create();
System.out.println("Remote Interface");
addDataToSB(customerData);
ArrayList namesList = customerData.getNames();
System.out.println(namesList.toString());
//customerData.remove();
catch (Exception exception)
System.out.println("FATAL ERRORS");
exception.printStackTrace();
} -
Running a Unix script from a Java class
I am trying to use SCP (Secure copy) to copy an xml file from my J2EE application to a remote Unix server using a Unix script. How can I run the Unix script from my Java class? I could not find any resource for this on the internet. Can someone help me with this please.
ThanksI am trying this below program ,but i am getting the error please help me
import com.jcraft.jsch.*;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.JSch;
//import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
//import com.jcraft.jsch.UserInfo;
import java.io.*;
public class testrad {
public static void main(String args[])
String user="usertvr";
String host="5.34.12.1";
String cmd="ls -l";
JSch jsch = new JSch();
try{
Session session=jsch.getSession(user,host,22);
session.setPassword("$yhaj23");
//UserInfo usrInfo=new MyUserInfo();
//session.setUserInfo(usrInfo);
session.connect();
Channel channel=session.openChannel("exec");
((ChannelExec) channel).setCommand(cmd);
channel.setXForwarding(true);
channel.connect();
//code
channel.setInputStream(System.in);
// channel.setOutputStream(System.out);
//((ChannelExec) channel).setErrStream(System.err);
InputStream in = channel.getInputStream();
channel.connect();
byte[] tmp = new byte[1024];
while (true)
while (in.available() > 0)
int i = in.read(tmp, 0, 1024);
if (i < 0)
break;
System.out.print(new String(tmp, 0, i));
if (channel.isClosed())
in.close();
// System.out.println("JSCH: exit-status: " +
//channel.getExitStatus());
break;
try
Thread.sleep(1000);
catch (Exception ee)
channel.disconnect();
session.disconnect();
}catch(Exception e)
{e.printStackTrace();
System.out.println("Exception"+e);}
/*public static class MyUserInfo implements UserInfo {
public String getPassword()
{ return "password"; }
public String getPassphrase()
{ return ""; }
public boolean promptPassword(String arg0)
{ return true; }
public boolean promptPassphrase(String arg0)
{ return true; }
public boolean promptYesNo(String arg0)
{ return true; }
public void showMessage(String arg0)
Here is the error
com.jcraft.jsch.JSchException: UnknownHostKey: 5.128.0.10. RSA key fingerprint is 02:a0:d6:c0:6f:69:2c:a9:a7:fa:7c:71:1c:60:ed:57
at com.jcraft.jsch.Session.checkHost(Unknown Source)
at com.jcraft.jsch.Session.connect(Unknown Source)
at com.jcraft.jsch.Session.connect(Unknown Source)
at testrad.main(testrad.java:23)
Exceptioncom.jcraft.jsch.JSchException: UnknownHostKey: 5.128.0.10. RSA key fingerprint is 02:a0:d6:c0:6f:69:2c:a9:a7:fa:7c:71:1c:60:ed:57
Can some one help me please.
I running this program from Windows to connect to remote unix boxes. -
Accessing managed-beans property from simple java class
I have managed bean that is registered in faces-config.xml:
<managed-bean>
<managed-bean-name>documentReportsBean</managed-bean-name>
<managed-bean-class>[myApp].beans.DocumentReportsBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
I want to access property of documentReportsBean from other java class without registering managed-property in faces-config. How can I do that?Thank you, what I needed was someone saying the right word. "ValueBinding" in this case.. :)
Two lines:
ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding("#{documentReportsBean}");
DocumentReportsBean pbean = (DocumentReportsBean) vb.getValue(FacesContext.getCurrentInstance());
gives my full control. Nice -
Accessing env-entry value from a java class
Hi,
I have my env-entry element declared in ejb-jar.xml like this
<env-entry>
<env-entry-name>ConfigFile</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>centaur</env-entry-value>
</env-entry>
and if I access that value from the EJB of that ejb-jar.xml, it is giving the right value. But when I am trying to retrieve the same from a java class, that is throwing exception "javax.naming.NameNotFoundException: Unable to resolve 'ConfigFile' Resolved ; remaining name 'ConfigFile'"
I think this is because env-entry has access to only EJB to maintain security?
or can env-entry elemenets cab be accessed outside the EJB and some thing I am doing wrong here?
can some one help me here?Hey Frank,
The JCo, DI API and DB are all on PL 18. I have found that the error only occurs for one business partner, and that business partner had a service contract added to it the day before the error started to occur. Also the business partner in question is the only business partner with a service contract which would explain why it is the only one experiencing these problems. It could be a coincidence but I will let you know what the outcome is.
Carla -
Calling another java class from a java class
Hi Friends,
I have a class tht works in 2 modes,depending upon which mode i am passing (gui or text) on the command line eg:
java myclass [mode]
I want to call this command from another java class,and i wrote this code:
try
Process theProcess =
Runtime.getRuntime().exec("java myclass "+args[0]);
catch(IOException e)
System.err.println("Error on exec() method");
e.printStackTrace();
}When i pass "gui" it works fine,but when i pass"text", the class completes and nothing shows up on the command prompt window,so can please somebody tell me how to make this work.
ThanksAs aniseed just pointed out, you could do something like this:
import javax.swing.*;
class Test extends JFrame {
public Test(String title) {
this.setTitle(title);
this.pack();
this.setSize(300, 300);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
public static void main(String[] argv) { new Test(argv[0]).setVisible(true); }
public class Test2 {
public static void main(String[] argv) {
Test.main(argv);
}Run it by executing this command:
java Test2 "Title of Frame"See if that's not what you're looking for ... -
How to execute a jsp instruction from a java class?
How to execute a jsp instruction from a java class?
Any help please.
Thank'sI'll detail my problem:
Supposing that I have a jsp file called: start.jsp
In the start.jsp I instanciated an object called global from the class Global ( for example ).
Then, I called a custom taglib:
<ix:mytag/>
In the suitable tld file: the mytag is defined:
<tag>
<tag class>Tag1<.....
The java file Tag1 has method:
doStartTag(){
// here is the problem
global.doSomeFunctions();
Okay, the problem is that the object gobal is not defined in the class Tag1. what to do?
I think that I have to pass the object global as a parameter to the class Tag1. How to do that?
Actually, the problem was to insert the follwoing in the doStartTag method:
doStartTag(){
pageContext.getOut().print("<%= hello world %>");
The output is <%= hello world %> not hello world.
Okay, the new problem is how to pass an object as a parameter to a class called from a tld file.
Any help please.
Thank's too much -
How to interact with a COM component from a Java class
Hi, could someone give a hint on what API I should explore in order to interact with a COM component from a Java class?
Thanks in advance
Luisjacob sounds nice...http://danadler.com/jacob/
Maybe you are looking for
-
Hey folks, I'm having some odd problems with DNS. Over the weekend I added a second ML server to my network. I changed the hostname on my original server from my FQDN to server1.domain.com. When I changed the hostname, the server created a new zone w
-
How to buy a single Print with iPhoto '09. I can't find the order option.
Hi, as it is stated on the "Options + Prices" on Apple's website you should be able to print single prints in the various sizes as it is shown here "Prints Right from iPhoto, you can order professionally printed color prints in the most popular sizes
-
This is doing my nut in lol Please help
-
Windows SMTP service - restrictions
Hi I have installed a SMTP service under IIS 6.0 in windows 2008 R2 I would like to know if is possible to restrict the SMPT traffic to specific domains Example: i only want that only relay traffic to google.com Thanks in advance.
-
When I click on a pdf file, it is black.