Forums de discussion
Portlet only works on 1/2 servers
Jan Frese, modifié il y a 10 années.
Portlet only works on 1/2 servers
New Member Publications: 12 Date d'inscription: 30/01/14 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:
Bean:
Greetings
Jan
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:
<!--?xml version="1.0" encoding="UTF-8"?-->
<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">
<h:head>
</h:head>
<h:body>
<!-- Here liferay should print the bean-instance-->
<p:outputlabel value="${projektBeanNew}" />
<h:form id="dForm">
<p:datatable id="dTable" var="projekt" value="#{projektBeanNew.projekte}" sortmode="multiple" rows="25" paginator="true">
<f:facet name="header">
Alle Projekte
</f:facet>
<p:column sortby="name" headertext="Name">
<h:outputtext value="#{projekt.name}" />
</p:column>
<p:column sortby="key" headertext="Key">
<h:outputtext value="#{projekt.key}" />
</p:column>
<p:column sortby="beschreibung" headertext="Beschreibung">
<h:outputtext value="#{projekt.beschreibung}" />
</p:column>
<p:column sortby="projektleiter" headertext="Projektleiter">
<h:outputtext value="#{projekt.projektleiter}" />
</p:column>
</p:datatable>
</h:form>
</h:body>
</f:view>
Bean:
@ViewScoped
@Named("projektBeanNew")
public class ProjekteBeanNew {
@Inject
private Logger logger;
private List<projekt> projekte;
public ProjekteBeanNew(){
init();
}
@PostConstruct
private void init() {
System.out.println("Test");
projekte = new ArrayList<projekt>();
String url = "jdbc:mysql://pmp2-vm/";
String dbName = "pmp2";
String driver = "com.mysql.jdbc.Driver";
String userName = "AlleProjekte";
String password = "AlleProjekte";
try {
System.out.println("test1");
Class.forName(driver).newInstance();
System.out.println("test2");
Connection conn = DriverManager.getConnection(url + dbName, userName, password);
System.out.println("test3");
Statement st = conn.createStatement();
ResultSet res = st.executeQuery("SELECT `Key`, `Name`, Beschreibung, JiraPersonen.`Nachname` FROM JiraProjekte JOIN JiraPersonen ON Projektleiter=JiraPersonen.Email");
while (res.next()) {
Projekt temp = new Projekt();
temp.setKey(res.getString("Key"));
temp.setName(res.getString("Name"));
temp.addBeschreibung(res.getString("Beschreibung"));
temp.addProjektleiter(new Person(res.getString("Nachname")));
projekte.add(temp);
}
res.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public List<projekt> getProjekte(){
return projekte;
}
}</projekt></projekt></projekt>
Greetings
Jan
Juan Gonzalez, modifié il y a 10 années.
RE: Portlet only works on 1/2 servers
Liferay Legend Publications: 3089 Date d'inscription: 28/10/08 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?
do you see any error in your server log?
what app server are you using in your live-vm environment?
Jan Frese, modifié il y a 10 années.
RE: Portlet only works on 1/2 servers
New Member Publications: 12 Date d'inscription: 30/01/14 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.
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, modifié il y a 10 années.
RE: Portlet only works on 1/2 servers
Liferay Legend Publications: 3089 Date d'inscription: 28/10/08 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...
Seems like an environment misconfiguration, not Liferay Faces problem...
Jan Frese, modifié il y a 10 années.
RE: Portlet only works on 1/2 servers
New Member Publications: 12 Date d'inscription: 30/01/14 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.
So I guessed it needs to be the same, because the portlet uses the same db on both plattforms.
Kyle Joseph Stiemann, modifié il y a 10 années.
RE: Portlet only works on 1/2 servers
Liferay Master Publications: 760 Date d'inscription: 14/01/13 Publications récentes
Hi Jan,
I see two problems with your code:
- Kyle
I see two problems with your code:
- 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.
- 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, modifié il y a 10 années.
RE: Portlet only works on 1/2 servers
New Member Publications: 12 Date d'inscription: 30/01/14 Publications récentes
Hi Kyle,
that did the trick. Thank you!
Jan
that did the trick. Thank you!
Jan
Kyle Joseph Stiemann, modifié il y a 10 années.
RE: Portlet only works on 1/2 servers
Liferay Master Publications: 760 Date d'inscription: 14/01/13 Publications récentes
Great! Thanks for using Liferay Faces!
- Kyle
- Kyle