MY ant build is stopped working with JNDI error, it was working perfectly couple of days ago. The log says that it there is no initial context exception.
Buildfile: C:\vseelsh_workspace\vseelsh_perforce_ws\pem_rd\NBDX\nbdx\build.xml
clean:
[delete] Deleting directory C:\vseelsh_workspace\vseelsh_perforce_ws\pem_rd\NBDX\nbdx\build
prepare:
[mkdir] Created dir: C:\vseelsh_workspace\vseelsh_perforce_ws\pem_rd\NBDX\nbdx\build
[mkdir] Created dir: C:\vseelsh_workspace\vseelsh_perforce_ws\pem_rd\NBDX\nbdx\build\classes
[mkdir] Created dir: C:\vseelsh_workspace\vseelsh_perforce_ws\pem_rd\NBDX\nbdx\build\dist
[mkdir] Created dir: C:\vseelsh_workspace\vseelsh_perforce_ws\pem_rd\NBDX\nbdx\build\report
compile:
[javac] C:\vseelsh_workspace\vseelsh_perforce_ws\pem_rd\NBDX\nbdx\build.xml:75: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 331 source files to C:\vseelsh_workspace\vseelsh_perforce_ws\pem_rd\NBDX\nbdx\build\classes
copyresources:
[copy] Copying 3 files to C:\vseelsh_workspace\vseelsh_perforce_ws\pem_rd\NBDX\nbdx\build\classes
test:
schemaexport:
[hibernatetool] Executing Hibernate Tool with a JPA Configuration
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool] log4j:WARN No appenders could be found for logger (org.jboss.logging).
[hibernatetool] log4j:WARN Please initialize the log4j system properly.
[hibernatetool] log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
[hibernatetool] SLF4J: Class path contains multiple SLF4J bindings.
[hibernatetool] SLF4J: Found binding in [jar:file:/C:/vseelsh_workspace/vseelsh_perforce_ws/pem_rd/NBDX/nbdx/lib/gwt/gwt-2.3.0/gwt-2.3.0/samples/DynaTableRf/war/WEB-INF/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
[hibernatetool] SLF4J: Found binding in [jar:file:/C:/Jboss/jboss-as-7.1.1.Final/modules/org/slf4j/impl/main/slf4j-jboss-logmanager-1.0.0.GA.jar!/org/slf4j/impl/StaticLoggerBinder.class]
[hibernatetool] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
[hibernatetool] An exception occurred while running exporter #2:hbm2ddl (Generates database schema)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.service.jndi.JndiException: Error parsing JNDI name [java:/nbdxDS]
[hibernatetool] javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
BUILD FAILED
The issue is resolved. Actually my project has two persistence.xml files where one of them is used by build.xml to export schema. In this file used by build.xml I should not use data source tag to refer JNDI (it is directly referring database credentials to connect to it). I have mistakenly copied contents from one persistence.xml file to another which has caused to have jta-datasource tag in it which I could not notice. It has forced build process to look for data source referred as JNDI in this file which is basically not possible because data source is not yet created and stored in JNDI by any other process. After removing this jta-datasource tag has resolved from this persistence tag has resolved the issue.