Mohammed Sardar.

Ranch Hand
+ Follow
since Jun 22, 2014
Mohammed likes ...
Java jQuery Spring
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
16
Received in last 30 days
0
Total given
5
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mohammed Sardar.

Dave Tolls wrote:I'm getting a little confused here.

Can you show the call to importDoc that causes the NullPointerException?
Can you also show where in that class (the one calling importDoc) that the instance of Good it uses comes from?

For example:




Yes, Sure we are missing track. But importDoc is a public method available inside Good class so we don't need create an instance. But inside importDoc, we are trying use a bean or instance that is created by AnnotationConfigApplicationContext and here is where we're getting NPE only if I use Autowired but able to use the bean if I get through Context i.e getBean(RxxxDyyyyHelper.class). Hope this adds more information.
As illustrated below with sample please read comments.






Hope this clarifies. Let me know if I miss something here.




2 weeks ago

Dave Tolls wrote:

Mohammed Sardar. wrote:
We call this Good from other class by reflection but the Good is also initiated at the time of component scanning as a base package.  Thanks



How do you get it by reflection?
I'm not sure that Spring would be involved in that, and so you would not be getting the Spring Bean, but something else entirely, something which would not have had anything injected into it.



Sorry I think  we're not on track because Spring getBean provides all the beans that are mentioned in the componentScan but not when autowiring. So I wish to thanks Spring comes into picture here. And also, For the question asked where "Good" class is initialized  I answered by reflection but I tried passing that class name itself I could not achieve Autowiring.
2 weeks ago

Dave Tolls wrote:

Where is instance of Good used that appears in the NullPointerException stacktrace?
Where is that instance instantiated/injected?

Can you show that code?



We call this Good from other class by reflection but the Good is also initiated at the time of component scanning as a base package.  Thanks
2 weeks ago

Al Hobbs wrote:You need to make sure you are scanning the right packages.  Also make sure your rxxxblahhelper class is annotated with @component.   Since its not a webapp you need to make sure the spring container is started from main



Yes, I double and triple checked @Component annotation is implemented and here is the blocking point actually looking for help.  Container is started, confirmed this by logging some message as "Context Invoked" and there is no issue with that.  The thing is when we try to get the bean with

getApplicationContext().getBean(rxxxblahhelper .class);

container gives back the bean. If try two to autowire no luck with null. I'm trying to get the bean autowired and get the bean required all over the application, instead implementing context everywhere and using getBean() method.
2 weeks ago
Thanks for your time to help me and to your questions.

Al Hobbs wrote:So youre getting a null when its trying to inject rxxxblahhelper?  Does that class even exist?  Also great class names .  Class good and it extends class good11.  ;p

Nice to hear you enjoy the class names  I named, because you are good as they .  Yes, There're classes exist. And they are available from ApplicationContext but unable to do Auto wiring since it throws NPE.

1. The actual code is not pasted here and the  above code is only for references as a sample code.  You are right   Looks like you are calling a method in the middle of a class actually we're not calling code in the mid of class but only in the mid of a method as below.
 
 

2. Code is compiled fine. So,

arent supposed to have injection code in the class. that defeats the purpose of doing dependency injection in the first place

I agree. In this situation, how can we utilize spring feature
to get this injected from the container with Auto Wiring ? Through this what I'm trying to achieve is, certain annotated classes/beans that're available in the spring container can be used directly from container into another classes without using new keyword.

3. Using AnnotationConfigApplicationContext and get this initialized when the main() starts so that all the beans which are annotated with @Component can available for the injection. Again, I would like to state this is not web app it's A stand alone app which provides data to some web API end point.

Hope I'm providing adequate information. But I'm stuck at analyzing the technical feasibility and seeking for help.

2 weeks ago
Can someone help me to edit the subject my post is not getting noticed by any one. Thanks.
3 weeks ago
When trying to use @AutoWire feature with one of StandAlone Application unable to do so instead getting Null Pointer Exception. Please highlight my mistakes if any. Your help is appreciated.

Spring Ver 5.1.5.RELEASE and we're not using any xml config file to tell spring there are annotated classes to look into instead using @ComponentScan or @EnableAutoConfiguration at the top of AppConfig and boost strap the Context from main() class as a first line. But Autowiring works perfectly with internal bean/java classes of jdk(Environment) but not with custom POJO classes. If we're trying to get through getBean method then it works. But I'm trying to avoid creating context everywhere and using getBean() Please Refer below and help me only with your valuable guidelines.  



   

   

3 weeks ago
Can some one help me remove the nationality specific in above ? I don't want to use any specific national that way.

Thanks Rob. So,  are you trying to say why don't I prefer JSON rather XML. But just started exploring web services concept. Not really sure what is going on. So that raised this for help. But the learning video rendered the same XML well and fine. So, Let me try to change to JSON.
4 months ago
Have created a simple Jersey Version of web services Project and trying to render a XML Format of List Produced by a Resource. And Below are my created code. when trying to reach a myresource path getting only the least added XML element and it's getting overridden. Debugged and tried changing code with no clues.  Can some one give me a idea of help on this to debug further ? Thanks

MyResource.java


IndianResource.Java


Output




4 months ago
I'm learning RESTFUL Web Services through some videos and I work in Spring MVC for last 2 years and there is no WS.  There was a question on WS, after I explained RESTController and GET Request, Produces and All. After all these are done how to expose your web services to users ? I'm Keep looking over net and getting answers only as on how to consume WS ? Does that what questions mean ? Please correct if my understanding is not right. So, In order to get ready for that Question, Do I need to practice on @CONSUMES(..) ?  In order to test this scenario  do we have to use only POSTMAN as a tool ? In interview aspect how this can be self trained ? Suggestions are highly appreciated.

Thanks
5 months ago
Nice to have you here. Warm welcomes Ben Forta with Cherry Flowers.
5 months ago
The request in fact doesn't come to specified controller instead will be routed by Front controller. Then as directed by FC request will reach exact request mentioned Ajax.
5 months ago
Welcome Karl Beecher ***
 
    Hope we don't need to read Good programming book if we read this Bad Programming Practice   . Thanks for brought to us.

Warm Regards ...
7 months ago
Good Luck Authors,

  Just gone through the index page and excited to read many new features are covered in this book also with SS(Spring Security) stuff. When coming to App Security, can we expect to enrich our spring knowledge so that we can also code including Banking and Financial Products ? Do we have any hands on practicals with this book?

Thanks
Mohammed Sardar

1 year ago
Warm Welcomes Sharma & Ashish Sarin. Have a nice time here and Thanks...








1 year ago