Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] AspectJ and JAAS problem

> I thought the
> aspect-weaving wasn't supposed to influence the original core code?

That is correct. You are right that moving advice from the base
aspect to a concrete aspect (even in a different package) shouldn't
have affected the functionality. This seems like some subtle issue
with classloading in app server. Something, I will definitely like
to explore and understand.

> BTW: Ramnivas - your book really rocks!

Thanks!

-Ramnivas
--- Hagen_Hasle <haagen@xxxxxxxxxxxx> wrote:
> 
> When I added
> 	permission java.io.FilePermission "C:\\-", "read";
> to my jaas.policy-file, everything worked like a charm.  But I'm
> still
> interested in knowing what it was that created the problem.  Does
> AspectJ,
> in its weaving process, mix the classloaders or something like that? 
> I
> don't quite understand why getClass().getResource() should give
> another
> result after weaving than before, because the code entered by the
> iajc
> compiler is far down in the stacktrace.  The class returned by
> getClass()
> doesn't look changed either, so how come the result changes?  I
> thought the
> aspect-weaving wasn't supposed to influence the original core code?
> 
> BTW: Ramnivas - your book really rocks!
> 
> 
> Regards, Hagen :)
> 
> Hagen Hasle
> haagen@xxxxxxxxxxxx
> 
> -----Original Message-----
> From: aspectj-users-admin@xxxxxxxxxxx
> [mailto:aspectj-users-admin@xxxxxxxxxxx]On Behalf Of Hagen Hasle
> Sent: 29. april 2004 18:05
> To: aspectj-users@xxxxxxxxxxx
> Subject: RE: [aspectj-users] AspectJ and JAAS problem
> 
> 
> 
> Well, the code is based on the admin-application in the Java Pet
> Store.  I
> have created
>
com.sun.j2ee.blueprints.admin.common.higjaas.AbstractPetStoreJAASAspect.java
> under src/admin/ and
> com.sun.j2ee.blueprints.admin.client.PetStoreJAASClientAspect.java
> under
> src/client/.  (And a similar aspect for the server under admin.web) 
> The
> aspect-code is based on the JAAS-chapter in your book, so I guess
> you're
> familiar with it. :)
> 
> The pointcut consists of several elements, but one of those that give
> a me
> problem is
> execution( * PetStoreAdminClient.createToolBar(..) ).
> 
> I use the ant-script that comes with the Pet Store, but have changed
> javac
> to iajc.  It looks like this now:
> <iajc srcdir="${admin.src}"
> 	destdir="${admin.classbindir}"
> 	classpath="${admin.classpath}:c:\aspectj1.1\lib\aspectjrt.jar"
> 	includes="admin/com/**"/>
> <iajc srcdir="${client.src}"
> 	destdir="${client.classbindir}"
> 	classpath="${admin.classpath}:c:\aspectj1.1\lib\aspectjrt.jar"
> 	includes="**"/>
> I don't know if it can cause a problem that I compile separatly?  The
> abstract aspect lies in admin.src.
> 
> I start the application from DOS (I skipped the webstart-thing..)
> with this:
> java -cp
> ../build/classes;../build/client;c:\aspectj1.1\lib\aspectjrt.jar
> -Djava.secu
> rity.manager -Djava.security.policy=policy
> -Djava.security.auth.policy=polic
> y.jaas -Djava.security.auth.login.config=login.conf
> com.sun.j2ee.blueprints.admin.client.PetStoreAdminClient
> com.sun.j2ee.blueprints.admin.clientHttpPostPetStoreProxy localhost
> 8000
> 1000
> (don't mind the stuff after "PetStoreADminClient", it's only
> parameters
> needed by that class..)
> 
> The error comes in the DataSource-class:
> NullPointerException at javax.swing.ImageIcon.<init>(Unknown Source)
> at
>
com.sun.j2ee.blueprints.admin.client.DataSource$RefreshAction.<init>(DataSou
> rce.java:196)
> (Let me know if it helps if I give you the entire stacktrace.)
> 
> Was this helpful, or should I write more?
> 
> If I write out getClass().toString() I get: class
> com.sun.j2ee.blueprints.admin.client.DataSource$RefreshAction, so
> that looks
> quite normal I guess?  I have tried to print out the classloader too,
> and it
> was sun.misc.Launcher$AppClassLoader both with and without the
> pointcut
> defined.
> 
> I guess you are right that it is some kind of permission issue.  I
> read
> briefly about file-permissions, and it looks like it is only possible
> to
> read from the same directory as the code lies in without explicit
> permission.  I will try to add a file-permission that enables the
> code to
> read from other directories too.  But why does it happen?  And why
> don't I
> get an AccessControllerException?  (Is it supposed to return null
> when
> you're not authorized to read a file?)
> 
> 
> Regards, Hagen
> 
> Hagen Hasle
> haagen@xxxxxxxxxxxx
> 
> -----Original Message-----
> From: aspectj-users-admin@xxxxxxxxxxx
> [mailto:aspectj-users-admin@xxxxxxxxxxx]On Behalf Of Ramnivas Laddad
> Sent: 29. april 2004 17:24
> To: aspectj-users@xxxxxxxxxxx
> Subject: Re: [aspectj-users] AspectJ and JAAS problem
> 
> 
> This does look like permission configuration issue.
> Can you try to print value returned by getClass() in
> both cases? Perhaps that will give a hint.
> 
> Can you show minimal code that reproduces the problem?
> 
> -Ramnivas
> 
> --- Hegen_Hasle <haagen@xxxxxxxxxxxx> wrote:
> >
> > I have a problem with AspectJ I don't quite understand...
> >
> > I have my AOP-code in two different packages.
> > One abstract aspect one place, and a concrete aspect together with
> > the code
> > I want to weave it into.
> >
> > In the abstract aspect I have defined an around advice that handles
> > authorization with a doAsPrivileged-block.  In the concrete aspect
> I
> > have
> > the pointcut.
> >
> > The problem I have is that code in the cflow of the
> > doAsPrivileged-block
> > start to misbehave.  There are several
> > getClass().getResource("/path/to/picture.jpg") that suddenly
> returns
> > null
> > instead of the picture.  If I move the around advice to the
> concrete
> > aspect,
> > everything works.
> >
> > I don't quite know if this is some kind of classloader error, or if
> I
> > need
> > to change the JAAS permissions (include some kind of filePermission
> > perhaps?)  The error-message I get is a nullpointer exception when
> > the
> > picture is used in a constructor, and not an
> > AccessControllerException as I
> > might have expected.
> >
> > If I move the folder with the pictures inside the folder-structure
> > where my
> > abstract aspect lies, the error goes away.  But it pops up
> somewhere
> > else
> > instead, in code that is identical (getClass().getResource("...")
> > except it
> > hasn't been weaved with the around-advice, so it's not inside a
> > doAsPrivileged-block.  This suggests to me that it has something to
> > do with
> > the classloader. (?)
> > But if I don't move the pictures, but instead include a
> > java.security.AllPermission in the JAAS policy-file, everything
> works
> > perfectly.  This suggests I need to find the right permission, but
> if
> > that's
> > the case - why doesn't I get an AccessControllerException in the
> > first
> > place?
> >
> > I hope I have explained enough here.  Any suggestions to what I'm
> > doing
> > wrong is greatly appreciated.
> >
> > Apologies if my english is below par..
> >
> > Regards,
> >
> > Hegen
> > haagen@xxxxxxxxxxxx
> >
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> Win a $20,000 Career Makeover at Yahoo! HotJobs
> http://hotjobs.sweepstakes.yahoo.com/careermakeover
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users



	
		
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 


Back to the top