0

I am using NetBeans to help me build a REST web service. My steps taken have been the following:

  • New Project -> Web Application
  • New File -> Web Service -> RESTFul WebService from Database
  • Select the Datasource (which is a MySQL DB)
  • Everything generates, right click on project -> Test RESTFul WebServices

When I want to test GET(application/XML), I can get a result returned fine, I can also get an XML response from a Jersey Client I made after the fact. But when I test the JSON functions, I always seem to get errors:

exception

javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.persistence.jaxb.BeanValidationHelper
root cause

org.glassfish.jersey.server.ContainerException: 
java.lang.NoClassDefFoundError: Could not initialize class 
org.eclipse.persistence.jaxb.BeanValidationHelper
root cause

java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.persistence.jaxb.BeanValidationHelper

My Database schema, which would really be the only thing I've written myself, is the following:

-- ****************** SqlDBM: MySQL ******************;
-- ***************************************************;

DROP TABLE `roles`;


DROP TABLE `orders`;


DROP TABLE `inventory`;


DROP TABLE `users`;


DROP TABLE `warehouses`;


DROP TABLE `inventory`;


DROP TABLE `addresses`;


DROP TABLE `products`;

-- ************************************** `addresses`

CREATE TABLE `addresses`
(
 `addressID`  INTEGER NOT NULL AUTO_INCREMENT ,
 `streetNum`  INTEGER NOT NULL ,
 `streetName` VARCHAR(45) NOT NULL ,
 `unitNum`    INTEGER ,
 `city`       VARCHAR(45) NOT NULL ,
 `province`   VARCHAR(45) NOT NULL ,
 `postalCode` VARCHAR(6) NOT NULL ,

PRIMARY KEY (`addressID`)
);

-- ************************************** `products`

CREATE TABLE `products`
(
 `productID`   INTEGER NOT NULL AUTO_INCREMENT ,
 `productNO`   VARCHAR(40) NOT NULL ,
 `productName` VARCHAR(80) NOT NULL ,
 `productDesc` VARCHAR(160) NOT NULL ,
 `cost`        REAL NOT NULL ,
 `price`       REAL NOT NULL ,

PRIMARY KEY (`productID`)
);

-- ************************************** `users`

CREATE TABLE `users`
(
 `userID`      INTEGER NOT NULL AUTO_INCREMENT ,
 `firstName`   VARCHAR(20) NOT NULL ,
 `lastName`    VARCHAR(20) NOT NULL ,
 `dateOfBirth` DATE NOT NULL ,
 `email`       VARCHAR(45) NOT NULL ,
 `password`    CHAR(64) NOT NULL ,
 `addressID`   INTEGER NOT NULL ,

PRIMARY KEY (`userID`),
KEY `fkIdx_87` (`addressID`),
CONSTRAINT `FK_87` FOREIGN KEY `fkIdx_87` (`addressID`) REFERENCES `addresses` (`addressID`)
);

-- ************************************** `warehouses`

CREATE TABLE `warehouses`
(
 `warehouseID` INTEGER NOT NULL AUTO_INCREMENT ,
 `addressID`   INTEGER NOT NULL ,

PRIMARY KEY (`warehouseID`),
KEY `fkIdx_58` (`addressID`),
CONSTRAINT `FK_58` FOREIGN KEY `fkIdx_58` (`addressID`) REFERENCES `addresses` (`addressID`)
);

-- ************************************** `inventory`

CREATE TABLE `inventory`
(
 `id`          INTEGER NOT NULL AUTO_INCREMENT ,
 `productID`   INTEGER NOT NULL ,
 `warehouseID` INTEGER NOT NULL ,
 `expiry`      DATE NOT NULL ,
 `productID_1` INTEGER NOT NULL ,

PRIMARY KEY (`id`),
KEY `fkIdx_31` (`productID_1`),
CONSTRAINT `FK_31` FOREIGN KEY `fkIdx_31` (`productID_1`) REFERENCES `products` (`productID`)
);

-- ************************************** `roles`

CREATE TABLE `roles`
(
 `roleID`   INTEGER NOT NULL AUTO_INCREMENT ,
 `roleName` VARCHAR(20) NOT NULL ,
 `userID`   INTEGER NOT NULL ,

PRIMARY KEY (`roleID`),
KEY `fkIdx_96` (`userID`),
CONSTRAINT `FK_96` FOREIGN KEY `fkIdx_96` (`userID`) REFERENCES `users` (`userID`)
);

-- ************************************** `orders`

CREATE TABLE `orders`
(
 `orderID`   INTEGER NOT NULL AUTO_INCREMENT ,
 `orderNum`  INTEGER NOT NULL ,
 `productID` INTEGER NOT NULL ,
 `quantity`  INTEGER NOT NULL ,
 `userID`    INTEGER NOT NULL ,

PRIMARY KEY (`orderID`),
KEY `fkIdx_70` (`productID`),
CONSTRAINT `FK_70` FOREIGN KEY `fkIdx_70` (`productID`) REFERENCES `products` (`productID`),
KEY `fkIdx_100` (`userID`),
CONSTRAINT `FK_100` FOREIGN KEY `fkIdx_100` (`userID`) REFERENCES `users` (`userID`)
);

-- ************************************** `inventory`

CREATE TABLE `inventory`
(
 `id`          INTEGER NOT NULL AUTO_INCREMENT ,
 `expiry`      DATE ,
 `productID`   INTEGER NOT NULL ,
 `warehouseID` INTEGER NOT NULL ,

PRIMARY KEY (`id`),
KEY `fkIdx_40` (`productID`),
CONSTRAINT `FK_40` FOREIGN KEY `fkIdx_40` (`productID`) REFERENCES `products` (`productID`),
KEY `fkIdx_62` (`warehouseID`),
CONSTRAINT `FK_62` FOREIGN KEY `fkIdx_62` (`warehouseID`) REFERENCES `warehouses` (`warehouseID`)
);
Dtroll MC
  • 303
  • 5
  • 14
  • Possible duplicate of [Could not initialize class org.eclipse.persistence.jaxb.BeanValidationHelper while trying to get JSON response](https://stackoverflow.com/questions/38743128/could-not-initialize-class-org-eclipse-persistence-jaxb-beanvalidationhelper-whi). See the two answers for workarounds. – skomisa May 18 '18 at 17:33
  • I've tried changing my server to Payara, and I get the same result. Not a duplicate. – Dtroll MC May 18 '18 at 18:14
  • OK. In that case please post the full stack trace when using Payara as well. – skomisa May 18 '18 at 18:22
  • The issue lied with my database schema. I had a StackOverFlow exception due to the foreign keys somehow when trying to parse the JSON – Dtroll MC May 18 '18 at 19:53

0 Answers0