Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in AspectJ's Java15AnnotationFinder when running on JDK 1.6 [SPR-4390] #9069

Closed
spring-issuemaster opened this issue Jan 25, 2008 · 14 comments

Comments

Projects
None yet
1 participant
@spring-issuemaster
Copy link
Collaborator

commented Jan 25, 2008

Martin Thelian opened SPR-4390 and commented

When running a webapp in jboss with Java 6.0 I get the following Exception during startup:


rg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'objectFactory' defined in class path resource [cc/lovo/types/springContext.xml]: Initialization of bean failed; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:445)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:383)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:353)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:400)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:736)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:123)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:76)
at cc.lovo.service.bootstrap.BootServlet.init(BootServlet.java:27)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3951)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4225)
[...]
Caused by: java.lang.NullPointerException
at org.aspectj.weaver.reflect.Java15AnnotationFinder.getAnnotations(Java15AnnotationFinder.java:109)
at org.aspectj.weaver.reflect.ReflectionBasedResolvedMemberImpl.unpackAnnotations(ReflectionBasedResolvedMemberImpl.java:174)
at org.aspectj.weaver.reflect.ReflectionBasedResolvedMemberImpl.hasAnnotation(ReflectionBasedResolvedMemberImpl.java:158)
at org.aspectj.weaver.patterns.ExactAnnotationTypePattern.matches(ExactAnnotationTypePattern.java:82)
at org.aspectj.weaver.patterns.AnnotationPointcut.matchInternal(AnnotationPointcut.java:151)
at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:146)
at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.getShadowMatch(PointcutExpressionImpl.java:235)
at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.matchesExecution(PointcutExpressionImpl.java:101)
at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.matchesMethodExecution(PointcutExpressionImpl.java:92)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.getShadowMatch(AspectJExpressionPointcut.java:362)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:239)
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:205)
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:244)
at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:278)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:113)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:85)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:66)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:296)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:331)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1266)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:438)
... 151 more


With java 1.5 there is no problem.


Affects: 2.5.1

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 25, 2008

Juergen Hoeller commented

Ramnivas, this seems to be a JDK 1.6 compatibility problem in AspectJ 1.5... Can you please follow up with Andy on whether we can fix this in AspectJ 1.5.x already, not having to wait for AspectJ 1.6?

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 21, 2008

Andy Clement commented

I have put a guard into the AspectJ code for this NPE. The fact that the NPE occurs means one of our assumptions in that code is invalid in a Java6 environment. So, when the guard detects this situation it will display some state at that time indicating what led to the NPE. Please can you try the same scenario using the aspectjweaver.jar from the latest AspectJ Development build available here:

http://www.eclipse.org/downloads/download.php?file=/tools/aspectj/dev/aspectj-DEVELOPMENT-20080221125823.jar

The guard will cause the application to continue now, rather than fail, but if I am not able to get hold of the diagnostics to verify why the NPE is happening, I won't be able to determine if we are missing out on some important annotations attached to a method.

The diagnostic code I have put in is:
System.err.println("Unexpected problem in Java15AnnotationFinder: cannot retrieve annotations on method '"+onMember.getName()+"' in class '"+jc.getClassName()+"'");

I am expecting there to be something strange about the method name - the NPE occurs because we cannot find it in the list of methods defined on the class that will be reported. If we can get these initial diagnostics, I may then ask for the list of methods on the offending class...

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 24, 2008

Martin Thelian commented

Hi!
I'm getting the following error-messages:


14:06:10,015 ERROR [STDERR] Unexpected problem in Java15AnnotationFinder: cannot retrieve annotations on method 'newInstance' in class 'javax.xml.bind.JAXBContext'
14:06:10,015 ERROR [STDERR] Unexpected problem in Java15AnnotationFinder: cannot retrieve annotations on method 'newInstance' in class 'javax.xml.bind.JAXBContext'
14:06:10,016 ERROR [STDERR] Unexpected problem in Java15AnnotationFinder: cannot retrieve annotations on method 'newInstance' in class 'javax.xml.bind.JAXBContext'
14:06:10,016 ERROR [STDERR] Unexpected problem in Java15AnnotationFinder: cannot retrieve annotations on method 'createBinder' in class 'javax.xml.bind.JAXBContext'
14:06:10,017 ERROR [STDERR] Unexpected problem in Java15AnnotationFinder: cannot retrieve annotations on method 'createBinder' in class 'javax.xml.bind.JAXBContext'
14:06:10,017 ERROR [STDERR] Unexpected problem in Java15AnnotationFinder: cannot retrieve annotations on method 'createJAXBIntrospector' in class 'javax.xml.bind.JAXBContext'
14:06:10,017 ERROR [STDERR] Unexpected problem in Java15AnnotationFinder: cannot retrieve annotations on method 'generateSchema' in class 'javax.xml.bind.JAXBContext'


@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 26, 2008

Andy Clement commented

Thanks for running that. I can see the problem now. The JAXB stuff is included in Java6 but was not included in Java5. I imagine you also have a version on your classpath. On Java5 we only ever find that version and everything is fine. On Java6 we are encountering both versions since we load the classes in different ways at different times - so we are operating on the Java6 version and then a loadclass occurs that picks up the Java5 version. The methods listed there (createBinder/etc) do not exist on the Java5 version of the JAXBContext object, so we fail. I will try and make the classloading consistently use the same version in all cases.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 27, 2008

Andy Clement commented

I have just released AspectJ1.6.0m2 which includes the fix for this to use reflection rather than repeating class loading - so the NPE cannot occur and the debug messages no longer come out.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 27, 2008

Martin Thelian commented

Andy Clement wrote:
|> I imagine you also have a version on your classpath.

Yes we have a quite old JAXB 1.05 on our classpath. Thank you for the bugfix.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 14, 2008

Chris Wall commented

I'm seeing the same issue w/ the following:

aspectjrt.jar and aspectjweaver.jar 1.5.3 (Spring 2.5 & 2.5.2)

  • and --
    aspectjrt.jar and aspectjweaver.jar 1.6.0m2 (Spring 2.5.2)

java version "1.5.0_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_13-b05, mixed mode)

Caused by: java.lang.NullPointerException
at org.aspectj.weaver.reflect.Java15AnnotationFinder.getParameterNamesFromLVT(Java15AnnotationFinder.java:192)
at org.aspectj.weaver.reflect.Java15AnnotationFinder.getParameterNames(Java15AnnotationFinder.java:183)
at org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate.tryToDiscoverParameterNames(Java15ReflectionBasedReferenceTypeDelegate.java:297)
at org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate.getDeclaredPointcuts(Java15ReflectionBasedReferenceTypeDelegate.java:270)
at org.aspectj.weaver.ReferenceType.getDeclaredPointcuts(ReferenceType.java:530)

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 14, 2008

Chris Wall commented

Should that my plugin contains JAXB 2.0.

Thoughts?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 17, 2008

Andy Clement commented

See AspectJ bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=222987 that I have just raised to cover this new failure. It is different to the problem the bug was originally raised for although the problem is in the same class (Java15AnnotationFinder) - there is a patch in the AspectJ bug to apply to AspectJ154 that will produce some diagnostics to help determine why our assumption in Java15AnnotationFinder is invalid.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 23, 2008

Ramnivas Laddad commented

Chris,

Can you give it another try, since Andy has made available a newer version of AspectJ6 with changed related to this.

-Ramnivas

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 24, 2008

Juergen Hoeller commented

Please test this against the Spring 2.5.4 GA release once it's out, including AspectJ 1.6.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented May 14, 2008

Juergen Hoeller commented

Fix scheduled for AspectJ 1.6.1 - to be shipped with Spring 2.5.6.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Jul 1, 2008

Juergen Hoeller commented

I've upgraded to AspectJ 1.6.1 RC1 for the next Spring 2.5.6 snapshot. The actual 2.5.6 release will ship against AspectJ 1.6.1 final.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Aug 18, 2008

Demian Neidetcher commented

I was able to go to AspectJ 1.6.1 while still being back with Spring 2.0.5

<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.1</version>
</dependency>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.