Print Service API Errors

Hi,
I am trying to use the new print services API's, I have a code example that will complie but failes at runtime.
I am using Wepshere develoment studio client for the Iseries (V4.00).
Can any one help me get this example running ?
Error Message >>
java.lang.NoClassDefFoundError: javax/print/PrintException
Exception in thread "main"
java.lang.NoClassDefFoundError: javax/print/DocFlavor
Exception in thread "main"
Example Code >>
import java.lang.*;
import java.io.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import javax.print.event.*;
public class Print01
static FileInputStream psStream;
public static void main(String[] args)
try
psStream = new FileInputStream("file.ps");
catch (FileNotFoundException ffne)
System.out.println(ffne.toString());
if (psStream == null)
return;
DocFlavor psInFormat = DocFlavor.INPUT_STREAM.POSTSCRIPT;
Doc myDoc = new SimpleDoc(psStream, psInFormat, null);
PrintRequestAttributeSet aset =
new HashPrintRequestAttributeSet();
aset.add(new Copies(5));
// aset.add(MediaSize.A4);
aset.add(Sides.DUPLEX);
PrintService[] services =
PrintServiceLookup.lookupPrintServices(psInFormat, aset);
if (services.length > 0)
DocPrintJob job = services[0].createPrintJob();
try
job.print(myDoc, aset);
catch (PrintException pe)
System.out.println(pe.toString());
Thanks

Looks like a runtime CLASSPATH problem...
Try to include this code in your main, and check that the version is the same as the one expected:
   System.out.println("JAVA VERSION  IS: " + System.getProperty("java.version"));

Similar Messages

  • Java Print Service API in Java Stored Procedure (Linux)

    Hi
    We are running an Oracle 10g database on Linux and I am in the proces of developing a java stored procedure which should utilize the Java Print Service API.
    I have made a simple stored procedure to list all available printers and the DocFlavors they support (se the code below).
    My problem is that no printers are listed. I have made a standalone java app. with the same code and executed it directly on the OS level of the Linux box through the Sun JDK 1.4.2 and here I get two printers.
    Is there any specific configuration I need to do to make it work?
    I am wondering if I need to grant specific authorisations through dbms_java for it to work...?
    Any help is greatlyh appreciated.
    ************************************** CODE BEGIN *************************************
    import javax.print.DocFlavor;
    import javax.print.PrintService;
    import javax.print.PrintServiceLookup;
    import javax.print.attribute.HashPrintRequestAttributeSet;
    import javax.print.attribute.PrintRequestAttributeSet;
    public class TestPrintService {
    public TestPrintService() {
    public static void listPrinters() {
    // Get all available printers and their supported DocFlavors
    PrintService[] pservices =
    PrintServiceLookup.lookupPrintServices(null, null);
    System.out.println("Printer services: " + pservices.length);
    for (int i = 0; i < pservices.length; i++) {
    PrintService pservice = pservices;
    System.err.println("Printer: " + pservice);
    DocFlavor[] docFlavors = pservice.getSupportedDocFlavors();
    for (int j = 0; j < docFlavors.length; j++) {
    DocFlavor docFlavor = docFlavors[j];
    System.err.println("DocFlavor " + docFlavor.toString());
    System.err.println();
    ************************************** CODE END *************************************
    Cheers,
    Jacob Vennervald

    Found this on Oracle support:
    Cannot List Available Printers From The Database Using A Java Stored Procedure [ID 372694.1]
    Applies to:
    Oracle Server - Enterprise Edition - Version: 10.1.0.4.0
    This problem can occur on any platform.
    Symptoms
    Able to list available printers on a machine when running Java code outside the Database.
    When running the same Java code inside the Database as a Java Stored Procedure, no printers are found.
    Cause
    Due to security restrictions, this is expected results.
    The Java Docs state:
    "Services which are registered by registerService(PrintService) will not be included in lookup
    results if a security manager is installed and its CheckPrintJobAccess() method denies access."
    Also from the documentation it states:
    "A PrintServiceLookup implementor is recommended to check for the SecurityManager.checkPrintJobAccess() to deny access to untrusted code. Following this recommended policy means that untrusted code may not be able to locate any print services. Downloaded applets are the most common example of untrusted code."
    Using the checkPrintJobAccess(); call, it does produce a Security Exception when run inside the Database but not when run outside. The exception can be viewed within the log file found in the UDUMP directory.
    Solution
    Run the following code to confirm obtaining available __printers can not be done...__
    This is the code to create the Java Stored Procedure
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "ListPrinters" AS
    import javax.print.*;
    public class ListPrinters {
    public static String AvailablePrinters(){
    String strList;
    PrintService[] pservices =PrintServiceLookup.lookupPrintServices(null,null);
    if (pservices.length > 0 )
    strList = pservices[0].getName();
    else
    strList = "No printers found";
    return strList;
    public static String listprinters() throws Exception {
    String listofprinters;
    try {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) sm.checkPrintJobAccess();
    catch (SecurityException ex) {
    System.err.println("Sorry. Printing is not allowed.");
    listofprinters = AvailablePrinters();
    return listofprinters;
    This is the PL/SQL Wrapper
    CREATE OR REPLACE FUNCTION Get_Printer_Test RETURN VARCHAR2 IS
    LANGUAGE JAVA
    NAME 'ListPrinters.listprinters() return String';
    This executes the code
    SQL> SELECT Get_Printer_Test FROM DUAL;
    GET_PRINTER_TEST
    No printers found
    This is the output found in the trace file in the UDUMP directory
    *** SESSION ID:(144.28) 2006-07-08 09:02:25.518
    Sorry. Printing is not allowed.

  • Turn off banner within Java Print Service API

    I have web services running on JBoss 4.0.5, which is running on IBM AIX 5.
    The issue I have is anytime I try to print something through Java Print Service within web services, there is always a banner, even though banner property is set to "never" on the print queue with AIX smitty. The bad news is that property value can be overwritten by applications, or by command line options with lp or lpr commands.
    Couldn't find any way or any attribute avaiable in Print Service API to diable banner printing. Currently only default attributes are used in document printing.
    Any help would be greatly appriciated!

    fermar84 wrote:
    Thanks for answering,
    Yes i totally agree with you. There is a per device basis. However you could think (and here i am letting my imagination fly) about categorizing devices, lets say all the digital cameras. Although it would still be per-device basis, some would have common commands like turn on, or turn off. Don't you think so?
    Now lets take a simple example, can a Java program turn off the computer where its running?
    Thanks in advance,
    FernandoDo I think all digital cameras expose an "on/off" API? No, I don't. Some may, they all may, but that's in no way a Java issue.
    Can a Java program turn off a PC? No. It can call native code to do so, but then it isn't Java doing the work. All of what you're talking about is very much platform-specific, and that's where Java is generally it's weakest

  • Printing Service API

    Since there appears to be no "printing" forum I assume it is ok to ask in the "advanced" forum?
    I am following the first example in the JPS API User Guide. I am trying to print a file I wrote with a FileWriter class. I'm having two problems (at least that I know about).
    First, when I call PrintServiceLookup.lookupPrintServices() nothing is returned to the array. When I call PrintServiceLookup.lookupDefaultPrintService() my printer is returned. It is an HP4000 attached to a network via jetdirect.
    Secondly, when I use the default print service I try to wrap the file in a FileReader class and pass that to the SimpleDoc (Using DocFlavor.READER.TEXT_PLAIN) but when I call the DocPrintJob.print() function I get a blank sheet of paper.
    Does anybody have a clue what I am missing, why the example wouldn't work?
    TIA
    Chuck Davis

    Chuck - there are other threads on this topic which might help - i posted a thread on it myself just yesterday. There are bugs in the JPS demo and errors in the docs - i have been in touch with the author (Rajesh) who is going to correct them.
    I didnt have the specific problem that you describe although it doesnt surprise me. I was getting patchy results from the supporteddocflavour method.

  • Printing chinese w/ Java Print Service API become garbled characters

    I'm using XP platform and I've a plain text file on my drive.
    Now, what I want to do is, to read the text file in, then print it, that's all.
    However, the printout become messy, just some garbled characters.
    I did try to change quite a different ways to read the file, but the printout is still messy.
    Is there anything wrong? Can somebody give me a help?
    package com.ysf.document.client.ups;
    import java.io.FileReader;
    import java.io.IOException;
    import javax.print.*;
    import javax.print.attribute.*;
    public class Class1
       public static void main(String[] args)
          String filename = "c:\\temp\\abcd.txt";
          DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
          PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
          // locate a print service that can handle it
          PrintService[] pservices = PrintServiceLookup.lookupPrintServices(flavor, aset);
          // create a print job for the chosen service
          int printnbr = 1;
          DocPrintJob pj = pservices[printnbr].createPrintJob();
          try
             int c;
             FileReader f = new FileReader(filename);
             StringBuffer buffer = new StringBuffer();
             c = f.read();
             while (c != -1)
                buffer.append((char) c);
                c = f.read();
             Doc doc = new SimpleDoc(buffer.toString().getBytes("BIG5"), flavor, null);
             pj.print(doc, aset);
          } catch (IOException ie)
             System.err.println(ie);
          } catch (PrintException e)
             System.err.println(e);
    }

    For #1, indeed, it's my overlook, I've corrected it already.
    For #2, it shows, java.lang.ArrayIndexOutOfBoundsException: 1.
    It's mainly because my printer do not support this flavor.
    My printer supports only:
    image/gif
    [B OR java.io.InputStream OR java.net.URL
    image/jpeg
    [B OR java.io.InputStream java.net.URL
    image/png
    [B OR java.io.InputStream OR java.net.URL
    application/x-java-jvm-local-objectref
    java.awt.print.Pageable OR java.awt.print.Printable
    application/octet-stream
    [B OR java.net.URL OR java.io.InputStream
    Up to now, still no solution to it. Anybody help.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Shared Services API - Error when getting datasource weblogic/pool/PooledConnectionDataSource

    Hello,
    I have a program that connects to shared services using Java APIs. The code is usually working fine on other environment.
    This one is on EPM version 11.1.2.1 and I get an error after this procedure --> system = CSSSystem.getInstance(context, "");
    Jan 27, 2015 9:36:44 AM com.hyperion.hit.registry.RegistryUtils buildConnFromDriverManager
    WARNING: Check whether Oracle Home and Instance environment variables are defined appropriately. RootCause : weblogic.jdbc.sqlserver
    .SQLServerDriver
    Error when getting datasource weblogic/pool/PooledConnectionDataSource
    Jan 27, 2015 9:36:44 AM com.hyperion.hit.registry.RegistryUtils createNewConnection
    SEVERE: Failed to create connection from data source. RootCause:weblogic/pool/PooledConnectionDataSource.
    Jan 27, 2015 9:36:44 AM com.hyperion.hit.registry.exceptions.RegistryException <init>
    INFO: Registry Exception Occured - Failed to create new database connection using datasource.RootCause:[weblogic/pool/PooledConnecti
    onDataSource]
    Jan 27, 2015 9:36:44 AM com.hyperion.hit.registry.Registry lookupComponentsWithException
    INFO: EPMREG-11045
    Jan 27, 2015 9:36:44 AM com.hyperion.hit.registry.exceptions.RegistryException <init>
    INFO: Registry Exception Occured - Failed to create new database connection using datasource.RootCause:[weblogic/pool/PooledConnecti
    onDataSource]
    Jan 27, 2015 9:36:44 AM com.hyperion.hit.registry.Registry lookupWithException
    INFO: EPMREG-11038
    Jan 27, 2015 9:36:44 AM com.hyperion.hit.registry.exceptions.RegistryException <init>
    INFO: Registry Exception Occured - com.hyperion.hit.registry.exceptions.RegistryException: Failed to create new database connection
    using datasource.RootCause:[weblogic/pool/PooledConnectionDataSource]
    Jan 27, 2015 9:36:44 AM com.hyperion.hit.registry.Registry lookup
    INFO: EPMREG-11038
    Jan 27, 2015 9:36:44 AM com.hyperion.css.registry.RegistryManager RegistryManager
    SEVERE: Failed to initialize EPM Shared Services security instance. Component SYSTEM9/FOUNDATION_SERVICES_PRODUCT/SHARED_SERVICES_PR
    ODUCT is null in EPM System Registry. Verify EPM System Registry configuration.
    java.lang.NullPointerException
            at start.initialize(start.java:84)
            at start.Sample(start.java:59)
            at cc.main(cc.java:10)
    I guess it is something with the SQLServer driver.Do you have any ideas?
    My ORACLE_HOME and ORACLE_INSTANCE are set correctly.
    Thanks in advance,
    Regards,
    Nicolas

    Hello,
    I finally got it working!
    I added the weblogic libraries located under EPM/Middleware/wlserver_10.3/server/lib, and now it works fine.
    It was a pain to find it out, because the error message did not specify that it was a missing library..
    Anyway, if it helps, here is the list of external libraries I am using:
    "wlssapi.jar"
    "wlssapi-internal.jar"
    "wlss-datatier.jar"
    "wlss-descriptor-binding.jar"
    "wlssdiameter.jar"
    "wlssechosvr.jar"
    "wlss-mbeaninfo.jar"
    "WLSSSecurityProviders.jar"
    "wlthint3client.jar"
    "wlw-langx.jar"
    "wlw-langx-ja.jar"
    "wlw-langx-ko.jar"
    "wlw-langx-zh_CN.jar"
    "wlw-langx-zh_TW.jar"
    "wlw-wsee-soapfault.jar"
    "xmlparserv2_sans_jaxp_services.jar"
    "xmlrpc-2.0.1.jar"
    "audit-client.jar"
    "castor-1.0.5.jar"
    "com.bea.core.apache.commons.pool_1.3.0.jar"
    "commons-lang-2.1.jar"
    "css.jar"
    "dms.jar"
    "interop-sdk.jar"
    "ojdl.jar"
    "quartz.jar"
    "regexp.jar"
    "registry-api.jar"
    "scheduler_ces.jar"
    "sqljdbc.jar"
    "wf_ces_utils.jar"
    "wf_eng_agent.jar"
    "wf_eng_api.jar"
    "wf_eng_server.jar"
    "wlcipher.jar"
    "wlclient.jar"
    "wlcommons-logging.jar"
    "wlconnector.jar"
    "wldb2.jar"
    "wldeploy.jar"
    "wlinformix.jar"
    "wl-j2ee-client.jar"
    "wljarbuilder.jar"
    "wljmsclient.jar"
    "wljmxclient.jar"
    "wllog4j.jar"
    "wlnmclient.jar"
    "wlpool.jar"
    "wlsafclient.jar"
    "wls-api.jar"
    "wlss.jar"
    "wlss_i18n.jar"
    Thank you all for your help.
    Regards,
    Nicolas

  • Urgent java print service API ?

    Hi all,
    I would like to use javax.print.*;
    libraries but I am using jdk1.3.1, I think in jdk1.3.1
    there is no javax.print.*; libraries , so how can I download the
    only java print API from jdk1.4..
    if anyone knows please help me..
    thanks

    You can't. You must upgrade your SDK to 1.4

  • Successful using Java Print Service API on Windows 32 Platform

    Hello,
    Using the JSP API supplied with JDK1.4, I was able to print successfully the following types of documents :
    1. Text
    2. GIF, JPG... (images)
    3. PostScript files.
    But could not print "HTML" files. THe problem is that the HTML files are getting printed as text files with all the HTML tags.
    Any pointers are appreciated.
    Thanks
    TJ

    You will need to load the html into something that can render html. The printer doesn't know how to do it. It just sees plain text that you are sending. Try using JTextPane or JEditorPane (I think). It can render html files for you. Then just print that component.
    1) Create JEditorPane or JTextPane.
    2) Set contents of pane as the html file or string you want to print.
    3) Use the Graphics2D API to adjust the component coordinate space to the printer coordinate space.
    4) Render the component (JEditorPane or JTextPane) on the printer.
    There is a very nice tutorial for printing components here: http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-Printing.html.
    Hope this helps.

  • Print Service API

    I have a problem.
    I can`t print a text file.
    How I can print text file?

    Thanks for replying!
    I tried iText but my file contains characters in Cyrillic and they become scrambled. The latin text is OK.
    Now I have installed an Adobe PDF Printer and Cyrillic is printed fine if printed from another application.
    But I cannot make the printer work from JPS. Here is my code:
    public static void testService(PrintService service) {
       try {
         DocFlavor printFlavor = DocFlavor.URL.AUTOSENSE;
         DocPrintJob job = service.createPrintJob();
         PrintRequestAttributeSet set = new HashPrintRequestAttributeSet();
         Doc doc = new SimpleDoc(new File("c:\\g\\myFile.txt").toURL(), printFlavor, null);
         try{
         job.print(doc, set);
       catch(Exception e){
         e.printStackTrace();
    }The parameter of the function is retrieved by calling
    PrintService[] services = PrintLookup.getAvailableServices();If I print to a normal printer it is somehow unfinished-I have to press "Print buffer" on the printer to make it print.

  • Where can i get Third party plugIns of Print Service

    JPS----Java Print Service API has provided the Service
    Provider Interface through which plugins can be created to provide ones own implementation of the PrintServiceLookup........i am unable to locate any such print service Api thru NET..if somebody can tell me where can i find such resources i shall be obliged...........

    I think that if someone has ever found an interesting way to print pdf files from java, especially if this uses the 1.4 JPS API, It would be nice to put it on this forum and not share it via e-mail with some happy-fews (just my 2 cents).
    I have been looking at this for a while and could not find any decent solution (spawning an Acrobat Reader with the /t option does not allow to control enough printer options like 2-sided, n-up, paper trays, ...).
    I think of a solution that would convert the pdf to a plain ps document and stream it with JPS to the printer. I am trying to integrate Ghostscript with my app using JNI to do so. Has anyone used this or another solution to get a PS file out of a pdf document within java?
    Did anybody find or write a java pdf renderer that could be used to implement the Pageable and Printable interfaces?
    Please let me (and us all) know...
    Daniel

  • Does java print service support word docs or text files

    Can anyone tell me that java print service api allows to print word doc files or RTF files etc.

    no it doesn't.
    To print a Word Doc you need to be able to read it, and display it.
    Anything that can be displayed in, say a JPanel, can be printed, cos it's just a matter of displaying the
    image to a virtual component ( a print canvas ). Which then gets printed.
    So, because Java doesn't immediately support Ms Docs, neither does the print service.
    regards,
    Owen

  • Print service lookup, and permissions

    I have written up an application which prints out text to the printer, using the new java print services API. The problem I have is that the i don't get any retuurned services from the lookup, unless i enable all permissions in my java.policy file (it usually has some security settings in there). Does anyone know the kind of permissions that is required for printers to be visible to the application?

    Hi, i've the same problem and i allready use the security option RuntimePermission "queuePrintJob" into the java.policy file.
    The problem is : if i specify in the java.policy "AllPermision". i get a PrintService array from PrintServiceLookup.lookupPrintServices(null,null). But if i only specified "queuePrintJob" RuntimePermission option, the funtion return an array of length 0.
    i guess that i need specified more java policy options to gain access to the printer information, but i can found information about it ....

  • Error on KEB0 execution ? = Program error: BI service API(component BC-BW)

    Error on KEB0 execution ?
    Iu2019m trying to create a data source on KEB0, but when I try to create, the system give this error:
    u201CProgram error: BI service API (component BC-BW) terminated: MAPI
    Message no. R8401u201D
    Some one knows this message ?
    Thanks !

    Marcus, have you checked following Note?
    504847 - Termination when creating a CO-PA DataSource

  • In printer services error message says "unable to perform this operation"

    when I try to check my ink levels in the printer services area, an error message comes up "unable to perform this operation"
    I have deleted and reinstalled my printer.  I have downloaded the lastest driver--all to no avail

    Please read this post then provide some details.  What printer model? What operating system? 
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • Error in oim Role creation using Role Manager Service API from Standalone Java client

    Hi,
      Facing the following error when trying to create Role using Role Manager Service API from a standalone java client .
    Tried with the solution of changing ,
    Login into the Web Logic Admin Console --> Servers --> OIM Server --> Protocols --> Modify the Maximum Message from 100000000 to 1000000000, but still the problem persists.
    Exception in thread "main" org.omg.CORBA.BAD_PARAM:   vmcid: 0x0  minor code: 0  completed: No
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase.getSystemException(Unknown Source)
    at com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage_1_2.getSystemException(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.getSystemExceptionReply(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.processResponse(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.invoke(Unknown Source)
    at org.omg.CORBA.portable.ObjectImpl._invoke(Unknown Source)
    at com.sun.org.omg.SendingContext._CodeBaseStub.meta(Unknown Source)
    at com.sun.corba.se.impl.encoding.CachedCodeBase.meta(Unknown Source)
    at com.sun.corba.se.impl.io.IIOPInputStream.getOrderedDescriptions(Unknown Source)
    at com.sun.corba.se.impl.io.IIOPInputStream.inputObjectUsingFVD(Unknown Source)
    at com.sun.corba.se.impl.io.IIOPInputStream.simpleReadObject(Unknown Source)
    at com.sun.corba.se.impl.io.ValueHandlerImpl.readValueInternal(Unknown Source)
    at com.sun.corba.se.impl.io.ValueHandlerImpl.readValue(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_value(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream.read_value(Unknown Source)
    at oracle.iam.identity.rolemgmt.api._RoleManager_ogut7n_RoleManagerRemoteRIntf_Stub.createx(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:85)
    at $Proxy2.createx(Unknown Source)
    at oracle.iam.identity.rolemgmt.api.RoleManagerDelegate.create(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at Thor.API.Base.SecurityInvocationHandler$1.run(SecurityInvocationHandler.java:68)
    at weblogic.security.subject.SubjectProxy.doAs(SubjectProxy.java:64)
    at weblogic.security.subject.SubjectManager.runAs(SubjectManager.java:262)
    at weblogic.security.Security.runAs(Security.java:48)
    at Thor.API.Security.LoginHandler.weblogicLoginSession.runAs(weblogicLoginSession.java:52)
    at Thor.API.Base.SecurityInvocationHandler.invoke(SecurityInvocationHandler.java:79)
    at $Proxy3.create(Unknown Source)
    at com.idm.role.CreateRole.createRole(CreateRole.java:113)
    at com.idm.role.CreateRole.main(CreateRole.java:167)
    Thanks In Advance

    Hi , I have used OIM 11g  R2.
    Please find below the code we have used,
    package com.idm.role;
    import java.util.HashMap;
    import java.util.HashSet;
    import java.util.Hashtable;
    import java.util.Iterator;
    import java.util.Set;
    import java.util.logging.Logger;
    import javax.security.auth.login.LoginException;
    import oracle.iam.identity.exception.NoSuchRoleException;
    import oracle.iam.identity.exception.RoleAlreadyExistsException;
    import oracle.iam.identity.exception.RoleCreateException;
    import oracle.iam.identity.exception.RoleLookupException;
    import oracle.iam.identity.exception.RoleModifyException;
    import oracle.iam.identity.exception.SearchKeyNotUniqueException;
    import oracle.iam.identity.exception.ValidationFailedException;
    import oracle.iam.identity.rolemgmt.api.RoleManager;
    import oracle.iam.identity.rolemgmt.api.RoleManagerConstants;
    import oracle.iam.identity.rolemgmt.vo.Role;
    import oracle.iam.platform.OIMClient;
    import oracle.iam.platform.authz.exception.AccessDeniedException;
    public class CreateRole {
    private final static Logger LOGGER = Logger.getLogger(CreateRole.class .getName());
    OIMClient oimClient = null;
    public OIMClient connectToOIM() {
      LOGGER.info("In connectToOIM ");
      Hashtable env = new Hashtable();
      env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL,
        "weblogic.jndi.WLInitialContextFactory");
      env.put(OIMClient.JAVA_NAMING_PROVIDER_URL,
        "t3://V-hydidm1.itig.co.in:14000");
      System.setProperty("java.security.auth.login.config",
        "F:\\Projects\\IDM\\Team\\Env_setup\\OIM_Setup\\designconsole\\config\\authwl.conf");
      System.setProperty("java.security.policy",
        "F:\\Projects\\IDM\\Team\\Env_setup\\OIM_Setup\\designconsole\\config\\xl.policy");
      System.setProperty("OIM.AppServerType", "wls");
      System.setProperty("APPSERVER_TYPE", "wls");
      System.setProperty("weblogic.Name", "oim_server1");
      oimClient = new OIMClient(env);
      try {
       oimClient.login("xelsysadm", "Passw0rd".toCharArray());
      } catch (LoginException e) {
       e.printStackTrace();
      System.out.println("Connected");
      return oimClient;
    public void readRoleMetadata() {
      LOGGER.info("in readRoleMetadata ");
      RoleManager roleManagerService = oimClient
        .getService(RoleManager.class);
      try {
       Role roleVo = roleManagerService.getDetails(
         RoleManagerConstants.ROLE_DISPLAY_NAME, "API Role1", null);
       Set attributeNameSet = roleVo.getAttributeNames();
       Iterator it = attributeNameSet.iterator();
       while (it.hasNext()) {
        System.out.println("Attribute Name :: " + it.next());
       // roleVo.setAttribute("ADentitlements", "Security Admin access");
       String adEntitlements = "" + roleVo.getAttribute("ADentitlements");
       System.out.println("AD Entitlements :: " + adEntitlements);
       System.out.println("DB Entitlements :: " + ""
         + roleVo.getAttribute("DBEntitlements"));
       System.out.println("Unix Entitlements :: " + ""
         + roleVo.getAttribute("UnixWindows"));
       System.out.println("VPN :: " + "" + roleVo.getAttribute("VPN"));
      } catch (SearchKeyNotUniqueException e) {
       e.printStackTrace();
      } catch (NoSuchRoleException e) {
       e.printStackTrace();
      } catch (RoleLookupException e) {
       e.printStackTrace();
      } catch (AccessDeniedException e) {
       e.printStackTrace();
    public void createRole() {
      LOGGER.info(" in Create role ");
      RoleManager roleManagerService = oimClient
        .getService(RoleManager.class);
      HashMap<String, Object> roleCreationAttrMap = new HashMap<String, Object>();
      roleCreationAttrMap.put(RoleManagerConstants.ROLE_NAME, "API Role1");
      roleCreationAttrMap.put(RoleManagerConstants.ROLE_DESCRIPTION,
        "This Role is created using API Role1");
      roleCreationAttrMap.put(RoleManagerConstants.ROLE_DISPLAY_NAME,
        "API Role1");
      roleCreationAttrMap.put("ADentitlements", "API Role1 AD Entitlements");
      roleCreationAttrMap.put("DBEntitlements", "API Role1 DB Entitlements");
      roleCreationAttrMap.put("VPN", "No");
      roleCreationAttrMap.put("UnixWindows", "API Role1 Unix Entitlements");
      Role roleVo = new Role(roleCreationAttrMap);
      try {
       System.out.println(" Before Create role *********************************************");
       roleManagerService.create(roleVo);
       System.out.println("Role Created .. ");
      } catch (ValidationFailedException e) {
       e.printStackTrace();
      } catch (RoleAlreadyExistsException e) {
       e.printStackTrace();
      } catch (RoleCreateException e) {
       e.printStackTrace();
      } catch (AccessDeniedException e) {
       e.printStackTrace();
    public void modifyRole() {
      LOGGER.info(" in modifyRole ");
      RoleManager roleManagerService = oimClient
        .getService(RoleManager.class);
      Role roleVo;
      try {
       roleVo = roleManagerService.getDetails(
         RoleManagerConstants.ROLE_DISPLAY_NAME, "API Role1", null);
       String roleKey = roleVo.getEntityId();
       HashMap<String, Object> roleCreationAttrMap = new HashMap<String, Object>();
       roleCreationAttrMap.put("ADentitlements",
         "Updated API Role1 AD Entitlements");
       Set roleKeySet = new HashSet<String>();
       roleKeySet.add(roleKey);
       Role roleVoNew = new Role(roleCreationAttrMap);
       roleManagerService.modify(roleKeySet, roleVoNew);
       System.out.println("Role Modified ..");
      } catch (SearchKeyNotUniqueException e) {
       e.printStackTrace();
      } catch (NoSuchRoleException e) {
       e.printStackTrace();
      } catch (RoleLookupException e) {
       e.printStackTrace();
      } catch (AccessDeniedException e) {
       e.printStackTrace();
      } catch (ValidationFailedException e) {
       e.printStackTrace();
      } catch (RoleModifyException e) {
       e.printStackTrace();
    public static void main(String args[]) {
      CreateRole miscObj = new CreateRole();
      miscObj.connectToOIM();
      miscObj.createRole();
      //miscObj.readRoleMetadata();
    Thanks In Advance .

Maybe you are looking for

  • Error while Seq vlc in powershell command line.

    Hi Team, when i am trying to seq Vlc i got below error in power shell. i have entered below command lines in powershell 1. cd c:\install 2. Set-ExecutionPolicy Unrestricted 3. New-AppvSequencerPackage -FullLoad -Installer "C:\Install\vlc-2.1.3-win32.

  • XML XSLT Maping Problem in XI

    Hi, I'm actually doing some tests with the possibility to invoke a ABAP-Mapping (ABAP-Class). So my scenario is quite simple: I have a import xml where I want to substitute exactly one value (database select). Now my problem is that the xml comes in

  • Java Web Start and MySQL driver

    I am trying to do a simple query on a MySQL database using the JDBC driver from http://www.mysql.com/downloads/api-jdbc-stable.html When I run my app, it works exactly as it should (connects to db, queries, displays in text boxes). When I package it

  • Simplepass login not working

    My simple pass is not letting me in my new latop it's a pavilion with windows 8.1 new The statement reads Access to windows cannot be granted until you authenticate with all your required devices Please help immediately This question was solved. View

  • Difficulty in installing Patch manager 2 on Solaris 9

    Hello, I have a Solaris 9 machine on which I am trying to install Patch Manager 2. I have PatchPro 2.2 also installed on the same machine. Since PatchManager2 requires some patches to be installed previously like: 112945 117593 117595, I tried to ins