7 Replies Latest reply on Aug 2, 2010 11:01 AM by 788877

    Unable to instantiate java class for custom filter

    Aacc-Oracle
      I created a filter for UCM and installed under server/custom/AlterPrefix/classes. however, I got following error when check in file:

      Content item <undefined> was not successfully checked in. Unable to do filter 'AlterPrefix.CustomFilter' for type 'validateStandard'. Unable to instantiate java class code for 'AlterPrefix.CustomFilter' at location 'AlterPrefix.CustomFilter' with default location at 'AlterPrefix.CustomFilter'.

      I have to move the classes to the server/classes, then, the filter works.

      I would like this to be in the server/custom. Is there anything I'm missing ?

      The hda file looks like:
      @ResultSet Filters
      4
      type
      location
      parameter
      loadOrder
      validateStandard
      AlterPrefix.CustomFilter
      null
      1
      @end
        • 1. Re: Unable to instantiate java class for custom filter
          Swapnil Solanki
          Hey Aacc,
          a piece of information for you, when you specify in the resultset Filters section, the UCM expects java class AlterPrefix.CustomFilter in side the classes folder. your folder hierarchy should be like
          customComponentFolder==>classes==>AlterPrefix==>CustomFilter.class

          If you can provide more information on your directory structure of the custom component with subfolders in side the classes directory, may be I can help you more.


          thanks,
          sapan
          1 person found this helpful
          • 2. Re: Unable to instantiate java class for custom filter
            742311
            Hi!
            First, make sure the classes are in the classpath. Look under the menu option "Configuration for xxx" to find the current classpath.

            There is a small problem with using the Component Wizard for updating the class path. Just setting the class path in the build settings dialog doesn't do it. The classpath seems to be updated with the component class path only during the enabling of a component. So a simple "disable, restart, enable, restart" might be needed.

            /Sam
            1 person found this helpful
            • 3. Re: Unable to instantiate java class for custom filter
              user10960252
              Try to remove the folder AlterPrefix from server/custom to server/classes
              1 person found this helpful
              • 4. Re: Unable to instantiate java class for custom filter
                674493
                Hi Aacc,

                I had the same problem recently with a component. This is probably the same thing as Sam is saying, but using Component Wizard I had to go to Advanced and put $COMPONENT_DIR/classes into the custom class path. Then I was able to have the classes reside under the <install>/custom directory. Then disable, rebuild, and re-enable your component ... and restart server :)

                Hope you've got this solved.

                -Jason

                Edited by: jschulz on Mar 12, 2010 7:51 AM

                Edited by: jschulz on Mar 12, 2010 7:52 AM
                1 person found this helpful
                • 5. Re: Unable to instantiate java class for custom filter
                  bex
                  @jschultz is correct...

                  In your component build settings, you need to click advanced, and then add the component classpath. In your component definition file (MyComponent.hda) you should see a line like this:

                  classpath=$COMPONENT_DIR/classes

                  Then you need to disable, and re-enable your component. If you do this, then you should see you component's classpath in the "ucm/config/state.cfg" file. Then you know it's in the classpath when UCM launches.

                  NOW... if you STILL have problems about not being able to instantiate the Java class, the most common problem is a misspelling of the Java class. Double check everything, preferably with a fresh set of eyes.

                  Another problem is that despite claims to the contrary, if you compile your Java classes with one JVM version, and instantiate them through reflection with another JVM version, then you'll occasionally get bizarre class not found" exceptions. Be sure to compile your code with the EXACT same version of Java that is running UCM.
                  • 6. Re: Unable to instantiate java class for custom filter
                    594928
                    Thanks a lot...i was facing the same issue and the issue gets resolved by following your steps,seems by default the CS will not look for custom component's classes by its own, we have to specify in our component file... :-)

                    Regards
                    Mani.R
                    • 7. Re: Unable to instantiate java class for custom filter
                      788877
                      Hello All,

                      Being new to Oracle UCM, I apologize for any absurd questions I post.

                      I have created a test component with a java class which prints "Hello World". Have done these following configuration settings -

                      1. Specified component classpath in build advance settings. MyComponent.hda file shows the classpath as classpath=$COMPONENT_DIR/classes

                      2. Component's classpath in the "ucm/config/state.cfg" file shows as - test_classpath=$IntradocDir/custom/test/classes. This seems to be okay I believe.

                      3. Java class compiled with the same version of Java that is running UCM. JRE 1.5 update 11

                      4. Service is executed with the java method - test()

                      Still I get this exception -

                      System code execution error. Runtime error: java.lang.ClassCastException: test.TestClass
                      at intradoc.server.ServiceManager.createServiceEx(ServiceManager.java:469)
                      at intradoc.server.ServiceManager.processCommand(ServiceManager.java:350)
                      at intradoc.server.IdcServerThread.run(IdcServerThread.java:197) at intradoc.server.ServiceManager.createServiceEx(ServiceManager.java:469)
                      at intradoc.server.ServiceManager.processCommand(ServiceManager.java:350)
                      at intradoc.server.IdcServerThread.run(IdcServerThread.java:197) ---!>

                      TestClass.java {

                      void test(){
                      System.out.println("Hello World");
                      }
                      }