0

So, basically I created xhtml file and JSF managed bean i use with that xhtml. And everything worked fine. But later, i had to call Stateful Session Bean in JSF managed bean file and use its methods. Since i use NetBeans IDE, i called SSB (right click->insert code->call enterprise bean). And after calling it, i now get the target unreachable error for some reason (and i didnt even call any of its methods yet).

Here is the xhtml file:

<?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://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Početna stranica</title>
    </h:head>
    <h:body onload="#{korisnikIndex.dohvatiSveKorisnike()}">            
        <h:form style="display:#{korisnikIndex.uspjesnaPrijava}" >
            <h:link value="Upravljanje Aerodromima " outcome="upravljanjeAerodromima.xhtml"/>
            <br></br>
            <h:link value="Upravljanje letovima" outcome="upravljanjeLetovima.xhtml"/>
            <br></br>
            <h:link value="Napredne stavke aerodroma" outcome="napredneStavkeAerodroma.xhtml"/>
            <br></br>
            <h:link value="Pregled poruka" outcome="pregledPoruka.xhtml"/>
            <br></br>
            <h:link value="Pregled dnevnika" outcome="pregledDnevnika.xhtml"/>
        </h:form >
        <h:form >
            Prijava       
            <h:panelGrid columns="2">
                <h:outputLabel value="Korisničko ime:" style="font-weight: bold;"/>
                <h:inputText value="#{korisnikIndex.prijavljeniKorisnikKorime}"/>

                <h:outputLabel value="Lozinka:" style="font-weight: bold;"/>
                <h:inputSecret value="#{korisnikIndex.prijavljeniKorisnikLozinka}"/>
            </h:panelGrid>
            <br></br>
            <h:commandButton value="Prijavi se"
                             id="gumbPrijava"
                             action="#{korisnikIndex.prijavaKorisnika()}">
            </h:commandButton>

        <br></br>

            Registracija       
            <h:panelGrid columns="2">
                <h:outputLabel value="Ime:" style="font-weight: bold;"/>
                <h:inputText value="#{korisnikIndex.ime}"/>

                <h:outputLabel value="Prezime:" style="font-weight: bold;"/>
                <h:inputText value="#{korisnikIndex.prezime}"/>

                <h:outputLabel value="E-mail adresa:" style="font-weight: bold;"/>
                <h:inputText value="#{korisnikIndex.email}"/>

                <h:outputLabel value="Korisničko ime:" style="font-weight: bold;"/>
                <h:inputText value="#{korisnikIndex.korime}"/>

                <h:outputLabel value="Lozinka:" style="font-weight: bold;"/>
                <h:inputSecret value="#{korisnikIndex.lozinka}"/>

                <h:outputLabel value="Ponovljena lozinka:" style="font-weight: bold;"/>
                <h:inputSecret value="#{korisnikIndex.ponovljenaLozinka}"/>
            </h:panelGrid>
            <br></br>
            <h:commandButton value="Registriraj se"
                             id="gumbRegistracija"
                             action="#{korisnikIndex.registracijaKorisnika()}"/>
            </h:form>
            <h:form style="display:#{korisnikIndex.uspjesnaPrijava}">



            Ažuriranje podataka       
            <h:panelGrid columns="2">
                <h:outputLabel value="Ime:" style="font-weight: bold;"/>
                <h:inputText value="#{placeholder}"/>

                <h:outputLabel value="Prezime:" style="font-weight: bold;"/>
                <h:inputText value="#{placeholder}"/>

                <h:outputLabel value="E-mail adresa:" style="font-weight: bold;"/>
                <h:inputText value="#{placeholder}"/>

                <h:outputLabel value="Korisničko ime:" style="font-weight: bold;"/>
                <h:inputText value="#{placeholder}"/>

                <h:outputLabel value="Lozinka:" style="font-weight: bold;"/>
                <h:inputSecret value="#{placeholder}"/>

                <h:outputLabel value="Ponovljena lozinka:" style="font-weight: bold;"/>
                <h:inputSecret value="#{placeholder}"/>
            </h:panelGrid>
            <br></br>
            <h:commandButton value="Ažuriraj"
                             id="gumbAzuriranje"
                             action="#{placeholder.sakrijElement()}"/>            



            Pregled korisnika  
            <p:dataTable id="lista" var="dohvaceniKorisnik" value="#{korisnikIndex.listaKorisnika}"
                         paginator="true" rows="4"
                         paginatorTemplate="{CurrentPageReport} {FirstPageLink}
                         {PreviousPageLink} {PageLinks} {NextPageLink}
                         {LastPageLink} {RowsPerPageDropdown}" style="width:800px;">
                <p:column headerText="Ime">
                    <h:outputText value="#{dohvaceniKorisnik.ime}"/>
                </p:column>

                <p:column headerText="Prezime">
                    <h:outputText value="#{dohvaceniKorisnik.prezime}"/>
                </p:column>

                <p:column headerText="Korisničko ime">
                    <h:outputText value="#{dohvaceniKorisnik.korime}"/>
                </p:column>               

                <p:column headerText="E-mail">
                    <h:outputText value="#{dohvaceniKorisnik.email}"/>
                </p:column>
            </p:dataTable>
        </h:form>
    </h:body>
</html>

And here is the JSF managed bean im using for xhtml from above (for now, i didnt paste everything since its too big. Only the upper part of the code. Note the @EJB notation and calling the Stateful Session Bean below it. Once i remove those, everyting works fine for some reason:

@Named(value = "korisnikIndex")

@SessionScoped public class KorisnikIndex implements Serializable {

@EJB
private Autentikacija autentikacija;

/**
 * Creates a new instance of KorisnikIndex
 */
private String ime;
private String prezime;
private String korime;
private String lozinka;
private String email;
private String poruka = "";

private String azuriranoIme;
private String azuriranoPrezime;
private String azuriranoKorime;
private String azuriranoLozinka;
private String azuriranoEmail;
private String azuriranoPonovljenaLozinka;

private String prijavljeniKorisnikKorime;
private String prijavljeniKorisnikLozinka;

private String uspjesnaPrijava = "none";

I dont think there is a need to write whole code from managed bean since evertyhing works fine after removing @EJB... But if needed, ill post everything.

Here is the whole error:

/index.xhtml @26,82 value="#{korisnikIndex.prijavljeniKorisnikKorime}": Target Unreachable, identifier 'korisnikIndex' resolved to null

Thank you for you help.

Bogy
  • 13
  • 6
  • 1
    Possible duplicate of [Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable](https://stackoverflow.com/questions/30128395/identifying-and-solving-javax-el-propertynotfoundexception-target-unreachable) – Selaron Jun 13 '19 at 06:01
  • I already looked at other threads, but i didnt find any answer. – Bogy Jun 13 '19 at 07:47

0 Answers0