Konfiguracja GlassFish - kontrola dostępu.

0

Witam,
postanowiłem odgrzebać moją apkę: https://github.com/pangeon/SEKP
kiedyś na pewno działała, bo dzięki niej zaliczyłem podyplomówkę z Java EE.

Większość rzeczy udało mi się skonfigurować, na podstawie raportu który też jest w repozytorium
ale jednej nie - mimo że autoryzacja, zapisywanie kont do bazy danych działa, to nadal mam dziwne
problemy z wyświetlaniem poszczególnych danych ze "spokrewnionych tabel". Dostaje błąd numer 500.

Aplikacja musi działać, skoro kiedyś było okej. Musiałem coś zgubić w konfiguracji, niestety nie wiem co.
Proszę o sugestie, choć domyślam się że to nie będzie łatwe - projekt jest duży.

0

Wiem, wiem trudno ocenić bez większej ilości informacji, więc:

GlassFish jest 4.0, SecurityRealm działa bo logowanie jest okej,
użytkownicy się dodają do bazy. Nie mam natomiast dostępu do danych z
kolekcji. Zamieszczam pliki konfiguracyjne i warningi:

Warning: JSF1058: The resource referred to by to-view-id, 'index.xhtml', for navigation from '/', does not start with '/'. This will be added for you, but it should be corrected.
Warning: JSF1058: The resource referred to by to-view-id, 'new_user.xhtml', for navigation from '/
', does not start with '/'. This will be added for you, but it should be corrected.
Warning: JSF1058: The resource referred to by to-view-id, 'error_page.xhtml', for navigation from '/', does not start with '/'. This will be added for you, but it should be corrected.
Warning: JSF1058: The resource referred to by to-view-id, 'confirm.xhtml', for navigation from '/
', does not start with '/'. This will be added for you, but it should be corrected.
Warning: JSF1058: The resource referred to by to-view-id, 'user/data_user_list.xhtml', for navigation from '/', does not start with '/'. This will be added for you, but it should be corrected.
Warning: JSF1058: The resource referred to by to-view-id, 'inactive_account.xhtml', for navigation from '/
', does not start with '/'. This will be added for you, but it should be corrected.
Warning: The error-page C:\Users\Kamil\Documents\NetBeansProjects\System\target\System-1.0\faces\error\500.xhtml does not exist

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>15</session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>/faces/index.xhtml</welcome-file>
    </welcome-file-list>
    <security-constraint>
        <display-name>Management System - Users</display-name>
        <web-resource-collection>
            <web-resource-name>User Realm</web-resource-name>
            <description/>
            <url-pattern>/faces/user/*</url-pattern>
            <url-pattern>/faces/user/login_success.xhtml</url-pattern>
            <!-- 
            POTRZEBA WYKLUCZENIA "new_user.xhtml" - TYLKO "admin"
            MOŻE TWORZYĆ PO ZALOGOWANIU NOWYCH UŻYTKOWNIKÓW
            
            ROZWIĄZANIE NA SKRÓTY: UKRYCIE WIDOKÓW
            -->
        </web-resource-collection>
        <auth-constraint>
            <description>Users Pages</description>
            <role-name>user_role</role-name>
        </auth-constraint>
    </security-constraint>
    <security-constraint>
        <display-name>Management System - Admin</display-name>
        <web-resource-collection>
            <web-resource-name>Administrator Realm</web-resource-name>
            <description/>
            <url-pattern>/faces/user/login_success.xhtml</url-pattern>
            <url-pattern>/faces/admin/*</url-pattern>
            <url-pattern>/faces/user/*</url-pattern>
            <http-method>GET</http-method>
            <http-method>POST</http-method>
        </web-resource-collection>
        <auth-constraint>
            <description>Admin Pages</description>
            <role-name>admin_role</role-name>
        </auth-constraint>
    </security-constraint>
    <security-constraint>
        <!-- BRAK AUTOMATYCZNEGO PRZEKIEROWANIA NA STRONĘ Z INFORMACJĄ -->
        <display-name>Display - Inactive</display-name>
        <web-resource-collection>
            <web-resource-name>Inactive Realm</web-resource-name>
            <description/>
            <url-pattern>/faces/inactive_account.xhtml</url-pattern>
            <url-pattern>/faces/user/login_success.xhtml</url-pattern>
            <http-method>GET</http-method>
            <http-method>POST</http-method>
        </web-resource-collection>
        <auth-constraint>
            <description>Inactive Pages</description>
            <role-name>inactive_role</role-name>
        </auth-constraint>
    </security-constraint>
    <login-config>
        <auth-method>FORM</auth-method>
        <realm-name>SecurityRealm</realm-name>
        <form-login-config>
            <form-login-page>/faces/sign_in.xhtml</form-login-page>
            <form-error-page>/faces/sign_err.xhtml</form-error-page>
        </form-login-config>
    </login-config>
    <security-role>
        <description/>
        <role-name>admin_role</role-name>
    </security-role>
    <security-role>
        <description/>
        <role-name>user_role</role-name>
    </security-role>
    <security-role>
        <description/>
        <role-name>inactive_role</role-name>
    </security-role>
    <error-page>
        <error-code>403</error-code>
        <location>/faces/error/403.xhtml</location>
    </error-page>
    <error-page>
        <error-code>404</error-code>
        <location>/faces/error/404.xhtml</location>
    </error-page>
    <error-page>
        <error-code>500</error-code>
        <location>/faces/error/500.xhtml</location>
    </error-page>
    <error-page>
        <exception-type>javax.persistence.OptimisticLockException</exception-type>
        <location>/faces/error/OptimisticLockException.xhtml</location>
    </error-page>
</web-app>

glassfish.web

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
  <security-role-mapping>
    <role-name>admin_role</role-name>
    <group-name>admin_role</group-name>
  </security-role-mapping>
  <security-role-mapping>
    <role-name>inactive_role</role-name>
    <group-name>inactive_role</group-name>
  </security-role-mapping>
  <security-role-mapping>
    <role-name>user_role</role-name>
    <group-name>user_role</group-name>
  </security-role-mapping>
  <class-loader delegate="true"/>
  <jsp-config>
    <property name="keepgenerated" value="true">
      <description>Keep a copy of the generated servlet class' java code.</description>
    </property>
  </jsp-config>
</glassfish-web-app>

glassfish.xml

?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
  <jdbc-resource enabled="true" jndi-name="jdbc/system" object-type="user" pool-name="Pool-System">
    <description/>
  </jdbc-resource>
  <jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="Pool-System" non-transactional-connections="false" ping="false" pool-resize-quantity="2" pooling="true" res-type="javax.sql.DataSource" statement-cache-size="0" statement-leak-reclaim="false" statement-leak-timeout-in-seconds="0" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
    <property name="URL" value="jdbc:mysql://localhost:3306/system"/>
    <property name="serverName" value="localhost"/>
    <property name="PortNumber" value="1527"/>
    <property name="DatabaseName" value="system"/>
    <property name="User" value="root"/>
    <property name="Password" value="admin"/>
  </jdbc-connection-pool>
</resources>

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="System.PU" transaction-type="JTA">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>jdbc/system</jta-data-source>
    <class>app.model.entity.Education</class>
    <class>app.model.entity.HistoryWork</class>
    <class>app.model.entity.Qualifications</class>
    <class>app.model.entity.Trainings</class>
    <class>app.model.entity.Users</class>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <shared-cache-mode>NONE</shared-cache-mode>
    <validation-mode>NONE</validation-mode>
    <properties>
      <property name="eclipselink.logging.level" value="INFO"/>
      <property name="eclipselink.canonicalmodel.subpackage" value="System.PU"/>
    </properties>
  </persistence-unit>
</persistence>

faces-config

<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.2"
              xmlns="http://xmlns.jcp.org/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    
    <application>
        <locale-config>
            <default-locale>pl</default-locale>
            <supported-locale>pl</supported-locale>
            <supported-locale>en</supported-locale>
        </locale-config>
        <resource-bundle>
            <base-name>i18n.messages</base-name>
            <var>msg</var>
        </resource-bundle>
        <message-bundle>
            i18n.jsf_messages
        </message-bundle>
    </application>
          
    <navigation-rule>
        <from-view-id>/*</from-view-id>
        <!-- guest (osoba bez roli) -->
        <navigation-case>              
            <redirect />
            <from-outcome>main</from-outcome>
            <to-view-id>index.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>              
            <redirect />
            <from-outcome>addUser</from-outcome>
            <to-view-id>new_user.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>              
            <redirect />
            <from-outcome>errorPage</from-outcome>
            <to-view-id>error_page.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>              
            <redirect />
            <from-outcome>confirmPanel</from-outcome>
            <to-view-id>confirm.xhtml</to-view-id>
        </navigation-case>
        
        <!-- user --> 
        <navigation-case>              
            <redirect />
            <from-outcome>DataUserList</from-outcome>
            <to-view-id>user/data_user_list.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>              
            <redirect />
            <from-outcome>editAuthData</from-outcome>
            <to-view-id>/user/edit_auth_data.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>              
            <redirect />
            <from-outcome>account</from-outcome>
            <to-view-id>/user/account.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>              
            <redirect />
            <from-outcome>editAccount</from-outcome>
            <to-view-id>/user/edit_account.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>              
            <redirect />
            <from-outcome>editEducation</from-outcome>
            <to-view-id>/user/edit_education.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>              
            <redirect />
            <from-outcome>editQualifications</from-outcome>
            <to-view-id>/user/edit_qualifications.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>              
            <redirect />
            <from-outcome>editHistoryWork</from-outcome>
            <to-view-id>/user/edit_history_work.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>              
            <redirect />
            <from-outcome>editTrainings</from-outcome>
            <to-view-id>/user/edit_trainings.xhtml</to-view-id>
        </navigation-case>
        
        <navigation-case>              
            <redirect />
            <from-outcome>advanceSearch</from-outcome>
            <to-view-id>/user/advance_search.xhtml</to-view-id>
        </navigation-case>
        
        <!-- admin -->
        <navigation-case>             
            <redirect />
            <from-outcome>list</from-outcome>
            <to-view-id>/admin/list.xhtml</to-view-id>
        </navigation-case>       
        <navigation-case>              
            <redirect />
            <from-outcome>editUser</from-outcome>
            <to-view-id>/admin/edit_user.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>              
            <redirect />
            <from-outcome>roleManager</from-outcome>
            <to-view-id>/admin/user_manager.xhtml</to-view-id>
        </navigation-case>
        <navigation-case>              
            <redirect />
            <from-outcome>list</from-outcome>
            <to-view-id>/admin/list.xhtml</to-view-id>
        </navigation-case>
        <!-- inactive (użytkownik z rolą nieaktywny) -->
        <navigation-case>
            <redirect />
            <from-outcome>inactive</from-outcome>
            <to-view-id>inactive_account.xhtml</to-view-id>
        </navigation-case>
        
    </navigation-rule>
    
</faces-config>

0

Logi z serwera.

0

Dobra znalazłem dziada:
#{of:formatDate(users.activationDate, 'dd.MM.yyyy')}

problem z OmniFace - zależność, którą wywaliłem.

Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean (default-clean) on project System: Failed to clean project: Failed to delete C:\Users\Kamil\Documents\NetBeansProjects\System\target\System-1.0\WEB-INF\lib\omnifaces-2.6.4.jar -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:

To było do dat, jak usuwam daty wszystko jest okej ale przecież nie chce usuwać daty...

0

Dobra ogarnąłem OmniFaces mi mieszał, bo instrukcji nie doczytałem, że wystarczy tylko dodać w POM.xml zależność.

Zarejestruj się i dołącz do największej społeczności programistów w Polsce.

Otrzymaj wsparcie, dziel się wiedzą i rozwijaj swoje umiejętności z najlepszymi.