java.lang.ClassNotFoundException: org.hibernate.HibernateException while making object in servlet - servlets

I am trying to make an object of service class in Servlet, if I not create any object and just print form request detains it works fine, but when I am making any object of other class it shows some error please help how can i resolve it. from jsp to servlet it works fine, but it shows exeption when creating an object.
[

Related

How can I return a custom reponse for a bean validation error under Open Liberty?

We are using beanValidation-2.0 and cdi-2.0 under Open Liberty 20.0.0.3. This works fine in that Open Liberty returns a 400 Bad Request response containing the bean validation error message when a a bean validation error is detected. I would like to update our application to instead return a custom response when Open Liberty detects a bean validation error. Is there a way that I can somehow "intercept" the bean validation error (or the Open Liberty generated response) and return my own custom response?`
Usually when you get a validation error, a ConstraintViolationException is thrown and you should be able to catch that and create your own response.
If you're using JAX-RS, you might want to do this by creating and registering an ExceptionMapper to handle this type of exception and turn it into a response. There's an example here.
You might be able to do this with a custom MessageInterpolator.
It can be specified via the message-interpolator element of validation.xml.

Mount/Use controller in console

In a Silex console command I want to perform a sub-request on a controller route. Unfortunately routes don't seem to be imported when executing a command by default.
I always get the following error:
Unable to generate a URL for the named route "xyz_subject_method" as
such route does not exist
Therefore I tried to mount the defining controller from within my Console class by using $this->mount('/prefix', Controller::mount($this)) inside the Console constructor. This has no effect.
Is there any way to access controllers directly from a console command?
After mounting a controller inside the Console constructor you need to flush the controller collection by using $this->flush();
So mounting the controller should look like this:
$this->mount('/prefix', Controller::mount($this));
$this-flush();

Server was unable to process request. in web service method call

Through my project i am making an web service call by adding web reference.
In my project i am creating object like below
PortalService portalService=new PortalService();
if (portalService != null)
{
DataSet ds = portalService.getStateList(3);
}
Its going inside if loop after creating object. But when calling web service method its giving me exception like below
[SoapException: Server was unable to process request. ---> Object reference not set to an instance of an object.]
Why this exception occuring? How do i make web service call?
The code is ok. It looks like there is an exception happening inside the service itself. I would look at the service code, and try to track down the issue. Perhaps the input is not valid?

How to stop the entire java webapp when the servlet fails to initialize

I want my web application to fail on startup if any of my servlet fails to initialize.
I would expect if I throw an exception form the Servlet.init() method it would cause the entire app to fail, but apparently it doesn't. The web container (Tomcat 7 in my case) just fails to load that particular servlet, but the application is reported to be successfully deployed anyway.
It behaves as expected if an exception thrown from e.g. ServletContextListener.contextInitialized() method, but why the exception thrown from the Servlet.init() doesn't have this effect?
Is there any way to stop the application in case of a Servlet initialization error?
Try this following steps:
Keep your servlet in load-on-startup list such that your servlet
is initialized on application start.
In Servlet.init() method, set an attribute in ServletContext saying the servlet is initialzied. ex, myServletInited
Implement ServletContextListener.contextInitialzied() method. Check if myServletInited is present. If is does not present throw an exception which fails the application.

Error while calling webservice (Server was unable to process request. ---> PARAMETER_NAME)

I get this error while calling the web service hosted on the server.
The service has one web method with as string input and returns string (will be in XML format). The service is working fine but once in a while I get this error and can't predict. Can someone help me to get through this error.
Attached the screen shot of the error. Please let me know if you need additional info
I've never seen this error before, but I suggest you look at the event log on the server side. I suspect you are getting an unhandled exception on the client because you have one on the server.
Also, you should never return XML as a string. Use the XmlElement data type to return XML.

Resources