{"id":"6840006304c679a5","repo":"spring-projects/spring-framework","slug":"no-source-location-joinpoint-available-target-is","errorCode":null,"errorMessage":"No source location joinpoint available: target is null","messagePattern":"No source location joinpoint available: target is null","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"warning","filePath":"spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java","lineNumber":303,"sourceCode":"\t\t\t\tappendType(sb, type.componentType(), useLongTypeName);\n\t\t\t\tsb.append(\"[]\");\n\t\t\t}\n\t\t\telse {\n\t\t\t\tsb.append(useLongTypeName ? type.getName() : type.getSimpleName());\n\t\t\t}\n\t\t}\n\t}\n\n\n\t/**\n\t * Lazily initialized SourceLocation.\n\t */\n\tprivate class SourceLocationImpl implements SourceLocation {\n\n\t\t@Override\n\t\tpublic Class<?> getWithinType() {\n\t\t\tif (methodInvocation.getThis() == null) {\n\t\t\t\tthrow new UnsupportedOperationException(\"No source location joinpoint available: target is null\");\n\t\t\t}\n\t\t\treturn methodInvocation.getThis().getClass();\n\t\t}\n\n\t\t@Override\n\t\tpublic String getFileName() {\n\t\t\tthrow new UnsupportedOperationException();\n\t\t}\n\n\t\t@Override\n\t\tpublic int getLine() {\n\t\t\tthrow new UnsupportedOperationException();\n\t\t}\n\n\t\t@Override\n\t\t@Deprecated(since = \"4.0\") // deprecated by AspectJ\n\t\tpublic int getColumn() {\n\t\t\tthrow new UnsupportedOperationException();","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/e8729d043887bf0d0baf91e062e909b56eb2b708/spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java#L285-L321","documentation":"Thrown by MethodInvocationProceedingJoinPoint's SourceLocationImpl.getWithinType() when the underlying target (methodInvocation.getThis()) is null. This happens when the advised object has no concrete target instance, e.g. when advising a static method or when the proxy uses a singleton target source that returned null.","triggerScenarios":"Calling JoinPoint.getSourceLocation().getWithinType() (directly or transitively) on an advice whose target is null — typically a static method advice or a scenario with no target object.","commonSituations":"Aspects that callgetSourceLocation() (uncommon); advising static methods via Spring AOP; CGLIB proxies on classes with no instance; misconfigured TargetSource returning null.","solutions":["Avoid calling getSourceLocation().getWithinType() when the target may be null; guard with getTarget() != null first.","Do not advise static methods expecting source location; Spring AOP is instance-based.","Ensure the advised bean has a real target instance."],"exampleFix":"// before\nClass<?> within = pjp.getSourceLocation().getWithinType();\n\n// after\nClass<?> within = (pjp.getTarget() != null)\n    ? pjp.getTarget().getClass()\n    : pjp.getSignature().getDeclaringType();","handlingStrategy":"type-guard","validationCode":"if (pjp.getTarget() == null) {\n    // skip source location, fall back to signature declaring type\n}","typeGuard":"boolean hasTarget = pjp.getTarget() != null;","tryCatchPattern":null,"preventionTips":["Never call getSourceLocation().getWithinType() without checking the target first.","Prefer pjp.getSignature().getDeclaringType() which is always available.","Avoid advising static methods when source location is required."],"tags":["spring-aop","aspectj","joinpoint","source-location"],"analyzedSha":"e8729d043887bf0d0baf91e062e909b56eb2b708","analyzedAt":"2026-08-04T19:07:39.725Z","schemaVersion":2}