2

So, my first example using Wildfly 9.0.2 and I have deployed one webapp with the settings:

context: app-estoque-ws-server-wildfly

src/main/resources/META-INF
-> import.sql
-> persistence.xml

WebContent/WEB-INF
-> knight-estoque-ds.xml

persistence.xml:

<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="        http://java.sun.com/xml/ns/persistence         http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
     <persistence-unit name="primario">
          <jta-data-source>java:jboss/datasources/KnightDS</jta-data-source>
          <properties>
               <property name="hibernate.hbm2ddl.auto" value="create-drop" />
               <property name="hibernate.show_sql" value="true" />
          </properties>
     </persistence-unit>
</persistence>

knight-estoque-ds.xml:

<datasources xmlns="http://www.jboss.org/ironjacamar/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
     <datasource jndi-name="java:jboss/datasources/KnightDS"
      pool-name="knight-datasource" enabled="true"
      use-java-context="true">
          <connection-url>jdbc:h2:file:knight-estoque;DB_CLOSE_ON_EXIT=FALSE</connection-url>
          <driver>h2</driver>
          <security>
               <user-name>sa</user-name>
               <password>sa</password>
          </security>
     </datasource>
</datasources>

This is what I get on startup log:

21:52:31,043 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) WFLYJCA0001: Bound data source [java:jboss/datasources/KnightDS]

But how can I accomplish:

1- Accessing H2 knight-estoque on H2 web console, I can't see the any created or previously imported tables.

enter image description here

2- Also, I can't see in the Wildfly log the execution of import.sql that was previously added on META-INF folder.

3- And finally, how to locate the knight-estoque DS on Wildfly web console? Tried the following paths and didn't find the DS setup:

[RUNTIME] -> Standalone Server -> Subsystems -> Datasources (only shows ExampleDS)

[CONFIGURATION] -> Subsystems -> Datasources -> Non-XA -> (only shows ExampleDS)

[CONFIGURATION] -> Subsystems -> Datasources -> XA -> nothing here

The knight-estoque DS setup only shows on the structure bellow:

enter image description here

What I'm missing? I just want to execute the import.sql on DS so I can start using the application and also navigate through tables using H2 web console.

Thanks.

aelkz
  • 1,786
  • 1
  • 24
  • 26

1 Answers1

2

The import.sql file needs to be up one level in the src/main/resources/ directory not the META-INF directory.

James R. Perkins
  • 16,800
  • 44
  • 60
  • That's right! I can execute de import.sql statements, but I cannot access the database or view the previously created tables after the application is deployed. I'm using the configuration bellow: `jdbc:h2:file:knight-estoque;INIT=RUNSCRIPT FROM 'classpath:import.sql';DB_CLOSE_ON_EXIT=FALSE; ` – aelkz Nov 19 '15 at 12:31
  • 1
    Like Thomas Mueller says above it's likely because you're using a relative path. Since you define both files as `knight-estoque` then it's possible the file is created in different locations. If you want to use file based storage it's better to use an absolute path or something like `jdbc:h2:file:~/knight-estoque`. – James R. Perkins Nov 19 '15 at 17:15