Sunday, April 3, 2011

Error 500--Internal Server Error


I have a struts Application which was deployed in BEA Weblogic Server instance and was working as expected. This Application is using some of the external API’s as well.

As part of enhancement, I modified some of the java files and replaced the external API’s with the re-written API’s and built the application (WAR/JAR) using ecplise-Ant and deployed it on the BEA Weblogic Server instance. Unfortunately it had thrown the “Error 500--Internal Server Error” as below.

==================================================================
Error 500--Internal Server Error
java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:308)
at java.lang.Class.newInstance(Class.java:261)
at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:163)
at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:138)
at org.apache.struts.action.RequestProcessor.processActionCreate(RequestProcessor.java:278)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:218)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:446)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1077)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7047)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
Caused by: java.lang.NullPointerException
at java.util.Hashtable.get(Hashtable.java:333)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:233)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at com.abc.wam.base.BaseAction.(BaseAction.java:30)
... 24 more



I was 100% sure; this was not the application issue and something to do with the Java classpath. The issue is i didn’t install JAVA JDK on the desktop where I built the application instead I placed the installed version of java jdk & jre folders from other desktop since i didn't have the admin privileges to install the software. And I had set the classpath & javahome variables. This setup was working for all the other applications but not for this application. It was a strange issue and tried the following and resolved this.

If your are getting the above exception try the following possibilities, one of them could solve your issues.


  • Check your application's build path - verify lib jar file locations.
  • Try to build the same application on the other system.
  • Verify the java version and its compatibility with your application.

JBoss service shutdown issue

I recently installed Jboss-5.0.0.GA version on my Linux environment and configured the Application server to run as a service as per the below guidelines.


Jboss Run the Application Server as a Service


I was able to start the jboss application server by using the service but i couldn't stop the service. It was throwing the following exception while stopping jboss service.


hostname018:/opt/jboss-5.0.0.GA/bin # /etc/init.d/jboss_eap stop
JBOSS_CMD_START = cd /opt/jboss-5.0.0.GA/bin; /opt/jboss-5.0.0.GA/bin/run_custom.sh
Exception in thread "main" javax.naming.CommunicationException: Could not obtain connection to any of these urls: hostname018.domain.com:1099 [Root exception is javax.naming.CommunicationException: Failed to connect to server hostname018.domain.com:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server hostname018.domain.com:1099 [Root exception is java.net.ConnectException: Connection refused]]]
        at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1727)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:680)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:673)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at org.jboss.Shutdown.main(Shutdown.java:219)
Caused by: javax.naming.CommunicationException: Failed to connect to server hostname018.domain.com:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server hostname018.domain.com:1099 [Root exception is java.net.ConnectException: Connection refused]]
        at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:311)
        at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1698)
        ... 4 more
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server hostname018.domain.com:1099 [Root exception is java.net.ConnectException: Connection refused]
        at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:281)
        ... 5 more
Caused by: java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:97)
        at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:82)
        at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:277)
        ... 5 more
hostname018:/opt/jboss-5.0.0.GA/bin #


I found the interesting solution for this issue after enough investigation. This might save some of your precious time during your installation/configuration.

I made sure that this exception is nothing to do with the service configuration. I was getting this exception even though i use the shutdown_custom.sh command to stop the service. Then i tried the following telnet command to make sure that my service is listening to port which is used for shutdown process. 

hostname018:~# telnet hostname018.domain.com 1099

Then I found the weired thing that it first tried to map it to the some unknown IP address and then connects to the it's own IP address as below.

hostname018:~# telnet hostname018.domain.com 1099
Trying 192.168.4.88...
telnet: connect to address 192.168.4.88: Connection refused
Trying 152.141.186.188...
Connected to hostname018.domain.com.
Escape character is '^]'.


Then i got a clue and verified the host file entry. Found the interesting thing here, this domain name was mapped to some irrelevant IP address 192.168.4.88 in the host file. 

Jboss service shutdown service is working as expected without any issues after removing the irrelevant host file entry.