В веб-приложении hibernate произошла ошибка FileNotFoundException, для которой я указал правильный путь к файлу
Ниже приведен журнал ошибок
java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1275)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1104)
at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43)
at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:86)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:123)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:118)
at eql.com.dao.EmployeeDAO.addEmployee(EmployeeDAO.java:16)
at eql.com.controller.EmployeeControllerServlet.doPost(EmployeeControllerServlet.java:27)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:407)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:844)
Ниже приведен метод, который будет вызывать сервлет
public void addEmployee(String FirstName,String LastName,String email,String Password,String phone, String City) {
try {
Configuration configuration = new Configuration().configure("src/main/resources/hibernate.cfg.xml");
SessionFactory sessionFactory=configuration.buildSessionFactory();
Session session=sessionFactory.openSession();
Transaction transaction =session.beginTransaction();
Employee em=new Employee();
em.setFirstname(FirstName);
em.setLastname(LastName);
em.setEmailid(email);
em.setPassword(Password);
em.setMobile(phone);
em.setCity(City);
session.save(em);
transaction.commit();
System.out.println("\n\n Details Added");
}
catch(HibernateException e) {
System.out.println(e.getMessage());
System.out.println("error");
}
Hibernate-конфигурация выглядит следующим образом
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/testdb</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password">sql123</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="hbm2ddl.auto">create </property>
<mapping resource="src/main/resources/Employee-hbn.xml" />
</session-factory>
</hibernate-configuration>
POJO-отображение выглядит следующим образом:
<hibernate-mapping>
<class name="eql.com.model.Employee" table="Employee123">
<id column="ID" name="empid" type="java.lang.Integer" />
<property column="FirstName" name="firstname" type="java.lang.String" />
<property column="LastName" name="lastname" type="string" />
<property column="Email" name="emailid" type="java.lang.String" />
<property column="Password" name="password" type="java.lang.String" />
<property column="Phone" name="mobile" type="java.lang.String" />
<property column="City" name="city" type="java.lang.String" />
</class>
</hibernate-mapping>
И структура моего проекта:
Может кто-нибудь найдет решение?помоги мне ...