File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JBoss/WildFly and the fly likes Null Pointer Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Null Pointer Exception" Watch "Null Pointer Exception" New topic

Null Pointer Exception

Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
I get NullPointerException while running the following program.
This program works perfectly in Tomcat 6.0.
Why should it fail in JBOSS?
If I use "Class.ForName(...)", I am able to access the database.

The list I got after running, http://localhost:8080/jmx-console, jndi View :

JMX MBean Operation Result list()
Back to Agent View Back to MBean View Reinvoke MBean Operation

Web Applications

My web-xml has :

My jboss-web.xml has :
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10441

I guess you are having a NullpointerException because the datasource is not injected (if not, post the exception stacktrace). Which version of JBoss are you using? Injection in servlets is not supported in JBoss version 4.2.x or prior versions. It's supported starting JBoss 5. See this for an explanation.

[My Blog] [JavaRanch Journal]
Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
Thanks, Jaikiran.

I use 4.2.2GA.
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
have you stepped through it in the debugger?
did that provide any insight?

Bill Shirley - bshirley -
if (Posts < 30) JavaRanchFAQ);
I agree. Here's the link:
subject: Null Pointer Exception
jQuery in Action, 3rd edition