1 2 Previous Next 23 Replies Latest reply on Aug 12, 2004 5:42 AM by Kabir Khan

    IllegalAccessException

    Tomasz Nazar Newbie

      Hi,

      I think I have some configuration problem with j2sdk or sth similar, cause you say in earlier thread and in docs, that it's normal to advice private class members.

      This is part of my class, and method I want to advice:

      public class banking.aspects.persistance.PreparedStatements
      {....
       private Connection getConnection(){ ... }
       ^^^^^
      ...}
      


      That's part of jboss-aop.xml:

      <aspect class="banking.jbossaop.transactions.DbConnectionAspect" scope="PER_VM" />
      <bind pointcut="call(* banking.aspects.persistance.DatabaseGateway->getConnection())
       OR
       call(* banking.aspects.persistance.PreparedStatements->getConnection())">
       <advice name="switchConnection"
       aspect="banking.jbossaop.transactions.DbConnectionAspect" />
      </bind>
      


      And error from ant looks...

      run-static:
      internal:parametrisied-java:
       [java] ==DB==[main] Initializing database connection..
       [java] ==DB==[main] Generating connection..
       [java] ==DB==[main] Generating normal connection from DB..
       [java] ==DB==[main] Connection: com.mysql.jdbc.Connection@adb1d4 generated successfully.
       [java] ==JB==[main] *PersistanceAspectCustomerManager->getNextId
      
       [java] java.lang.IllegalAccessException: Class org.jboss.aop.joinpoint.MethodCalledByMethodInvocation can not access a
      member of class banking.aspects.persistance.PreparedStatements
      with modifiers "private"
      
       [java] at sun.reflect.Reflection.ensureMemberAccess(Unknown Source)
       [java] at java.lang.reflect.Method.invoke(Unknown Source)
       [java] at org.jboss.aop.joinpoint.MethodCalledByMethodInvocation.invokeNext(MethodCalledByMethodInvocation.java:71)
       [java] at banking.jbossaop.transactions.DbConnectionAspect.switchConnection(Unknown Source)
       [java] at org.jboss.aop.advice.banking.jbossaop.transactions.DbConnectionAspect0.invoke(DbConnectionAspect0.java)
       [java] at org.jboss.aop.joinpoint.MethodCalledByMethodInvocation.invokeNext(MethodCalledByMethodInvocation.java:60)
       [java] at org.jboss.aop.ClassAdvisor.invokeCaller(ClassAdvisor.java:1453)
      .... cut
      


      Any ideas about sth wrong here?
      Thanks..

      --
      nthx


        • 1. Re: IllegalAccessException
          Bill Burke Master

          Can you try CVS Head? This may have been fixed there.

          • 2. Re: IllegalAccessException
            Clebert Rezende Suconic Newbie

            I'm running a testcase on jboss-profiler module (download it from CVS if you want to run the same testcase) which I'm using private methods, and it's working fine.

            I don't know if you have done it or not...

            Are you sure you are calling invocation.invokeNext() in your interceptor?

            This is just a guessing, but at a first look looks like you are calling the banking.aspects.persistance.PreparedStatements.getConnection instead invocation.invokeNext().


            Clebert

            • 3. Re: IllegalAccessException
              Tomasz Nazar Newbie

               

              "clebertsuconic" wrote:

              Are you sure you are calling invocation.invokeNext() in your interceptor?

              This is just a guessing, but at a first look looks like you are calling the
              banking.aspects.persistance.PreparedStatements.getConnection
              instead invocation.invokeNext().

              Clebert


              Hi,

              Of course it's impossible to run ...PreparedStatements.getConnection() within anywhere except the class, cause it's private - except one would invoke it by using reflection, which I don't.

              But here is the aspect class, that I haven't provided before:

              public class DbConnectionAspect
              {
               private DbConnectionsHelper dbConnectionsHelper;
              
               public DbConnectionAspect()
               {
               dbConnectionsHelper = new DbConnectionsHelper();
               }
              
               public Object switchConnection(Invocation invocation)
               throws Throwable
               {
               invocation.invokeNext();
               return dbConnectionsHelper.getConnectionForCurrentThread();
               }
              }
              


              As u see, I totally ignore returned value of invocation.invokeNext() which is my aim: to switch global connection into per-thread connection (wchich allows one to program threaded apps in non-threaded way :] )

              I'll check these tests from CVS...

              --nthx


              • 4. Re: IllegalAccessException
                Clebert Rezende Suconic Newbie

                Well...

                The testcase I have it's very simple, and I'm using Interceptor there. (Not aspect)

                The ant target to active the testcase is aop-test or aop-test-classloader


                The sourcetree is:
                /jboss-profiler/java/src/aopAgent/org/jboss/profiler/aop/test

                • 5. Re: IllegalAccessException
                  Kabir Khan Master

                  I'm investigating a fix. For now, could you try using something else than caller pointcuts? For example:

                  <aspect class="banking.jbossaop.transactions.DbConnectionAspect" scope="PER_VM" />
                  <bind pointcut="execution(* banking.aspects.persistance.DatabaseGateway->getConnection())
                   OR
                   execution(* banking.aspects.persistance.PreparedStatements->getConnection())">
                   <advice name="switchConnection"
                   aspect="banking.jbossaop.transactions.DbConnectionAspect" />
                  </bind>
                  
                  


                  • 6. Re: IllegalAccessException
                    Tomasz Nazar Newbie

                    Hi,

                    Problems with cvs compilation:

                    First: downloaded whole jboss cvs tree (default branch)

                    cd jboss-aop
                    build.bat dist

                    Second: In file: jboss-aop/build.xml line:

                    <fileset dir="${project.thirdparty}/xdoclet-xdoclet/lib">
                    
                    is incorrect. There is no dir called xdoclet-xdoclet.

                    But I replaced with correct one, and then
                    removed 'javadocs' from target 'dist' cause of:
                     [javadoc] D:\nthx\install\jbossaop\jboss-cvs-04.08.2004
                    \AnnotatedPOJO.java:16: illegal character: \64
                     [javadoc] @trace public int field;
                     [javadoc] ^
                    


                    Then: `$move 'thirdparty/javassist/javassist ..` cause of:
                    BUILD FAILED
                    D:\nthx\install\jbossaop\jboss-cvs-04.08.2004\jboss-ao
                    -cvs-04.08.2004\thirdparty\javassist\lib not found.
                    

                    And the same with: oswego-concurrent, trove, qdox, junit,

                    And before that:
                    mkdir ..\common\output\lib
                    build dist
                    


                    And thank-you JBoss fellows .. `build dist` built a jar file without classess.

                    `build jars` doesn't work.. problem with not-having other classess (jboss-common)


                    Sorry, but I've seen many build configurations and this isn't one..
                    Is this on purpose? This you call 'professional'?
                    Need help with writing ant files? People, wake up! It's becoming to be not funny...

                    As stated Scott Stark : "Its baseline status requires nothing other than running the jboss-head/build/build.xml script". That's the answer?

                    Please explain...

                    --nthx



                    • 7. Re: IllegalAccessException
                      Bill Burke Master

                      It should be:

                      $ cvs checkout jboss-head
                      $ cd jboss-head/aop
                      $ build.sh dist
                      




                      • 8. Re: IllegalAccessException
                        Tomasz Nazar Newbie

                         

                        "kabkhan" wrote:
                        I'm investigating a fix. For now, could you try using something else than caller pointcuts? For example:
                        <aspect class="banking.jbossaop.transactions.DbConnectionAspect" scope="PER_VM" />
                        <bind pointcut="execution(* banking.aspects.persistance.DatabaseGateway->getConnection())
                        ....
                        


                        DatabaseGateway.getConnection() is private
                        poincut type: 'execution' instead of 'call'

                        It works.. without any problems.
                        Thank you.
                        I still will need 'call' type, though..

                        --
                        nthx


                        • 9. Re: IllegalAccessException
                          Bill Burke Master

                          We know the problem and the bug fix for it. Will fix ASAP.

                          • 10. Re: IllegalAccessException
                            Kabir Khan Master

                            Hello there,

                            I've added a fix for this. Can you get the latest from cvs and try again?

                            • 11. Re: IllegalAccessException
                              Tomasz Nazar Newbie

                               

                              "kabkhan" wrote:
                              Hello there,

                              I've added a fix for this. Can you get the latest from cvs and try again?



                              Hi, I would like to, but..
                              I need help with cvs compilation. I did like Bill said:
                              (windows)
                              > cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/jboss login
                              > cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/jboss co jboss-head
                              (approx 30 minutes of downloading...)
                              > cd jboss-head/aop
                              > build.bat dist
                              ...
                              dist:
                              BUILD FAILED
                              D:\nthx\install\jbossaop\jboss-head-10.08.2004\jboss-head\aop\build.xml:303: D:\nthx\install\jbossaop
                              \jboss-head-10.08.2004\jboss-head\common\output\lib not found.
                              )
                              


                              so...

                              > mkdir ..\common\output
                              > mkdir ..\common\output\lib
                              > build.bat dist
                               [zip] Building zip: D:\nthx\install\jbossaop\jboss-head-10.08.2004\jboss-head\aop\jboss-aop-dis
                              t.zip
                              
                              BUILD SUCCESSFUL
                              


                              It created dist file, without classes in it. Where can I find info about building jboss-aop library? How do you people build it?

                              Task: 'compile' doesn't work:
                              D:\nthx\install\jbossaop\jboss-head-10.08.2004\jboss-head\aop>ant compile
                              Buildfile: build.xml
                              
                              _buildmagic:init:
                              Trying to override old definition of task property
                              
                              _buildmagic:init:buildlog:
                              
                              configure:
                              Overriding previous definition of reference to xdoclet.task.classpath
                              
                              init:
                              
                              compile-classes:
                               [echo] XXXX classes go to: D:\nthx\install\jbossaop\jboss-head-10.08.2004\jboss-head\aop/output/
                              classes
                               [javac] Compiling 297 source files to D:\nthx\install\jbossaop\jboss-head-10.08.2004\jboss-head\a
                              op\output\classes
                               [javac] D:\nthx\install\jbossaop\jboss-head-10.08.2004\jboss-head\aop\src\main\org\jboss\aop\Aspe
                              ctManager.java:32: package org.jboss.util.loading does not exist
                               [javac] import org.jboss.util.loading.Translatable;
                               [javac] ^
                               [javac] D:\nthx\install\jbossaop\jboss-head-10.08.2004\jboss-head\aop\src\main\org\jboss\aop\Aspe
                              ctManager.java:33: package org.jboss.util.loading does not exist
                               [javac] import org.jboss.util.loading.Translator;
                               [javac] ^
                              ...
                              



                              Is this me, or sth is really wrong? Help appreciate..

                              Tomasz


                              • 12. Re: IllegalAccessException
                                Kabir Khan Master

                                jboss aop relies on some files from the common module of jboss. Easiest thing to do is:

                                $cvs checkout jboss-head (YOU HAVE ALREADY DONE THIS...)
                                $cd jboss-head
                                $cd build
                                $build (This builds all of jboss, including aop)
                                $cd ../aop
                                $build dist
                                


                                Now that you have got all the stuff on your machine, if there are any further changes to aop, you can simply do the following from the jboss-head/aop directory:

                                $cvs update -d
                                $build
                                $build dist
                                




                                • 13. Re: IllegalAccessException
                                  Tomasz Nazar Newbie

                                  Ok.
                                  I figured it out after a while, and did as you said. Problem is with finding door: and it was building all jboss. So, thanks anyway.

                                  Let's go back to the problem. I compiled today's version of JBossAOP, and switched jboss-aop.jar only. Before the operation, everything (with `execution of public PreparedStatements.getConnection()) worked fine. After switching to the latest jbossaop:

                                   [aopc] [no comp needed] D:\nthx\E8-workspace\JBossAOPBanking\build\classes\banking\
                                  aspects\persistance\AccountGatewayTest.class
                                   [aopc] [trying to transform] banking.aspects.persistance.BankingWithPersistanceDemo
                                   [aopc] error getting:banking.core.Account. 'credit'
                                   [aopc] java.io.FileNotFoundException:
                                  D:\nthx\E8-workspace\JBossAOPBanking\build\classes\banking\aspects\persistance\
                                  BankingWithPersistanceDemo_N_1585215547985831794banking_aspects_
                                  persistance_BankingWithPersistanceDemo7162818025563628934MethodCalledByMethodInvocation.class
                                   (The system cannot find the path specified)
                                   [aopc] at java.io.FileOutputStream.open(Native Method)
                                   [aopc] at java.io.FileOutputStream.<init>(Unknown Source)
                                   [aopc] at java.io.FileOutputStream.<init>(Unknown Source)
                                   [aopc] at org.jboss.aop.instrument.TransformerCommon.compileOrLoadClass(TransformerCommon.java:113)
                                   [aopc] at org.jboss.aop.instrument.CallerTransformer$CallerExprEditor.createOptimizedMethodCalle
                                  dByMethodInvocationClass(CallerTransformer.java:979)
                                   [aopc] at org.jboss.aop.instrument.CallerTransformer$CallerExprEditor.modifyMethod(CallerTransformer.java:395)
                                   [aopc] at org.jboss.aop.instrument.CallerTransformer$CallerExprEditor.edit(CallerTransformer.java:320)
                                   [aopc] at javassist.expr.ExprEditor.doit(ExprEditor.java:114)
                                   [aopc] at javassist.CtBehavior.instrument(CtBehavior.java:328)
                                   [aopc] at org.jboss.aop.instrument.CallerTransformer.applyCallerPointcuts(CallerTransformer.java:74)
                                   [aopc] at org.jboss.aop.instrument.Instrumentor.applyCallerPointcuts(Instrumentor.java:448)
                                   [aopc] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:511)
                                   [aopc] at org.jboss.aop.AspectManager.translate(AspectManager.java:509)
                                   [aopc] at org.jboss.aop.AspectManager.transform(AspectManager.java:463)
                                   [aopc] at org.jboss.aop.standalone.Compiler.compileFile(Compiler.java:196)
                                   [aopc] at org.jboss.aop.standalone.Compiler.compile(Compiler.java:157)
                                   [aopc] at org.jboss.aop.standalone.Compiler.main(Compiler.java:61)
                                   [aopc] java.lang.RuntimeException: failed to transform: banking.aspects.persistance.BankingWithPersistanceDemo
                                   [aopc] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:548)
                                   [aopc] at org.jboss.aop.AspectManager.translate(AspectManager.java:509)
                                   [aopc] at org.jboss.aop.AspectManager.transform(AspectManager.java:463)
                                   [aopc] at org.jboss.aop.standalone.Compiler.compileFile(Compiler.java:196)
                                   [aopc] at org.jboss.aop.standalone.Compiler.compile(Compiler.java:157)
                                   [aopc] at org.jboss.aop.standalone.Compiler.main(Compiler.java:61)
                                   [aopc] Caused by: javassist.CannotCompileException: by java.io.FileNotFoundException:
                                  D:\nthx\E8-workspace\JBossAOPBanking\build\classes\banking\aspects\
                                  persistance\BankingWithPersistanceDemo_N_1585215547985831794banking_aspects_persistance_
                                  BankingWithPersistanceDemo7162818025563628934MethodCalledByMethodInvocation.class (The system cannot find the path specified)
                                   [aopc] at org.jboss.aop.instrument.CallerTransformer$CallerExprEditor.edit(CallerTransformer.java:328)
                                   [aopc] at javassist.expr.ExprEditor.doit(ExprEditor.java:114)
                                   [aopc] at javassist.CtBehavior.instrument(CtBehavior.java:328)
                                   [aopc] at org.jboss.aop.instrument.CallerTransformer.applyCallerPointcuts(CallerTransformer.java:74)
                                   [aopc] at org.jboss.aop.instrument.Instrumentor.applyCallerPointcuts(Instrumentor.java:448)
                                   [aopc] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:511)
                                   [aopc] ... 5 more
                                   [aopc] java.lang.RuntimeException: failed to transform: banking.aspects.persistance.BankingWithPersistanceDemo
                                   [aopc] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:548)
                                   [aopc] at org.jboss.aop.AspectManager.translate(AspectManager.java:509)
                                   [aopc] at org.jboss.aop.AspectManager.transform(AspectManager.java:463)
                                   [aopc] at org.jboss.aop.standalone.Compiler.compileFile(Compiler.java:196)
                                   [aopc] at org.jboss.aop.standalone.Compiler.compile(Compiler.java:157)
                                   [aopc] at org.jboss.aop.standalone.Compiler.main(Compiler.java:61)
                                   [aopc] Caused by: javassist.CannotCompileException: by java.io.FileNotFoundException:
                                  D:\nthx\E8-workspace\JBossAOPBanking\build\classes\banking\aspects\persistance\
                                  BankingWithPersistanceDemo_N_1585215547985831794banking_aspects_persistance_
                                  BankingWithPersistanceDemo7162818025563628934MethodCalledByMethodInvocation.class (The system cannot find the path specified)
                                   [aopc] at org.jboss.aop.instrument.CallerTransformer$CallerExprEditor.edit(CallerTransformer.java:328)
                                   [aopc] at javassist.expr.ExprEditor.doit(ExprEditor.java:114)
                                   [aopc] at javassist.CtBehavior.instrument(CtBehavior.java:328)
                                   [aopc] at org.jboss.aop.instrument.CallerTransformer.applyCallerPointcuts(CallerTransformer.java:74)
                                   [aopc] at org.jboss.aop.instrument.Instrumentor.applyCallerPointcuts(Instrumentor.java:448)
                                   [aopc] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:511)
                                   [aopc] ... 5 more
                                   [aopc] java.lang.RuntimeException: failed to transform: banking.aspects.persistance.BankingWithPersistanceDemo
                                   [aopc] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:548)
                                   [aopc] at org.jboss.aop.AspectManager.translate(AspectManager.java:509)
                                   [aopc] at org.jboss.aop.AspectManager.transform(AspectManager.java:463)
                                   [aopc] at org.jboss.aop.standalone.Compiler.compileFile(Compiler.java:196)
                                   [aopc] at org.jboss.aop.standalone.Compiler.compile(Compiler.java:157)
                                   [aopc] at org.jboss.aop.standalone.Compiler.main(Compiler.java:61)
                                   [aopc] Caused by: javassist.CannotCompileException: by java.io.FileNotFoundException:
                                  D:\nthx\E8-workspace\JBossAOPBanking\build\classes\banking\aspects\persistance\
                                  BankingWithPersistanceDemo_N_1585215547985831794banking_aspects_persistance_Bank
                                  ingWithPersistanceDemo7162818025563628934MethodCalledByMethodInvocation.class (The system cannot find the path specified)
                                   [aopc] at org.jboss.aop.instrument.CallerTransformer$CallerExprEditor.edit(CallerTransformer.java:328)
                                   [aopc] at javassist.expr.ExprEditor.doit(ExprEditor.java:114)
                                   [aopc] at javassist.CtBehavior.instrument(CtBehavior.java:328)
                                   [aopc] at org.jboss.aop.instrument.CallerTransformer.applyCallerPointcuts(CallerTransformer.java:74)
                                   [aopc] at org.jboss.aop.instrument.Instrumentor.applyCallerPointcuts(Instrumentor.java:448)
                                   [aopc] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:511)
                                   [aopc] ... 5 more
                                   [aopc] Exception in thread "main"
                                  BUILD FAILED: D:\nthx\E8-workspace\JBossAOPBanking\build.xml:66: Java returned: 1
                                  


                                  Any ideas, why?

                                  • 14. Re: IllegalAccessException
                                    Kabir Khan Master

                                    Hi,

                                    All the tests work, so it would be cool to find out what is slipping through the net. Can you please upload an example to the wiki, and post the link?

                                    Thanks

                                    1 2 Previous Next