Hello.

I'm developing a simple (read: JSP, JDBC-based, but not using EJBs, JMS, JTA or 
anything fancy) application. I want to use the UUIDKeyGenerator that is bundled 
with JBoss, but I am stumped at how to declare and use the UUID Key Generator.

I've got the uuidkeygenerator.sar in the deploy directory. I've set up the 
code: 
  try {
    InitialContext ic = new InitialContext();
    String idFactoryName = "UUIDKeyGeneratorFactory";

    // get generator factory from JNDI
    try {
      UUIDKeyGeneratorFactory keyGeneratorFactory =   
                 (UUIDKeyGeneratorFactory)ic.lookup(idFactoryName);

      // get generator instance 
      UUIDKeyGenerator idGenerator =
               (UUIDKeyGenerator)keyGeneratorFactory.getKeyGenerator();
      String generatedId = (String)idGenerator.generateKey();
      log("Id is: " + generatedId);
    } catch (Exception ex) {
      log("Threw an exception: " + ex.getMessage());
    }
  } catch (NamingException nex) {
      log("Threw a naming exception: " + nex.getExplanation());
  }

I double-checked that  standardjbosscmp-jdbc has the following declaration:

      <unknown-pk>
         <key-generator-factory>UUIDKeyGeneratorFactory</key-generator-factory>
         <unknown-pk-class>java.lang.String</unknown-pk-class>
         <jdbc-type>VARCHAR</jdbc-type>
         <sql-type>VARCHAR(32)</sql-type>
      </unknown-pk>

But when I run the program, here's the exception I get: 
WebModule[/db_test]Threw an exception: UUIDKeyGeneratorFactory not found|#]


I'm obviously missing something quite fundamental. Can anyone help me out here?

Thanks,
Maya


View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3858099#3858099

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3858099


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to