2

I am following the tutorial on Java EE7-hands on lab here. I followed the instructions as provided there to set up my WildFly Application server. Everything works fine. The tutorial zip comes with sample data and sql load scripts that is used to initialize the data-source. If no data-source is provided in persistence.xml, WildFly will provide a default data-source as mentioned in the tutorial.

At the end of step 3 in the tutorial link, here is how my screen-shot looks like:

enter image description here

But what is expected (as per tutorial link: Figure 12) is this:

enter image description here

The difference is "showing movies in theaters!" in my case to "showing 20 movies in 7 theaters!" in expected one. The JSF template used to display these numbers makes a EJB call that fetches data from the data-source. Looking at this, I think that my data-source is not initialized. But I don't why since I followed the tutorial word-by-word. I am also having hard trouble-shooting this.

Thanks for help in advance

EDIT

the server log shows Unable to determine H2 database version, certain features may not work.

2014-10-02 18:02:50,167 INFO  [org.hibernate.Version] (ServerService Thread Pool -- 50) HHH000412: Hibernate Core {4.3.5.Final}
2014-10-02 18:02:50,170 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 50) HHH000206: hibernate.properties not found
2014-10-02 18:02:50,172 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 50) HHH000021: Bytecode provider name : javassist
2014-10-02 18:02:50,330 INFO  [org.jboss.ws.common.management] (MSC service thread 1-6) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.2.4.Final
2014-10-02 18:02:50,491 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 50) JBAS011409: Starting Persistence Unit (phase 2 of 2) Service 'movieplex7.war#movieplex7PU'
2014-10-02 18:02:50,641 INFO  [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 50) HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
2014-10-02 18:02:50,875 INFO  [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 50) HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2014-10-02 18:02:50,883 WARN  [org.hibernate.dialect.H2Dialect] (ServerService Thread Pool -- 50) HHH000431: Unable to determine H2 database version, certain features may not work
2014-10-02 18:02:50,922 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ServerService Thread Pool -- 50) HHH000397: Using ASTQueryTranslatorFactory
2014-10-02 18:02:51,047 INFO  [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 50) HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2014-10-02 18:02:51,048 WARN  [org.hibernate.dialect.H2Dialect] (ServerService Thread Pool -- 50) HHH000431: Unable to determine H2 database version, certain features may not work
2014-10-02 18:02:51,055 WARN  [org.hibernate.jpa.internal.schemagen.GenerationTargetToDatabase] (ServerService Thread Pool -- 50) Unable to execute JPA schema generation drop command [DROP TABLE SALES]
2014-10-02 18:02:51,055 WARN  [org.hibernate.jpa.internal.schemagen.GenerationTargetToDatabase] (ServerService Thread Pool -- 50) Unable to execute JPA schema generation drop command [DROP TABLE POINTS]
2014-10-02 18:02:51,055 WARN  [org.hibernate.jpa.internal.schemagen.GenerationTargetToDatabase] (ServerService Thread Pool -- 50) Unable to execute JPA schema generation drop command [DROP TABLE SHOW_TIMING]
2014-10-02 18:02:51,055 WARN  [org.hibernate.jpa.internal.schemagen.GenerationTargetToDatabase] (ServerService Thread Pool -- 50) Unable to execute JPA schema generation drop command [DROP TABLE MOVIE]
2014-10-02 18:02:51,056 WARN  [org.hibernate.jpa.internal.schemagen.GenerationTargetToDatabase] (ServerService Thread Pool -- 50) Unable to execute JPA schema generation drop command [DROP TABLE TIMESLOT]
2014-10-02 18:02:51,056 WARN  [org.hibernate.jpa.internal.schemagen.GenerationTargetToDatabase] (ServerService Thread Pool -- 50) Unable to execute JPA schema generation drop command [DROP TABLE THEATER]
2014-10-02 18:02:51,250 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-8) Initializing Mojarra 2.2.6-jbossorg-4 20140501-1134 for context '/movieplex7'
2014-10-02 18:02:51,867 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) JBAS017534: Registered web context: /movieplex7
2014-10-02 18:02:51,905 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "movieplex7.war" (runtime-name : "movieplex7.war")
2014-10-02 18:02:51,910 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
2014-10-02 18:02:51,911 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
2014-10-02 18:02:51,911 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.1.0.Final "Kenny" started in 5525ms - Started 256 of 310 services (91 services are lazy, passive or on-demand)

I have also raised an issue in github repo here: https://github.com/javaee-samples/javaee7-hol/issues/17#issuecomment-57561731

brain storm
  • 30,124
  • 69
  • 225
  • 393
  • 1
    Assuming you're using Netbeans (as per the tutorial), open up the [output]. There should be a Wildfly Server tab that shows the server log. Do you see any exceptions? – Paul Samsotha Oct 02 '14 at 01:35
  • @peeskillet: I am using Eclipse. but I located the server log. please see edit above where I included server log – brain storm Oct 03 '14 at 18:30
  • So I got the app, and tried to run it (Netbeans, Wildfly-8.1). It didn't run at all. Problem with the data source not being found. So (with Wildfly started) I went to the admin console `localhost:9990` and typed in my credentials. In the console, Selected the [Configuration] tab, then [Datasources]. There is no `defaultDataSource`. There _was_ a `java:jboss/datasources/ExampleDS` as a preconfigured datasource. So in the `persistence.xml`, I changed the data source to that, and it worked. FYI, I ran the `movieplex7` from the `solution` dir from the download – Paul Samsotha Oct 03 '14 at 19:05
  • @peeskillet: Thanks for taking time to test this out. If you look at the github repo linked above, I have a snapshot showing that my defaultDataSource is configured. can you please paste the link that you used in persistence.xml? That will be very helpful.. – brain storm Oct 03 '14 at 19:19
  • This is the only thing I changed to the entire project. Just changed the jndi name for the data source to `java:jboss/datasources/ExampleDS` – Paul Samsotha Oct 03 '14 at 19:24
  • great!. worked like a charm. I was always doubting something wrong with datasource, but the tutorial did not say any configuration for datasources. I will issue this concern to them. if you want to post as an answer, I can accept it. Thanks – brain storm Oct 03 '14 at 19:28

2 Answers2

2

So I got the app, and tried to run it (Netbeans, Wildfly-8.1). It didn't run at all. Problem with the data source not being found. So (with Wildfly started) I went to the admin console localhost:9990 and typed in my credentials. In the console, Selected the [Configuration] tab, then [Datasources]. There is no defaultDataSource. There was a java:jboss/datasources/ExampleDS as a preconfigured datasource. So in the persistence.xml, I changed the data source to that, and it worked. FYI, I ran the movieplex7 from the solution dir from the download


This is the only thing I changed to the entire project. Just changed the jndi name for the data source to <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>


EDIT

So @ArunGupta is correct. In the application, in the persistence.xml There was this commented out line

<!--<jta-data-source>java:comp/DefaultDataSource</jta-data-source>-->

I assumed I would have to uncomment that. By uncommenting it, that's what caused it to initially not work. So I commented it back out, and without specifying any data souce i.e. java:jboss/datasources/ExampleDS, it works as specified. So your problem seems to be elsewhere.

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
  • I tried glassFish with this configuration `java:comp/DefaultDataSource`. suprisingly this does not work..same issue as I posted for WildFly. – brain storm Oct 03 '14 at 20:09
  • Take a look at my **EDIT**. So the application does work as expected. Your problem lies elsewhere. Please untick the check mark, until you find out what the problem is/was. Then you can answer your own question once/if you figure it out. – Paul Samsotha Oct 04 '14 at 05:09
  • why is that the first time you tried running, it did not run then? – brain storm Oct 04 '14 at 05:25
  • Becuase I uncommented the `java:comp/DefaultDataSource`. It seems the server couldn't find _that_ specific data source. I'm not sure if that's the default data source Arun is talking about or if there is an _implicit_ data source that is not visually displayed to us – Paul Samsotha Oct 04 '14 at 05:31
  • in your answer before,you mentioned you added `java:jboss/datasources/ExampleDS` which is the default dataSource for JBoss. Adding that to my persistance.xml worked on wildfly. `java:comp/DefaultDataSource` is the default Datasource of glassFish. – brain storm Oct 04 '14 at 05:34
  • Again I am not sure, I have never used this _default data source_ Arun is talking about. It appears the `ExampleDS` is _not_ the _"default data source"_ as I am still able to use it without specifying the `ExampleDS`. Or maybe it _is_ the default data source, that Wildfly goes to when we don't explicitly specify a data source. We can wait for an explanation from Arun, if he gets around to it – Paul Samsotha Oct 04 '14 at 05:37
  • Did you try to run it on glassfish, with no data source explicitly specified (i.e. commenting out the data source in the persistence.xml)? Or on Wildfly? – Paul Samsotha Oct 04 '14 at 05:38
  • I think it could be problems with Eclipse JBoss tools. because when I mvn package and deploy manually to WildFly, it works fine. (without DataSource tag in it...) – brain storm Oct 04 '14 at 05:56
0

Adding

<jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>

should not be required as Java EE 7 defines a new default data source that should be picked up automatically.

This issue is also being discussed at https://github.com/javaee-samples/javaee7-hol/issues/17.

Arun Gupta
  • 3,965
  • 5
  • 31
  • 39