This discussion is archived
14 Replies Latest reply: May 15, 2012 2:45 PM by 815088 RSS

class not found creating new user with Java API

j.teodoro Newbie
Currently Being Moderated
This is the error when creating new user with API MobileResourceManager:

java.lang.NoClassDefFoundError: oracle/lite/resource/ResourceManager
at oracle.lite.web.JupConfig.OpenConsolidatorConnection(Unknown Source)
at oracle.lite.web.resource.ResourceFactory.getInstance(Unknown Source)
at oracle.mobile.admin.MobileResourceManager.<init>(Unknown Source)
at createUser.main(createUser.java:59)

The classpath is :
C:\Olite10g_2\jdbc\lib\ojdbc14.jar
C:\Olite10g_2\Mobile\Sdk\BIN\webtogo.jar
C:\Olite10g_2\Mobile\Sdk\BIN\OLITE40.JAR
C:\Olite10g_2\Mobile\CLASSES\classgen.jar
C:\Olite10g_2\Mobile\CLASSES\xmlparserv2.jar
C:\Olite10g_2\Mobile\CLASSES\ojsp.jar
C:\Olite10g_2\Mobile\CLASSES\jssl-1_2.jar
C:\Olite10g_2\Mobile\CLASSES\javax-ssl-1_2.jar
C:\Olite10g_2\Mobile\CLASSES\jzlib.jar
C:\Olite10g_2\Mobile\CLASSES\servlet.jar
C:\Olite10g_2\Mobile\Server\bin\devmgr.jar
C:\Olite10g_2\Mobile\CLASSES\mSync.jar
C:\Olite10g_2\Mobile\CLASSES\debug\Consolidator_g.jar
C:\Olite10g_2\Mobile\CLASSES\phaos.jar
C:\Olite10g_2\Mobile\classes\share.jar
C:\Olite10g_2\Mobile\classes\oracle_ice.jar
C:\Olite10g_2\Mobile\classes\jewt4.jar
C:\Olite10g_2\Mobile\classes\jewt4-nls.jar
C:\Olite10g_2\Mobile\classes\wtgpack.jar

need others jars files ?

Thanks.
  • 1. Re: class not found creating new user with Java API
    343896 Oracle ACE
    Currently Being Moderated
    Looks like you have everything you need.

    C:\jdev1013\jdbc\lib\ojdbc14dms.jar
    C:\oracle\Mobile\Sdk\BIN\webtogo.jar
    C:\oracle\Mobile\Sdk\BIN\OLITE40.JAR
    C:\oracle\Mobile\CLASSES\classgen.jar
    C:\oracle\Mobile\CLASSES\xmlparserv2.jar
    C:\oracle\Mobile\CLASSES\ojsp.jar
    C:\oracle\Mobile\CLASSES\jssl-1_2.jar
    C:\oracle\Mobile\CLASSES\javax-ssl-1_2.jar
    C:\oracle\Mobile\CLASSES\jzlib.jar
    C:\oracle\Mobile\CLASSES\servlet.jar
    C:\oracle\Mobile\Server\bin\devmgr.jar
    C:\oracle\Mobile\CLASSES\mSync.jar
    C:\oracle\Mobile\CLASSES\debug\Consolidator_g.jar
            try {
                DriverManager.registerDriver((Driver)(Class.forName("oracle.jdbc.OracleDriver").newInstance()));
                try {
                    con = DriverManager.getConnection(JDBC_URL, MOBILE_SCHEMA, MOBILE_PASSWORD);
                } catch (SQLException sqle) {
                    sqle.printStackTrace();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                MobileResourceManager rm = new MobileResourceManager(con);
            } catch (ResException res) {
                res.printStackTrace();
            }
            
            ConsolidatorManager cm = new ConsolidatorManager();
    Here is a sample of something that is working with my classpath.
  • 2. Re: class not found creating new user with Java API
    j.teodoro Newbie
    Currently Being Moderated
    Thanks for reply.

    this is the Java file with your modification:
    ---------------------------------------------------

    import java.sql.*;

    import oracle.lite.sync.ConsolidatorException;
    import oracle.lite.sync.ConsolidatorManager;
    import oracle.mobile.admin.*;


    class createUser
    {
    private static Connection con = null;

    public static void main(String arg[]) throws ConsolidatorException,
    SQLException, Exception{


    String MOBILE_SCHEMA = arg[0];
    String MOBILE_PASSWORD = arg[1];
    String JDBC_URL = "jdbc:oracle:thin:@" + arg[2] + ":" +
    arg[3] + ":" + arg[4];

    try{
    DriverManager.registerDriver((Driver)(Class.forName("oracle.jdbc.OracleDriver").newInstance()));
    try {
    con = DriverManager.getConnection(JDBC_URL, MOBILE_SCHEMA, MOBILE_PASSWORD);
    } catch (SQLException sqle) {
    sqle.printStackTrace();
    }
    } catch (Exception e) {
    e.printStackTrace();
    return;
    }

    try {
    /* MobileResourceManager mrm = new MobileResourceManager(MOBILE_SCHEMA, MOBILE_PASSWORD, JDBC_URL); */
    MobileResourceManager rm = new MobileResourceManager(con);
    } catch (ResException res) {
    res.printStackTrace();
    }

    ConsolidatorManager cm = new ConsolidatorManager();

    }
    }

    ----------------------------------------------------------
    And the new error message:
    Note: C:\Documents and Settings\Administrador\Mis documentos\QW14\createUser.jav
    a uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.

    -----------------------------------------
    The file 'createUser.class' was created but return the same error.

    Exception in thread "main" oracle.lite.web.resource.ResourceException: oracle/li
    te/resource/ResourceManager
    at oracle.lite.web.resource.ResourceFactory.getInstance(Unknown Source)
    at oracle.mobile.admin.MobileResourceManager.<init>(Unknown Source)
    at createUser.main(createUser.java:54)

    Tanks.
  • 3. Re: class not found creating new user with Java API
    316350 Newbie
    Currently Being Moderated
    Hi there,

    the second error You show is a different one!
    The first one was a "noclassdeffound". The missing class is included in devmgr.jar.

    The second error is a ResourceException. But the given error message does not tell WHAT resource exception (no details). Maybe wrong language or so? Try to unset the LANG variable when running under Unix/Linux, maybe that helps (blindly). Or the JDBC_URL parameter is somehow incorrect, that's the most probable one...

    Regards,
    Marcel
  • 4. Re: class not found creating new user with Java API
    343896 Oracle ACE
    Currently Being Moderated
    Here is the full Java code:
    import java.sql.Connection;
    
    import java.sql.Driver;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    
    import oracle.lite.sync.ConsolidatorException;
    import oracle.lite.sync.ConsolidatorManager;
    
    import oracle.mobile.admin.MobileResourceManager;
    import oracle.mobile.admin.ResException;
    
    public class createUser {
    
        private static String MOBILE_SCHEMA = "MOBILEADMIN";
        private static String MOBILE_PASSWORD = "YOURPASSWORD";
        private static String JDBC_URL = "jdbc:oracle:thin:@127.0.0.1:1521:ORCL";
        
        private static Connection con = null;
    
        public static void main(String[] args) throws ResException, 
                                                      ConsolidatorException {
            try {
                DriverManager.registerDriver((Driver)(Class.forName("oracle.jdbc.OracleDriver").newInstance()));
                try {
                    con = DriverManager.getConnection(JDBC_URL, MOBILE_SCHEMA, MOBILE_PASSWORD);
                } catch (SQLException sqle) {
                    sqle.printStackTrace();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                MobileResourceManager rm = new MobileResourceManager(con);
            } catch (ResException res) {
                res.printStackTrace();
            }
            
            ConsolidatorManager cm = new ConsolidatorManager();
            
            // SET YOUR PUBLICATION NAME HERE
            String PUBLICATION = "MYAPP";
    
            cm.openConnection(con);
            
            cm.setSubscriptionParameter(PUBLICATION, "USERNAME", "PARAMETER_NAME", "'some parameter'");
            cm.instantiateSubscription(PUBLICATION, "USERNAME");
    
            cm.closeConnection();
    
        }
    }
  • 5. Re: class not found creating new user with Java API
    j.teodoro Newbie
    Currently Being Moderated
    i've found the error in the Classpath:

    The file C:\Olite10g_2\Mobile\Server\bin\devmgr.jar don't exist, the correct is :
    C:\Olite10g_2\Mobile\Sdk\bin\devmgr.jar.

    The program runs and the parameter is modified.
    But one new error is showed:
    ----------------------------------
    java.io.FileNotFoundException: \mobile\server\bin\mobileserverid.dat (El sistema
    no puede hallar la ruta especificada)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
    at oracle.lite.web.util.ParamEncoder.readKey(Unknown Source)
    at oracle.lite.web.util.ParamEncoder.setId(Unknown Source)
    at oracle.lite.web.JupConfig.initialize0(Unknown Source)
    at oracle.lite.dm.Config.initialize(Unknown Source)
    at oracle.lite.resource.ResourceManager.initialize(Unknown Source)
    at oracle.lite.web.JupConfig.OpenConsolidatorConnection(Unknown Source)
    at oracle.lite.web.resource.ResourceFactory.getInstance(Unknown Source)
    at oracle.mobile.admin.MobileResourceManager.<init>(Unknown Source)
    at createUser.main(createUser.java:36)
    ----------------------------------
    I'm running the java from windows and this file is located in the mobile server (Linux), and the repository is in other (Aix).

    I'm other too with the MobileResourceManager:
    --------------------------------------------------------------------------------
    cannot find symbol
    symbol : variable rm
    location: class createUser
    rm.addUserToGroup("ASTURIAS","350148");
    ^
    1 error
    ---------------------------------------------------------


    Thanks.
  • 6. Re: class not found creating new user with Java API
    343896 Oracle ACE
    Currently Being Moderated
    Try running the code on the Mobile Server itself. I usually have the SDK and the Server (Without the repository) installed locally. That is why my path had the devmgr.jar under the server/bin.

    Obviously the error is that it's looking for the mobileserverid.dat file that only exists with a server install.

    BTW, I get similar issues when I try to run the partition map methods. I end up having to run the code directly on the mobile server.
  • 7. Re: class not found creating new user with Java API
    j.teodoro Newbie
    Currently Being Moderated
    We don't have the SDK instaled on the server.

    How can run it from windows ?

    thanks
  • 8. Re: class not found creating new user with Java API
    343896 Oracle ACE
    Currently Being Moderated
    You don't need the SDK on the server. The server has the consolidator API jars already.

    In the same Oracle Home you installed your SDK, install Mobile Server as well. Do not install the repository. This will give you the standalone OC4J container on your dev machine, but you don't have to start it or use it.

    There are some things that come with the server install that the dev install does not have like the WSH utility.
  • 9. Re: class not found creating new user with Java API
    j.teodoro Newbie
    Currently Being Moderated
    I've instaled the mobile server with the SDK but the file wasn't created.

    if I try wiht new devmgr.jar but the error was the same.

    Thanks.
  • 10. Re: class not found creating new user with Java API
    343896 Oracle ACE
    Currently Being Moderated
    Come to think of it, I actually run that API from a WebLogic hosted application, and I don't have either SDK or Server installed in that environment. I will look in my APP-INF/lib and get you a list of JARs.

    Here is the list:

    aes.jar
    consolidator.jar
    devmgr.jar
    jzlib.jar
    olite40.jar
    phaos.jar
    servlet.jar
    webtogo.jar

    Message was edited by:
    rekounas
  • 11. Re: class not found creating new user with Java API
    624708 Newbie
    Currently Being Moderated
    Hi Greg,
    It looks like that contructor with just the connection object is deprecated...
    new MobileResourceManager(con)...

    And btw, Doesn't it seem like a little buggy that you "should" run these on the MobileServer machine. I have the Mobile Development environment so I should be able to build apps (such as the one discussed here) in the Mobile Dev Environment. I get that error regarding MobileResourceManager not being able to find mobile/server/bin/mobileserverid.dat but it continues to process my work with no errors.

    One last thing, do you know what jar file has oracle.dms.* - I run my getuserlist console app just fine in JBuilder but when I run from command prompt I get missing classes in this package... I can't find what I've left out of my classpath...

    Cheers,
    Anastasia
    aaourik@embarqmail.com
  • 12. Re: class not found creating new user with Java API
    343896 Oracle ACE
    Currently Being Moderated
    Hi Anastasia,
    MobileResourceManager
    
    public MobileResourceManager(java.lang.String adminUser,
                                 java.lang.String adminPwd,
                                 java.lang.String adminURL)
                          throws ResException
    
        Initialize a MobileResourcManager object.
    
    Parameters:
        adminUser - the username of the MobileAdmin schema.
        adminPwd - the password of the MobileAdmin schema.
        adminURL - the jdbc url of the database which contains the MobileAdmin schema.
    See Also:
        MobileResourceManager(Connection conn)
    The reason it is probably deprecated is that is can only use a static connection. If you were to pass in a connection that was obtained from a connection pool for example, the API will not work. So, to remove some confusion, they are deprecating this method. That is my assumption.

    I am not sure which JAR oracle.dms.* is listed under, but if you take a look at the JARs I listed above, one of those should contain it. There is a dms.jar with JDeveloper, but it is probably different.
  • 13. Re: class not found creating new user with Java API
    624708 Newbie
    Currently Being Moderated
    Okay, I found my classes. thanks.

    Precisely how does one CREATE NEW data subsettingparameters (name/value) pair for a new user that is created and added to a group (where the group is defined to have access to Application X.

    My code give me:
    CONS-10049: Consolidator Exception: ORA-02291: integrity constraint (MOBILEADMIN.C$ALL_SUBSCRIPTION_PARAMS_FK1) violated - parent key not found

    Code BELOW:

    String sitecodeUser=null;
    String sitecodePass=null;
    for (int i=0; i<btrsiteVector.size(); i++)
    {
    sitecodeUser = "U" + btrsiteVector.get(i).toString().toUpperCase();
    sitecodePass = "smith_" + sitecodeUser;
    boolean ok = mrm.createUser(sitecodeUser, sitecodePass, sitecodeUser, "U");
    ResourceManager.initialize(adminURL,adminUser,adminPassword);
    ResourceManager rm = ResourceManager.getInstance();
    User userObj = rm.getUser(sitecodeUser);
    Group grpObj = rm.getGroup("DRS GROUP");
    grpObj.addUser(userObj);
    Application appObj = rm.getApplication("DRS"); //doin nothing with this....
    if (ok)
    {
    cm.setSubscriptionParameter("DRS", userObj.getId(), "BUILD_DT", "'03/10/2008'"); //<<<<<<FAILS HERE
    }
  • 14. Re: class not found creating new user with Java API
    815088 Newbie
    Currently Being Moderated
    I have got the same error message:

    CONS-10049: Consolidator Exception: ORA-02291:
    integrity constraint (MOBILEADMIN.C$ALL_SUBSCRIPTION_PARAMS_FK1) violated - parent key not found.

    Have you got it fixed?
    If you have a fix, please send your solution
    to jgao@netstarit.com.

    Thanks.

    Jack