I am creating simple servlet and deploying it in tomcat server but I am getting the following error:
HTTP Status 500 — Error instantiating servlet class pkg.coreServlet
File Structure on the tomcat server:
webapps
|
- aarya
|
- WEB-INF
|
-web.xml
-src(folder)
|
-pkg
|
-coreServlet.class
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>aaryaservlet</servlet-name>
<servlet-class>pkg.coreServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>aaryaservlet</servlet-name>
<url-pattern>/coreServlet</url-pattern>
</servlet-mapping>
</web-app>
coreServlet.java:
package pkg;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class coreServlet extends HttpServlet
{
/**
*
*/
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws ServletException,IOException
{
PrintWriter out = res.getWriter();
res.setContentType("text/html");
out.println("this is First servlet Example ");
}
}
url I am giving is http://localhost:8080/aarya/coreServlet
I try by restarting tomcat but I am getting same error. Where I am doing wrong?
I am getting the following error on Tomcat.
The code is given below
message Servlet execution threw an exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
java.lang.NoClassDefFoundError: net/sf/ezmorph/Morpher
DBChart.doGet(DBChart.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
java.lang.ClassNotFoundException: net.sf.ezmorph.Morpher
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
DBChart.doGet(DBChart.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Below is my Java file
//imported all the required packages here
class DBChart extends HttpServlet
{
Connection c = null;
Statement st = null;
ResultSet rs = null;
String query = null;
JSONObject obj = null;
JSONObject resobj = null;
PreparedStatement pst = null;
DatabaseMetaData dbmd = null;
String dbURL = "jdbc:sqlserver://localhost:1433; databaseName = EMPLOYEE";
String user = "username";
String password = "mypassword";
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
try
{
List<JSONObject> Details = new LinkedList<JSONObject>();
PrintWriter out = response.getWriter();
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
c = DriverManager.getConnection(dbURL, user, password);
query = " select DeptName, NumberOfEmployess from Departments";
pst = c.prepareStatement(query);
rs = pst.executeQuery();
while (rs.next())
{
String dept = rs.getString(1);
int empnumber = rs.getInt(2);
obj = new JSONObject();
obj.put("DepartmentName", dept);
obj.put("EmployeesinNumbers", empnumber);
Details.add(obj);
}
resobj.put("RelativeDetails", Details);
out.write(resobj.toString());
}
catch (Exception e)
{
System.out.println("Exception " + e);
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
doGet(request, response);
}
}
I made sure that I have mentioned the correct name in XMl file and using the url as follows:
http://localhost:8080/DBCHART/db
0 / 0 / 1 Регистрация: 06.12.2015 Сообщений: 143 |
|
1 |
|
01.06.2017, 21:13. Показов 11760. Ответов 5
Всем привет! Ребят, очень прошу помощи. Установила tomcat, но при запуске выдаёт вот такую гадость. Что делать? В чем проблема? Может уже кто — то сталкивался? Миниатюры
0 |
84 / 84 / 42 Регистрация: 25.01.2010 Сообщений: 386 |
|
01.06.2017, 22:06 |
2 |
Не хватает какой-то либы. Что за проект? Выложи на гит
0 |
0 / 0 / 1 Регистрация: 06.12.2015 Сообщений: 143 |
|
01.06.2017, 22:10 [ТС] |
3 |
Да проекта вобщем — то никакого нет, просто пытаюсь проверить работу сервера.
0 |
4450 / 2683 / 482 Регистрация: 28.04.2012 Сообщений: 8,539 |
|
01.06.2017, 22:27 |
4 |
А что, пункт 7 без ошибок прошёл? И, хотя, наверное, мало что поменялось, но тебя не смущает, что статья семилетней давности?
0 |
0 / 0 / 1 Регистрация: 06.12.2015 Сообщений: 143 |
|
01.06.2017, 22:38 [ТС] |
5 |
С седьмым пунктом все гладко, инфа семилетней давности не смутила, т.к. на всех сайтах установка tomcat описывается одинаково, но с ошибкой мучаюсь уже 2 дня… Переменные среды вроде все прописала и правильно. Миниатюры
0 |
1 / 1 / 0 Регистрация: 25.09.2017 Сообщений: 1 |
|
25.09.2017, 00:15 |
6 |
Если осуществляете установку на Windows, одна из возможных причин — запуск startup нужно осуществлять с правами администратора.
1 |
Hi,
I am new to the OHDSI platform and I am trying to setup a OHDSI stack environment using BroadSea and SQL Server 2016 database.I have followed the guide provided in the BroadSea documentation page(https://github.com/OHDSI/Broadsea) for setup.
I am seeing following error in tomcat logs:
Nov 06, 2017 8:37:06 AM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WebAPI]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1127)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:2020)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webApi': Invocation of init method failed; nested exception is javax.ws.rs.WebApplicationException: HTTP 500 Internal Server Error
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:137)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1620)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.springframework.boot.web.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:151)
at org.springframework.boot.web.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:131)
at org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:86)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5623)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
... 10 more
Caused by: javax.ws.rs.WebApplicationException: HTTP 500 Internal Server Error
at org.ohdsi.webapi.job.JobTemplate.launchTasklet(JobTemplate.java:75)
at org.ohdsi.webapi.service.CDMResultsService.warmCache(CDMResultsService.java:143)
at org.ohdsi.webapi.WebApi.lambda$warmCaches$2(WebApi.java:41)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
at org.ohdsi.webapi.WebApi.warmCaches(WebApi.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:366)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:311)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:134)
... 31 more
Nov 06, 2017 8:37:06 AM org.apache.catalina.startup.HostConfig deployWAR
SEVERE: Error deploying web application archive /usr/local/tomcat/webapps/WebAPI.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/WebAPI]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:903)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1127)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:2020)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
If I remove results record from source_daimon table. This error disappears.
-- RESULTS daimon
INSERT INTO ohdsi.source_daimon( source_daimon_id, source_id, daimon_type, table_qualifier, priority) VALUES (3, 1, 2, 'ohdsi', 2);
Not sure what’s relation of this record with error, Am I missing something?
Thanks,
Rohan
Error:
1 HTTP Status 500 – Internal Server Error
2 Type Exception Report
3
4 Message Error instantiating servlet class [Servlet.BeerSelect]
5
6 Description The server encountered an unexpected condition that prevented it from fulfilling the request.
7
8 Exception
9
10 javax.servlet.ServletException: Error instantiating servlet class [Servlet.BeerSelect]
11 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
12 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
13 org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
14 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
15 org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
16 org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
17 org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:791)
18 org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417)
19 org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
20 java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
21 java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
22 org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
23 java.lang.Thread.run(Unknown Source)
24 Root Cause
25
26 java.lang.UnsupportedClassVersionError: Servlet/BeerSelect has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0 (unable to load class [Servlet.BeerSelect])
27 org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2376)
28 org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:834)
29 org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1297)
30 org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157)
31 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
32 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
33 org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
34 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
35 org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
36 org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
37 org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:791)
38 org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417)
39 org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
40 java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
41 java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
42 org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
43 java.lang.Thread.run(Unknown Source)
44 Note The full stack trace of the root cause is available in the server logs.
I didn’t take a close look at it at the beginning. I thought it was the wrong Tomcat directory structure. I searched the Internet for various methods, but they couldn’t solve it
Later, if you look at root cause carefully, it is caused by the Java runtime version. After thinking about it, I installed it
It is jdk10, and the default compiled version is also 10. The compiled version should be too high
solution:
just lower the compilation level