Я студент: D, и я работаю над проектом для веб-технологий. Я должен работать в JavaEE в JSF Framework с JPA, EJB, JDB C, и у меня есть проблема.
Warning: #{cc.attrs.loginButtonAction}: javax.ejb.EJBException: Transaction aborted
javax.faces.FacesException: #{cc.attrs.loginButtonAction}: javax.ejb.EJBException: Transaction aborted
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at
Все ошибки https://shrib.com/#Gaur8rM4LwV
И мой код.
EJB. Контроллер с базой данных
@Stateless
public class UsersFacade extends AbstractFacade<Users> {
@PersistenceContext(unitName = "OtoNaszDomPU")
private EntityManager em;
@Override
protected EntityManager getEntityManager() {
return em;
}
//...
//...
public String LoginAuthentication(String username, String password) {
Users user = null;
user = GetUser(username);
if (user == null) {
return "notExist";
}
String salt = user.getSalt();
byte[] hashed = HashSha256(password.concat(salt));
String encryptedPassword = bytesToString(hashed);
System.out.println("haslo:" + password + ", salt:" + salt + ", sha: " + encryptedPassword + " == " + user.getPassword());
//Until next line everything works properly.
return encryptedPassword.equals(user.getPassword()) == true ? "true" : "false";
}
Методы Hash256 и byteToString работают корректно И Мой фронт
КомпонентыZlozone: Logowan ie является CompositeComponent
<center>
<h:form class="centered Form">
<h3 style="font-size: 50px">Oto Nasz Dom</h3>
<komponentyZlozone:Logowanie
usernameLabel="#{bundle['logowanie.pseudonim']}"
usernameValue="#{loginController.user}"
passwordLabel="#{bundle['logowanie.haslo']}"
passwordValue="#{loginController.pwd}"
loginButtonLabel="#{bundle['logowanie.zaloguj']}"
loginButtonAction="#{loginController.validateUsernamePassword()}"
/>
<br/><br/>
<h:button value="Rejestracja" outcome="userRegister" style="font-size: 25px; box-shadow: gray; padding: 5px;">
<f:ajax execute="toogle" render="toogleRender" event="click"/>
</h:button>
</h:form>
</center>
CompositeComponent "Blueprint"
<?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:h = "http://java.sun.com/jsf/html"
xmlns:f = "http://java.sun.com/jsf/core"
xmlns:composite = "http://java.sun.com/jsf/composite">
<composite:interface>
<composite:attribute name = "usernameLabel" />
<composite:attribute name = "usernameValue" />
<composite:attribute name = "passwordLabel" />
<composite:attribute name = "passwordValue" />
<composite:attribute name = "loginButtonLabel" />
<composite:attribute name = "loginButtonAction"
method-signature = "java.lang.String validateUsernamePassword()" />
</composite:interface>
<composite:implementation>
<h:form>
<h:panelGrid columns = "2" id = "loginPanel">
#{cc.attrs.usernameLabel} :
<h:inputText id = "username" value = "#{cc.attrs.usernameValue}" required="true" />
#{cc.attrs.passwordLabel} :
<h:inputSecret id = "password" value = "#{cc.attrs.passwordValue}" required="true" />
</h:panelGrid>
<h:commandButton
action = "#{cc.attrs.loginButtonAction}"
value = "#{cc.attrs.loginButtonLabel}"
style="padding: 10px"
/>
</h:form>
</composite:implementation>
</html>
Спасибо за помощь!
edit. Я не понимаю, почему я получаю эту ошибку. Во время отладки я не смог выяснить в чем проблема. (