Has anyone had this problem where Nebeans cannot locate the hibernate.cfg.xml file no matter where it is placed or where it is configured configure it?
This is the error message:
org.hibernate.internal.util.config.ConfigurationException: Could not locate cfg.xml resource [/hibernateConfig.xml]
The hibernate.cfg.xml file is in the default package since the error persists if I use the resources folder.
Here is my configuration code:
Configuration config = new Configuration().configure( "/hibernateConfig.xml") .addAnnotatedClass(Client.class) .addAnnotatedClass(CarSpare.class); StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).build(); sessionFactory = config.buildSessionFactory(serviceRegistry);
For completeness I have included the pom.xml file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>vzap.com</groupId> <artifactId>Argility_Project</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <name>Argility_Project</name> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <failOnMissingWebXml>false</failOnMissingWebXml> <jakartaee>8.0</jakartaee> </properties> <dependencies> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>${jakartaee}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>5.6.0.Final</version> <!-- Use the latest version --> </dependency> <!-- [url]https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-server[/url] --> <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-server</artifactId> <version>9.4.51.v20230217</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>4.0.1</version> <!-- Use the appropriate version --> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> <compilerArguments> <endorseddirs>${endorsed.dir}</endorseddirs> </compilerArguments> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.3</version> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.6</version> <executions> <execution> <phase>validate</phase> <goals> <goal>copy</goal> </goals> <configuration> <outputDirectory>${endorsed.dir}</outputDirectory> <silent>true</silent> <artifactItems> <artifactItem> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>${jakartaee}</version> <type>jar</type> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin> <!-- <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.4.51.v20230217</version> <configuration> Configure Jetty options, e.g., contextPath, webAppSourceDirectory, etc. <contextPath>/your-web-app</contextPath> </configuration> </plugin>--> </plugins> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> <!-- ... other build configurations ... --> </build> </project>