Win a copy of High Performance Python for Data Analytics this week in the Python forum!

Bj Krishna

Greenhorn
+ Follow
since Jan 12, 2021
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bj Krishna

I deleted all projects and installed Netbeans 12 again and created a fresh web application:

Here is the code generated by NETbeans IDE, I didnt change anything but just ran below is the code:



web.xml file:



error from browser:

HTTP Status 500 – Internal Server Error

Type Exception Report

Message Error instantiating servlet class [com.bobin.SampleServ]

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

javax.servlet.ServletException: Error instantiating servlet class [com.bobin.SampleServ]
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.base/java.lang.Thread.run(Thread.java:832)
Root Cause

java.lang.RuntimeException:
com.bobin.SampleServ.<init>(SampleServ.java:1)
java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.base/java.lang.Thread.run(Thread.java:832)

log file:

13-Jan-2021 16:24:03.961 INFO [http-nio-8081-exec-12] org.apache.catalina.core.ApplicationContext.log Marking servlet [SampleServ] as unavailable
13-Jan-2021 16:24:03.961 SEVERE [http-nio-8081-exec-12] org.apache.catalina.core.StandardWrapperValve.invoke Allocate exception for servlet [SampleServ]
java.lang.RuntimeException:
at com.bobin.SampleServ.<init>(SampleServ.java:1)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:151)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1042)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:761)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:832)

1 week ago
Tim as you requested I created a HTTPServlet and attached the entire code and response from the browser.

1 week ago
Given you the snapshot of the code in IDE in the attached image. Also as you can see a small rounded i in front of the service method line which shows that I am just implementing the service method and I am sure this as worked before in the same netbeans. Also have a doubt when my web applications loads it shows up the index.html page and then I include the URL-pattern in the URL to run the application, could this be a problem should I need to link it from the index.html. Thank you.

let me know if anything else needed.

Thanks,
Krishna
1 week ago
Hi Tim: this is the catalina logs: I doubted why it shows this warning and whether this could be a reason but couldnt figure it out. I have copied the ones that matches with the time stamp of stack trace.

12-Jan-2021 21:53:02.463 INFO [http-nio-8081-exec-15] org.apache.catalina.startup.HostConfig.undeploy Undeploying context [/webapp1]
12-Jan-2021 21:53:07.567 INFO [http-nio-8081-exec-16] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying deployment descriptor [/Users/bobinkrishna/Java/apache-tomcat-9.0.41/conf/Catalina/localhost/webapp1.xml]
12-Jan-2021 21:53:07.567 WARNING [http-nio-8081-exec-16] org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute with value [/webapp1] in deployment descriptor [/Users/bobinkrishna/Java/apache-tomcat-9.0.41/conf/Catalina/localhost/webapp1.xml] has been ignored
12-Jan-2021 21:53:07.591 INFO [http-nio-8081-exec-16] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of deployment descriptor [/Users/bobinkrishna/Java/apache-tomcat-9.0.41/conf/Catalina/localhost/webapp1.xml] has finished in [25] ms
12-Jan-2021 21:53:07.596 INFO [http-nio-8081-exec-19] org.apache.catalina.util.LifecycleBase.start The start() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/webapp1]] after start() had already been called. The second call will be ignored.
12-Jan-2021 21:53:41.814 INFO [http-nio-8081-exec-19] org.apache.catalina.core.StandardContext.reload Reloading Context with name [/webapp1] has started
12-Jan-2021 21:53:41.836 INFO [http-nio-8081-exec-19] org.apache.catalina.core.StandardContext.reload Reloading Context with name [/webapp1] is completed
12-Jan-2021 21:53:51.229 INFO [http-nio-8081-exec-13] org.apache.catalina.core.StandardContext.reload Reloading Context with name [/webapp1] has started
12-Jan-2021 21:53:51.250 INFO [http-nio-8081-exec-13] org.apache.catalina.core.StandardContext.reload Reloading Context with name [/webapp1] is completed
12-Jan-2021 21:54:11.322 INFO [http-nio-8081-exec-19] org.apache.catalina.core.StandardContext.reload Reloading Context with name [/webapp1] has started
12-Jan-2021 21:54:11.336 INFO [http-nio-8081-exec-19] org.apache.catalina.core.StandardContext.reload Reloading Context with name [/webapp1] is completed
12-Jan-2021 21:54:25.636 INFO [http-nio-8081-exec-16] org.apache.catalina.startup.HostConfig.undeploy Undeploying context [/webapp1]
12-Jan-2021 21:54:29.897 INFO [http-nio-8081-exec-11] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying deployment descriptor [/Users/bobinkrishna/Java/apache-tomcat-9.0.41/conf/Catalina/localhost/webapp1.xml]
12-Jan-2021 21:54:29.898 WARNING [http-nio-8081-exec-11] org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute with value [/webapp1] in deployment descriptor [/Users/bobinkrishna/Java/apache-tomcat-9.0.41/conf/Catalina/localhost/webapp1.xml] has been ignored
12-Jan-2021 21:54:29.929 INFO [http-nio-8081-exec-11] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of deployment descriptor [/Users/bobinkrishna/Java/apache-tomcat-9.0.41/conf/Catalina/localhost/webapp1.xml] has finished in [32] ms
12-Jan-2021 21:54:29.938 INFO [http-nio-8081-exec-25] org.apache.catalina.util.LifecycleBase.start The start() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/webapp1]] after start() had already been called. The second call will be ignored.

It is my own example Tim which worked separately when I run it out of IDE.  The IDE creates a HTTPServlet by default but it was giving this error, so what I did was I removed the HTTPservlet and used GenericServlet just to check if it works without any error but it still gives the same error.  I basically deleted the collapsed methods of HTTPServlet which is what Dave is asking for but that is not in the code any more. what I copied is what exists in Servlet.

Did I give you the information you are looking out for ? also as you mentioned where can I check for any member variable defined whose initialization expression failed? thank you for your help.
1 week ago
a simple servlet:

web.xml:

but I get the following error:

12-Jan-2021 21:53:14.428 INFO [http-nio-8081-exec-11] org.apache.catalina.core.ApplicationContext.log Marking servlet [firstServlet] as unavailable
12-Jan-2021 21:53:14.428 SEVERE [http-nio-8081-exec-11] org.apache.catalina.core.StandardWrapperValve.invoke Allocate exception for servlet [firstServlet]
java.lang.RuntimeException:
at simple.servlets.FirstServlet.<init>(FirstServlet.java:1)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:151)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1042)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:761)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:832)
12-Jan-2021 21:54:33.982 INFO [http-nio-8081-exec-26] org.apache.catalina.core.ApplicationContext.log Marking servlet [firstServlet] as unavailable
12-Jan-2021 21:54:33.983 SEVERE [http-nio-8081-exec-26] org.apache.catalina.core.StandardWrapperValve.invoke Allocate exception for servlet [firstServlet]
java.lang.RuntimeException:
at simple.servlets.FirstServlet.<init>(FirstServlet.java:1)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:151)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1042)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:761)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:832)

servlet-api.jar is correctly mapped to CLASSPATH. Any help to resolve it would be appreciated.
1 week ago