Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7173741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:53:16+00:00 2026-05-28T15:53:16+00:00

I am getting null pointer exception while trying to add anything in my solrQueue.

  • 0

I am getting null pointer exception while trying to add anything in my solrQueue. I checked in debugger and it is because solrQueue is null. But I have autowired it in my application context then why this error?

public class Check {
    @Autowired
    public LinkedBlockingQueue<SolrInputDocument> solrQueue;
    public SolrInputDocument solrDoc;   
    public void solradd(){
        solrDoc=new SolrInputDocument();
        solrDoc.addField("title", "abc");
        solrQueue.add(solrDoc);//solrQueue is null 
    }
}

application Context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
        http://www.springframework.org/schema/aop 
        http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-2.5.xsd">

    <context:annotation-config />
    <!--<context:component-scan base-package="com/abc" />   -->

    <bean id="solrQueue" class="java.util.concurrent.LinkedBlockingQueue" />
    <bean id="check" class="com.abc.Check" scope="prototype" />

</beans>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:53:18+00:00Added an answer on May 28, 2026 at 3:53 pm

    You are creating an instance of Check class manually rather than asking Spring to create/return one for you:

    Check c=new Check();
    c.solradd();
    

    This will never* work since Spring has no knowledge about you created Check class. Depending on how do you start you Spring context, you must either explicitly ask the application context:

    Check check = applicationContext.getBean(Check.class)
    

    or inject the check bean into some other compoent like controller:

    @Autowired
    private Check check;
    

    See also:

    • Spring Dependency Injection Autowiring Null

    * AspectJ weaving will do the trick, but this is like using a cannon to kill a fly

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Iam getting a null pointer exception while sending some string text as an sms
I am getting same null pointer exception while running integration test in eclipse .while
I'm Getting a Null Pointer Exception while canceling the Progress Dialog in Async Task
Hoping you guys can figure out why im getting a null pointer exception with
I'm getting a bizarre null pointer exception and I can't understand why. I narrowed
I'm writing a Linux module and getting: Unable to handle kernel NULL pointer dereference
I keep getting a null exception at the ; below. The ApiUsername & ApiPassword
authentication problem on windows vista (iis7) (cookie is getting written but httpcontext.current.user is null)
Im trying to display this listview, but I keep getting a: 07-17 21:14:22.233: ERROR/AndroidRuntime(349):
i m getting a nullpointer exception continuously but i can't figure out where the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.