2 Replies Latest reply on Jun 14, 2011 1:01 PM by nev can

    org.jboss.weld.exceptions.UnsatisfiedResolutionException class sun.rmi.runtime.Log

    nev can Newbie
      I am getting an error when I am trying to use the seam catch from Java SE. Can you please help? I am new to seam catch and weld and trying to write a simple main app. Here is my code.

      Main class

      package org.jboss.weld.environment.se.example.simple;

      import java.io.IOException;

      import org.jboss.weld.environment.se.Weld;
      import org.jboss.weld.environment.se.WeldContainer;

      public class MyAppWeld {
             
              public static void main(String[] args) {
             
                      WeldContainer weld = new Weld().initialize();
                      MyClass app = weld.instance().select(MyClass.class).get();
                     
                      try {
                              app.getName();
                             
                      } catch (IOException e) {
                             
                              e.printStackTrace();
                      }
              }

      }

      MyClass:

      package org.jboss.weld.environment.se.example.simple;



      import java.io.IOException;

      import javax.enterprise.event.Event;
      import javax.inject.Inject;
      import javax.inject.Singleton;

      import org.jboss.seam.exception.control.ExceptionToCatch;

      @Singleton
      public class MyClass {
             
              @Inject
              Event<ExceptionToCatch> catchEvt;
             

             
              public void getName() throws IOException {
                     
                      try{
                              System.out.println("will throw IOException");
                              throw new IOException("my exception");
                             
                      }catch(Exception e) {
                             
                              this.catchEvt.fire(new ExceptionToCatch(e));
                              System.out.println(this.catchEvt.toString());
                     
                             
                      }
                     
              }
      }

      MyHandlers:

      package org.jboss.weld.environment.se.example.simple;

      import java.io.IOException;

      import org.jboss.seam.exception.control.CaughtException;
      import org.jboss.seam.exception.control.Handles;
      import org.jboss.seam.exception.control.HandlesExceptions;
      import org.jboss.seam.exception.control.Precedence;
      import org.jboss.seam.exception.control.TraversalMode;

      import sun.rmi.runtime.Log;

      @HandlesExceptions
      public class MyHandlers {

              void printExceptions(@Handles CaughtException<IOException> evt)

              {

                      System.out.println("Something bad happened: " + evt.getException().getMessage());

                      evt.markHandled();

              }
             
              
              
               public void logExceptions(@Handles(during = TraversalMode.BREADTH_FIRST, precedence = Precedence.HIGH) CaughtException<Throwable> evt, Log log) {
               System.out.println(("Exception caught: " + evt.getException().getMessage()));
           }

         


              
      }

      The error I am getting is:
      Exception in thread "main" org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001308 Unable to resolve any beans for Types: [class sun.rmi.runtime.Log]; Bindings: [@javax.enterprise.inject.Default()]
              at org.jboss.weld.manager.BeanManagerImpl.getBean(BeanManagerImpl.java:809)
              at org.jboss.weld.manager.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:794)
              at org.jboss.seam.solder.reflection.annotated.ParameterValueRedefiner$ParameterValue.getDefaultValue(ParameterValueRedefiner.java:86)
              at org.jboss.seam.exception.control.OutboundParameterValueRedefiner.redefineParameterValue(OutboundParameterValueRedefiner.java:61)
              at org.jboss.seam.solder.reflection.annotated.InjectableMethod.invoke(InjectableMethod.java:178)
              at org.jboss.seam.exception.control.HandlerMethodImpl.notify(HandlerMethodImpl.java:169)
              at org.jboss.seam.exception.control.ExceptionHandlerDispatch.executeHandlers(ExceptionHandlerDispatch.java:83)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305)
              at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
              at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
              at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299)
              at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188)
              at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:59)
              at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:198)
              at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:270)
              at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253)
              at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:222)
              at org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:632)
              at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:625)
              at org.jboss.weld.event.EventImpl.fire(EventImpl.java:75)
              at org.jboss.weld.environment.se.example.simple.MyClass.getName(MyClass.java:31)
              at org.jboss.weld.environment.se.example.simple.MyAppWeld.main(MyAppWeld.java:19)


      If I take the MyHandler class out of the project, I am not getting the error. What is the problem?

      Thank you in advance for your time.