Introduction
This is an article where the main content is to be discuss about how to solve a certain error message. In detail, that certain error message appear in the Output tab of the NetBeans IDE. Actually, the error message which appear is from the execution of a Java web application running using with the help of NetBeans IDE. In this case, the java web application is using the format of a maven-based project structure. For a reference, there is an article with the title of ‘How to Create maven-based Web Application in NetBeans IDE’ in this link. As an addition, that maven-based project has a JSF library as part of it. So, just check the article in this link with the title of ‘How to Add JSF Library to a maven-based Web Application in NetBeans IDE’ for further reference. While building, compiling and running the java web application, there is an error message appear. Precisely, it appear upon submiiting a form. So, the following is the complete error message log :
15:54:26,044 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "app-1.0-SNAPSHOT.war" (runtime-name: "app-1.0-SNAPSHOT.war") 15:54:26,279 INFO [org.jboss.as.jpa] (MSC service thread 1-6) WFLYJPA0002: Read persistence.xml for my_persistence_unit 15:54:26,451 INFO [org.jipijapa] (MSC service thread 1-7) JIPIORMV53020253: Second level cache enabled for app-1.0-SNAPSHOT.war#my_persistence_unit 15:54:26,451 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 245) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'app-1.0-SNAPSHOT.war#my_persistence_unit' 15:54:26,451 INFO [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 245) HHH000204: Processing PersistenceUnitInfo [ name: my_persistence_unit ...] 15:54:26,459 INFO [org.jboss.weld.deployer] (MSC service thread 1-6) WFLYWELD0003: Processing weld deployment app-1.0-SNAPSHOT.war 15:54:26,484 INFO [io.jaegertracing.internal.JaegerTracer] (MSC service thread 1-6) No shutdown hook registered: Please call close() manually on application shutdown. 15:54:26,484 INFO [org.wildfly.microprofile.opentracing.smallrye] (MSC service thread 1-6) WFLYTRAC0001: Tracer initialized: JaegerTracer(version=Java-1.6.0, serviceName=app-1.0-SNAPSHOT.war, reporter=RemoteReporter(sender=org.wildfly.extension.microprofile.opentracing.spi.sender.WildFlySender@262eb708, closeEnqueueTimeout=1000), sampler=ConstSampler(decision=true, tags={sampler.type=const, sampler.param=true}), tags={hostname=LAPTOP-6EV9VAU3, jaeger.version=Java-1.6.0, ip=172.16.9.216}, zipkinSharedRpcSpan=false, expandExceptionLogs=false, useTraceId128Bit=false) 15:54:26,487 INFO [org.jipijapa] (MSC service thread 1-8) JIPIORMV53020253: Second level cache enabled for app-1.0-SNAPSHOT.war#my_persistence_unit 15:54:26,585 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-8) WFLYJCA0005: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 42.3) 15:54:26,595 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) WFLYJCA0018: Started Driver service with driver-name = app-1.0-SNAPSHOT.war_org.postgresql.Driver_42_3 15:54:26,599 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 245) WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'app-1.0-SNAPSHOT.war#my_persistence_unit' 15:54:26,600 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 245) HHH000400: Using dialect: org.hibernate.dialect.H2Dialect 15:54:26,602 INFO [org.hibernate.envers.boot.internal.EnversServiceImpl] (ServerService Thread Pool -- 245) Envers integration enabled? : true 15:54:26,795 INFO [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 252) Initializing Mojarra 2.3.17.SP01 for context '/app-1.0-SNAPSHOT' 15:54:27,430 INFO [org.primefaces.webapp.PostConstructApplicationEventListener] (ServerService Thread Pool -- 252) Running on PrimeFaces 11.0.0 15:54:27,431 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 252) WFLYUT0021: Registered web context: '/app-1.0-SNAPSHOT' for server 'default-server' 15:54:27,447 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0010: Deployed "app-1.0-SNAPSHOT.war" (runtime-name : "app-1.0-SNAPSHOT.war") 15:54:44,614 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (default task-1) /db-connection-test.xhtml @20,149 actionListener="#{dbConnectionTestView.submit()}": Target Unreachable, identifier 'dbConnectionTestView' resolved to null: javax.el.PropertyNotFoundException: /db-connection-test.xhtml @20,149 actionListener="#{dbConnectionTestView.submit()}": Target Unreachable, identifier 'dbConnectionTestView' resolved to null at [email protected]//com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:67) at [email protected]//javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:124) at [email protected]//javax.faces.event.ActionEvent.processListener(ActionEvent.java:72) at [email protected]//javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:495) at [email protected]//javax.faces.component.UICommand.broadcast(UICommand.java:211) at [email protected]//javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:847) at [email protected]//javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1396) at [email protected]//com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:58) at [email protected]//com.sun.faces.lifecycle.Phase.doPhase(Phase.java:76) at [email protected]//com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:177) at [email protected]//javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:707) at [email protected]//javax.faces.webapp.FacesServlet.service(FacesServlet.java:451) at [email protected]//io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at io.opentracing.contrib.opentracing-jaxrs2//io.opentracing.contrib.jaxrs2.server.SpanFinishingFilter.doFilter(SpanFinishingFilter.java:52) at [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at [email protected]//io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at [email protected]//io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at [email protected]//io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at [email protected]//io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at [email protected]//org.wildfly.elytron.web.undertow.server.ElytronRunAsHandler.lambda$handleRequest$1(ElytronRunAsHandler.java:68) at [email protected]//org.wildfly.security.auth.server.FlexibleIdentityAssociation.runAsFunctionEx(FlexibleIdentityAssociation.java:103) at [email protected]//org.wildfly.security.auth.server.Scoped.runAsFunctionEx(Scoped.java:161) at [email protected]//org.wildfly.security.auth.server.Scoped.runAs(Scoped.java:73) at [email protected]//org.wildfly.elytron.web.undertow.server.ElytronRunAsHandler.handleRequest(ElytronRunAsHandler.java:67) at [email protected]//io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at [email protected]//io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:117) at [email protected]//io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at [email protected]//io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at [email protected]//io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at [email protected]//io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at org.wildfly.security.elytron-web.undertow-server-servlet@1.10.1.Final//org.wildfly.elytron.web.undertow.server.servlet.CleanUpHandler.handleRequest(CleanUpHandler.java:38) at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at [email protected]//org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at [email protected]//org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68) at [email protected]//io.undertow.servlet.handlers.SendErrorPageHandler.handleRequest(SendErrorPageHandler.java:52) at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:275) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:79) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:134) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:131) at [email protected]//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at [email protected]//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1544) at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1544) at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1544) at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1544) at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1544) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:255) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:79) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:100) at [email protected]//io.undertow.server.Connectors.executeRootHandler(Connectors.java:387) at [email protected]//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:852) at [email protected]//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at [email protected]//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990) at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486) at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377) at [email protected]//org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1280) at java.base/java.lang.Thread.run(Thread.java:833) 15:54:44,672 SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (default task-1) javax.el.PropertyNotFoundException: /db-connection-test.xhtml @20,149 actionListener="#{dbConnectionTestView.submit()}": Target Unreachable, identifier 'dbConnectionTestView' resolved to null at [email protected]//com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:67) at [email protected]//javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:124) at [email protected]//javax.faces.event.ActionEvent.processListener(ActionEvent.java:72) at [email protected]//javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:495) at [email protected]//javax.faces.component.UICommand.broadcast(UICommand.java:211) at [email protected]//javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:847) at [email protected]//javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1396) at [email protected]//com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:58) at [email protected]//com.sun.faces.lifecycle.Phase.doPhase(Phase.java:76) at [email protected]//com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:177) at [email protected]//javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:707) at [email protected]//javax.faces.webapp.FacesServlet.service(FacesServlet.java:451) at [email protected]//io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at io.opentracing.contrib.opentracing-jaxrs2//io.opentracing.contrib.jaxrs2.server.SpanFinishingFilter.doFilter(SpanFinishingFilter.java:52) at [email protected]//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at [email protected]//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at [email protected]//io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at [email protected]//io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at [email protected]//io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at [email protected]//io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at [email protected]//org.wildfly.elytron.web.undertow.server.ElytronRunAsHandler.lambda$handleRequest$1(ElytronRunAsHandler.java:68) at [email protected]//org.wildfly.security.auth.server.FlexibleIdentityAssociation.runAsFunctionEx(FlexibleIdentityAssociation.java:103) at [email protected]//org.wildfly.security.auth.server.Scoped.runAsFunctionEx(Scoped.java:161) at [email protected]//org.wildfly.security.auth.server.Scoped.runAs(Scoped.java:73) at [email protected]//org.wildfly.elytron.web.undertow.server.ElytronRunAsHandler.handleRequest(ElytronRunAsHandler.java:67) at [email protected]//io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at [email protected]//io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:117) at [email protected]//io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at [email protected]//io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at [email protected]//io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at [email protected]//io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at org.wildfly.security.elytron-web.undertow-server-servlet@1.10.1.Final//org.wildfly.elytron.web.undertow.server.servlet.CleanUpHandler.handleRequest(CleanUpHandler.java:38) at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at [email protected]//org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at [email protected]//org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68) at [email protected]//io.undertow.servlet.handlers.SendErrorPageHandler.handleRequest(SendErrorPageHandler.java:52) at [email protected]//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:275) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:79) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:134) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:131) at [email protected]//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at [email protected]//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1544) at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1544) at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1544) at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1544) at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1544) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:255) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:79) at [email protected]//io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:100) at [email protected]//io.undertow.server.Connectors.executeRootHandler(Connectors.java:387) at [email protected]//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:852) at [email protected]//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at [email protected]//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990) at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486) at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377) at [email protected]//org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1280) at java.base/java.lang.Thread.run(Thread.java:833)
But the most important line pointing out to the specific error message which is becoming the main hint exist below :
15:54:44,672 SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (default task-1) javax.el.PropertyNotFoundException: /db-connection-test.xhtml @20,149 actionListener="#{dbConnectionTestView.submit()}": Target Unreachable, identifier 'dbConnectionTestView' resolved to null
Actually, before getting on to the process for solving the error message, the following is the actual script of the JSF file. It is a file where the main focus is the database connection process. The file exist in the Web Pages folder. It exist inside the Java web application with the name of ‘db-connection-test.xhtml’. In that file, the focus is the PostgreSQL database server connection. Moreover, the connection is available using a certain trigger. In this case, the trigger is clicking a button where it will trigger or it will execute a method with the name of ‘submit’ exist in a bean with the name of ‘dbConnectionTestView’.
<?xml version="1.0" encoding="UTF-8"?> <!-- Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/XHtml.xhtml to edit this template --> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"> <h:head> <title>Database Connection</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> </h:head> <body> <h:form> <p:outputPanel> <p:outputLabel id="connectionStatus" value="#{dbConnectionTestView.status}"></p:outputLabel> </p:outputPanel> <p:commandButton type="submit" value="Alert" onclick="alert('Prime')" actionListener="#{dbConnectionTestView.submit()}" update="@form"/> </h:form> </body> </html>
Furthermore, the following is the Java Bean class which acts as the reference for processing the submit method where the button’s click action :
/* * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template */ package training.web.view; import training.web.db.DBConnection; import java.io.Serializable; import java.sql.Connection; import javax.faces.view.ViewScoped; import javax.inject.Named; /** * * @author Mark Spectre */ @Named @ViewScoped public class DBConnectionTestView implements Serializable { private Connection connection; String DEFAULT_DB_CONNECTION = "Not Connected"; private String status = DEFAULT_DB_CONNECTION; String DB_CONNECT_SUCCESS = "Database Connection is a success"; String DB_CONNECT_FAILED = "Database Connection is failed"; static void init(){ String url = "jdbc:postgresql://localhost:5432/employee"; String username = "postgres"; String password = "password"; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } }
How to Solve Error Message
Actually, the solution for handling the error message is very easy. The above error message is already hinting the solution. In the above error message, the target is unreachable. What is the target actually ?. It is an identifier with the name of ‘dbConnectionTestView’. Unfortunately, the resolve process of that identifier resulting in a null value. So, the solution is very simple. In this case, just add the name of the bean in the bean class. In this context, the bean class is a Java class with the name of ‘DBConnectionTestView’. But what is the bean name of that Java class. Well, just use the Java class name but use the non-capital letter in front of it. In other words, it is exactly like the name as it exist in the JSF file as in the following line exist as part of the script above :
<p:commandButton type="submit" value="Alert" onclick="alert('Prime')" actionListener="#{dbConnectionTestView.submit()}" update="@form"/>
Specifically, it is in the value of the ‘actionListener’ parameter. It is ‘dbConnectionTestView’ where it will act as a reference to the bean which is a Java class. In that Java class where it acts as the Java Bean, it will have the submit method available for further process in the click action. So, edit the Java class by adding the bean name. The following is the revision of the Java Bean class :
/* * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template */ package training.web.view; import training.web.db.DBConnection; import java.io.Serializable; import java.sql.Connection; import javax.faces.view.ViewScoped; import javax.inject.Named; /** * * @author Mark Spectre */ @Named(value = "dbConnectionTestView") @ViewScoped public class DBConnectionTestView implements Serializable { private Connection connection; String DEFAULT_DB_CONNECTION = "Not Connected"; private String status = DEFAULT_DB_CONNECTION; String DB_CONNECT_SUCCESS = "Database Connection is a success"; String DB_CONNECT_FAILED = "Database Connection is failed"; static void init(){ String url = "jdbc:postgresql://localhost:5432/employee"; String username = "postgres"; String password = "password"; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } }