Vue combinée Vue Plate Arborescence
Sujets [ Précédent | Suivant ]
toggle
Jan Frese
Portlet only works on 1/2 servers
29 janvier 2014 23:24
Réponse

Jan Frese

Rang: New Member

Publications: 12

Date d'inscription: 29 janvier 2014

Publications Récentes

Hello everyone,
I've got a problem. I have developed a portlet wich collects data from a MySQL database and puts it into a primefaces dataTable.
On my local test-liferay (V 6.2) it works quite fine. But on my live-vm-liferay (also V 6.2) it does only print the datatable and no content in it.
For me it looks like liferay doesn't load the bean or something.

Here's the source-code:

view.xhtml:
 1<?xml version="1.0" encoding="UTF-8"?>
 2<f:view 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.org/ui" xmlns:pt="http://xmlns.jcp.org/jsf/passthrough">
 3    <h:head>
 4
 5    </h:head>
 6
 7    <h:body>
 8        <!-- Here liferay should print the bean-instance-->
 9        <p:outputLabel value="${projektBeanNew}"/>
10
11        <h:form id="dForm">
12            <p:dataTable id="dTable" var="projekt" value="#{projektBeanNew.projekte}" sortMode="multiple" rows="25" paginator="true">
13
14                <f:facet name="header"> 
15                    Alle Projekte
16                </f:facet> 
17
18                <p:column sortBy="name" headerText="Name">
19                    <h:outputText value="#{projekt.name}" /> 
20                </p:column> 
21
22                <p:column sortBy="key" headerText="Key"> 
23                    <h:outputText value="#{projekt.key}" /> 
24                </p:column>
25               
26                <p:column sortBy="beschreibung" headerText="Beschreibung"> 
27                    <h:outputText value="#{projekt.beschreibung}" /> 
28                </p:column>
29               
30                <p:column sortBy="projektleiter" headerText="Projektleiter"> 
31                    <h:outputText value="#{projekt.projektleiter}" /> 
32                </p:column>
33
34            </p:dataTable>
35        </h:form>
36    </h:body>
37
38</f:view>


Bean:
 1@ViewScoped
 2@Named("projektBeanNew")
 3public class ProjekteBeanNew {
 4
 5    @Inject
 6    private Logger logger;
 7   
 8    private List<Projekt> projekte;
 9   
10    public ProjekteBeanNew(){
11        init();
12    }
13   
14    @PostConstruct
15    private void init() {
16        System.out.println("Test");
17        projekte = new ArrayList<Projekt>();
18        String url = "jdbc:mysql://pmp2-vm/";
19        String dbName = "pmp2";
20        String driver = "com.mysql.jdbc.Driver";
21        String userName = "AlleProjekte";
22        String password = "AlleProjekte";
23        try {
24            System.out.println("test1");
25            Class.forName(driver).newInstance();
26            System.out.println("test2");
27            Connection conn = DriverManager.getConnection(url + dbName, userName, password);
28            System.out.println("test3");
29            Statement st = conn.createStatement();
30            ResultSet res = st.executeQuery("SELECT `Key`, `Name`, Beschreibung, JiraPersonen.`Nachname` FROM  JiraProjekte JOIN JiraPersonen ON Projektleiter=JiraPersonen.Email");
31            while (res.next()) {            
32                Projekt temp = new Projekt();
33                temp.setKey(res.getString("Key"));
34                temp.setName(res.getString("Name"));
35                temp.addBeschreibung(res.getString("Beschreibung"));
36                temp.addProjektleiter(new Person(res.getString("Nachname")));
37                projekte.add(temp);
38            }
39            res.close();
40            conn.close();
41        } catch (Exception e) {
42            e.printStackTrace();
43        }
44    }
45   
46    public List<Projekt> getProjekte(){
47        return projekte;
48    }
49
50}


Greetings
Jan
Juan Gonzalez
RE: Portlet only works on 1/2 servers
29 janvier 2014 23:25
Réponse

Juan Gonzalez

LIFERAY STAFF

Rang: Liferay Legend

Publications: 2798

Date d'inscription: 28 octobre 2008

Publications Récentes

Hi Jan,

do you see any error in your server log?

what app server are you using in your live-vm environment?
Jan Frese
RE: Portlet only works on 1/2 servers
29 janvier 2014 23:29
Réponse

Jan Frese

Rang: New Member

Publications: 12

Date d'inscription: 29 janvier 2014

Publications Récentes

Hi Juan,
no, there are no errors in catalina.out or on the website itself.
And for the AppServer, I use the same as on my lokal liferay.
Juan Gonzalez
RE: Portlet only works on 1/2 servers
29 janvier 2014 23:36
Réponse

Juan Gonzalez

LIFERAY STAFF

Rang: Liferay Legend

Publications: 2798

Date d'inscription: 28 octobre 2008

Publications Récentes

Is the hostname pmp2-vm pointing to the same host in both your local and live-vm environments?

Seems like an environment misconfiguration, not Liferay Faces problem...
Jan Frese
RE: Portlet only works on 1/2 servers
29 janvier 2014 23:42
Réponse

Jan Frese

Rang: New Member

Publications: 12

Date d'inscription: 29 janvier 2014

Publications Récentes

Yes, pmp2-vm is the hostname of the db...
So I guessed it needs to be the same, because the portlet uses the same db on both plattforms.
Kyle Joseph Stiemann
RE: Portlet only works on 1/2 servers
30 janvier 2014 06:53
Réponse

Kyle Joseph Stiemann

LIFERAY STAFF

Rang: Expert

Publications: 437

Date d'inscription: 14 janvier 2013

Publications Récentes

Hi Jan,
I see two problems with your code:

  1. If you are using JSF 2.1, you should not be using @Named and @ViewScoped together. @Named is a CDI annotation and @ViewScoped is a JSF annotation, so neither jar will know what to do with this class. Use @ManagedBean(name="projektBeanNew") with @ViewScoped, and remove @Named from this class.
  2. You are calling your @PostConstruct annotated method in your constructor. Because @PostConstruct annotated methods are only supposed to be called after the bean has been constructed, you should never call @PostConstruct methods in the constructor (in general, you should probably not need to call a @PostConstruct method manually at all). Once you work out the JSF/CDI problem mentioned above, you should be able to remove your constructor completely because your @PostConstruct method will be called automatically after construction.

- Kyle
Jan Frese
RE: Portlet only works on 1/2 servers
31 janvier 2014 04:34
Réponse

Jan Frese

Rang: New Member

Publications: 12

Date d'inscription: 29 janvier 2014

Publications Récentes

Hi Kyle,
that did the trick. Thank you!

Jan
Kyle Joseph Stiemann
RE: Portlet only works on 1/2 servers
31 janvier 2014 06:12
Réponse

Kyle Joseph Stiemann

LIFERAY STAFF

Rang: Expert

Publications: 437

Date d'inscription: 14 janvier 2013

Publications Récentes

Great! Thanks for using Liferay Faces!

- Kyle