Веб-приложение работает нормально при работе с Eclipse IDE
Но после его развертывания на сервере wildfly не происходит связывание для доступа к базе данных.На приведенной ниже странице jsf имеются данные ниже ДОБАВИТЬ Новые данные и при отправке ДОБАВИТЬ Новые данные появится диалоговое окно для добавления данных, но оно не отображается после развертывания на wildfly.И получение исключения нулевого указателя для страниц, обращающихся к базе данных.
Context Path:/STCMedicalSystem
Servlet Path:/secure/MedVoucUpdate.jsf
Path Info:null
Query String:null
Stack Trace:
javax.servlet.ServletException
at javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:725)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:451)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:364)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at com.stc.medical.dao.ConnectionPool.getConnection(ConnectionPool.java:47)
at com.stc.medical.service.RegMedicalVoucherService.getAllMedicalNos(RegMedicalVoucherService.java:21)
at com.stc.medical.upload.RegMedicalVoucherAction.<init>(RegMedicalVoucherAction.java:32)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:162)
at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:76)
at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:387)
at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:247)
at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:200)
at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:55)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:156)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:184)
at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:92)
at com.sun.el.parser.AstValue.getBase(AstValue.java:126)
at com.sun.el.parser.AstValue.getValue(AstValue.java:175)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:202)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:73)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:170)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:157)
at javax.faces.component.UIData.getValue(UIData.java:736)
at javax.faces.component.UIData.getDataModel(UIData.java:1849)
at javax.faces.component.UIData.getRowCount(UIData.java:347)
at org.primefaces.component.datatable.DataTable.calculatePage(DataTable.java:769)
at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:160)
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:85)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:595)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:286)
at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:90)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:566)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1647)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:152)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:566)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1647)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:468)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:170)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:132)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:102)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:76)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:199)
at javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:708)
... 42 more
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>STCMedicalSystem</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<resource-ref>
<description>My DataSource Reference</description>
<res-ref-name>jdbc/stc_medical</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<servlet>
<servlet-name>FacesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>start</param-value>
</context-param>
</web-app>
page.xhtml:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
<title>STC Medical system</title>
<link rel="shortcut icon" type="image/x-icon"
href="../resources/images/favicon.ico" />
<link href="../resources/css/style1.css" rel="stylesheet"
type="text/css" />
<link rel="stylesheet" type="text/css"
href="../resources/css/sdmenu.css" />
<script type="text/javascript" src="../resources/js/sdmenu.js"></script>
<h:body>
<h:form id="dbform">
<p:growl id="growl" />
<h:panelGrid>
<p:outputPanel>
<h:outputText value="Filter by Flag(E, R, S, D, N): " />
<h:selectOneMenu immediate="true"
value="#{allMedVocAction.selectedFlag}"
onchange="submit()"
valueChangeListener="#{allMedVocAction.flagFilter}"
render="true">
<f:selectItem itemLabel="Select One" itemValue="all" />
<f:selectItems id="options"
value="#{allMedVocAction.flagNames}" />
</h:selectOneMenu>
</p:outputPanel>
</h:panelGrid>
<h:panelGroup id="dbpanelgrid">
<p:dataTable style="width:800px;" id="tbl" var="med"
value="#{allMedVocAction.searchResults}"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15" rowKey="med.file"
selection="med.selectedMedNo"
columnClasses="text,number,number,number,text,text"
rowClasses="table-evenRow,table-oddRow"
update="excelPdfPanelGroup" rows="5"
selectionMode="single"
rowSelectListener="#{allMedVocAction.onDataSelect}">
<p:column sortBy="#{med.brno}" filterBy="#{med.brno}"
filterMatchMode="contains">
<f:facet name="header">
<h:outputText value="BRNO" />
</f:facet>
<h:outputText value="#{med.brno}" />
</p:column>
<p:column style="text-align:center;">
<f:facet name="header">
<h:outputText value="EDIT" />
</f:facet>
<p:commandButton title="EDIT" onclick="dlg2.show();"
render="tbl"
action="#{allMedVocAction.editMcodeDetails}"
image="ui-icon ui-icon-pencil"
update="editfrom:editdevice,display" immediate="true">
<f:setPropertyActionListener value="#{med}"
target="#{allMedVocAction.selectedMedNo}" />
</p:commandButton>
</p:column>
</p:dataTable>
<!-- Delete Dialog box -->
<!-- Preview Dialog box -->
</h:panelGroup>
</h:form>
</h:body>
</html>
Получение кода ответа 500 в журнале доступа tomcat для страниц jsf после развертывания на сервере tomcat.context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<Context path="/stc_medical">
<Resource name="jdbc/stc_medical"
auth="Container"
type="javax.sql.DataSource"
username="root"
password="root"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/stc_medical?autoReconnect=true"
validationQuery="select 1"
maxActive="10"
maxIdle="4"/>
</Context>
Класс ConnectionPool:
public class ConnectionPool {
private static ConnectionPool pool = null;
private static DataSource dataSource = null;
private ConnectionPool() {
try {
InitialContext ic = new InitialContext();
dataSource = (DataSource) ic
.lookup("java:/comp/env/jdbc/stc_medical");
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Get an instance of the connection pool
*
* @return ConnectionPool
*/
public static ConnectionPool getInstance() {
if (pool == null) {
pool = new ConnectionPool();
}
return pool;
}
/**
* Get a connection
*
* @return Connection
*/
public Connection getConnection() {
try {
return dataSource.getConnection();
} catch (SQLException sqle) {
sqle.printStackTrace();
return null;
}
}
/**
* Free a connection
*
* @param c
*/
public void freeConnection(Connection c) {
try {
c.close();
} catch (SQLException sqle) {
sqle.printStackTrace();
}
}
}
Я поместил mysql-connector-java-5.1.23-bin в каталог lib tomcat при развертывании файла war, ноне может получить доступ к базе данных.Я пробовал много способов, но не смог найти решение.