Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mysql data not showing in JSF

 
Darius rib
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I'm trying to show mysql data in JSF using this example http://www.devmanuals.com/tutorials/java/jsf/database/viewdata.html . I figured out what <h:dataTable value="#{userBean.getUserList()}" var="u" border="1"> must be <h:dataTable value="#{userBean.userList}" var="u" border="1"> but getting error:

09:08:38,654 ERROR [stderr] (http--127.0.0.1-8080-1) at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:307)

09:08:38,654 ERROR [stderr] (http--127.0.0.1-8080-1) at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:101)

09:08:38,654 ERROR [stderr] (http--127.0.0.1-8080-1) at java.lang.Class.forName0(Native Method)

09:08:38,654 ERROR [stderr] (http--127.0.0.1-8080-1) at java.lang.Class.forName(Unknown Source)

09:08:38,654 ERROR [stderr] (http--127.0.0.1-8080-1) at com.dev.UserBean.getUserList(UserBean.java:27)

09:08:38,654 ERROR [stderr] (http--127.0.0.1-8080-1) at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)

09:08:38,654 ERROR [stderr] (http--127.0.0.1-8080-1) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

09:08:38,654 ERROR [stderr] (http--127.0.0.1-8080-1) at java.lang.reflect.Method.invoke(Unknown Source)

09:08:38,655 ERROR [stderr] (http--127.0.0.1-8080-1) at javax.el.BeanELResolver.getValue(BeanELResolver.java:302)

09:08:38,655 ERROR [stderr] (http--127.0.0.1-8080-1) at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)

09:08:38,655 ERROR [stderr] (http--127.0.0.1-8080-1) at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)

09:08:38,655 ERROR [stderr] (http--127.0.0.1-8080-1) at org.apache.el.parser.AstValue.getValue(AstValue.java:134)

09:08:38,656 ERROR [stderr] (http--127.0.0.1-8080-1) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:187)

09:08:38,656 ERROR [stderr] (http--127.0.0.1-8080-1) at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)

09:08:38,656 ERROR [stderr] (http--127.0.0.1-8080-1) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:193)

09:08:38,656 ERROR [stderr] (http--127.0.0.1-8080-1) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:181)

09:08:38,656 ERROR [stderr] (http--127.0.0.1-8080-1) at javax.faces.component.UIData.getValue(UIData.java:557)

09:08:38,656 ERROR [stderr] (http--127.0.0.1-8080-1) at javax.faces.component.UIData.getDataModel(UIData.java:1297)

09:08:38,656 ERROR [stderr] (http--127.0.0.1-8080-1) at javax.faces.component.UIData.setRowIndex(UIData.java:450)

09:08:38,656 ERROR [stderr] (http--127.0.0.1-8080-1) at com.sun.faces.renderkit.html_basic.TableRenderer.encodeEnd(TableRenderer.java:191)

09:08:38,656 ERROR [stderr] (http--127.0.0.1-8080-1) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:883)

Please help
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18014
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Darius!

I recommend that you forget that you ever saw that website or anything in it. It's all wrong, and not just the parts you've already discovered.

There should have been a secondary stacktrace I think telling more what's wrong, plus the actual Exception line is missing. Although based on the sample code, I'd say that the database driver wasn't in the classpath.

J2EE is an expensive platform in terms of the amount of effort it takes to develop a webapp. So one of the things you would normally do is use a database connection pool instead of grabbing a driver directly. BTW, Class.forName() for drivers hasn't been necessary for quite a few years now, since modern JDBC drivers contain the necessary meta-data already.

A connection pool allows 2 benefits.

1. It allows multiple users access to the database without having to have each use open a new connection. Creating connections is a lot of work, but re-using pooled connections is not.

2. It allows you to abstract yourself more from the database, since the database connections are defined to the webapp server instead of to the webapp itself. While SQL isn't quite portable enough that you can swap MySQL for MS SQL Server without risk, it does make it a lot easier.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic