I have a rest web service, that retrives data from my sql database using hibernate technology. While running, the web sevice throws error below
java.lang.NoClassDefFoundError: Could not initialize class com.sample.restlet.HibernateSessionFactory
com.sample.restlet.EmployeeResource.(EmployeeResource.java:22)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
java.lang.Class.newInstance0(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
com.sun.jersey.server.spi.component.ResourceComponentConstructor._construct(ResourceComponentConstructor.java:158)
com.sun.jersey.server.spi.component.ResourceComponentConstructor.construct(ResourceComponentConstructor.java:148)
com.sun.jersey.server.impl.resource.PerRequestFactory$PerRequest._getInstance(PerRequestFactory.java:175)
com.sun.jersey.server.impl.resource.PerRequestFactory$AbstractPerRequest.getInstance(PerRequestFactory.java:132)
com.sun.jersey.server.impl.application.WebApplicationContext.getResource(WebApplicationContext.java:160)
com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:64)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:63)
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:543)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:502)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:493)
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:308)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:314)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:239)
I dont get why this problem is coming. Please help.
A java.lang.NoClassDefFoundError: Could not initialize class XXX means that the class is found, but its initialization failed. Possible cause include:
missing dependent classes.
an exception thrown during execution of a static initialization block in the class.
Don't you get more info in the server logs? Any Caused by?
Providing the code of com.sample.restlet.HibernateSessionFactory might help too?
Related
i'm trying to use a cxf web service. i have a java sample in intelliJ and when i run it, every thing is ok. but when i try to invoke web service in a java web project(Struts2 and spring framework) i got this exception. every thing is same in both code. and both are running in same client.
Can any body tell me what went wrong ?
org.apache.cxf.interceptor.Fault: Could not send Message.
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
.
.
.
`Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: http://servicebus......
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
`.
.
.
.
.
Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: http://servicebus......
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2081)
... 111 more
code i used is below:
CustomsDebtService customsDebtService = new CustomsDebtService();
CustomsDebt debtWebService = customsDebtService.getCustomsDebtPort();
java.util.Map<String, Object> ctx = ((BindingProvider) debtWebServicePort).getRequestContext();
ctx.put("ws-security.signature.properties", "keystore.properties");
ctx.put("ws-security.encryption.properties", "truststore.properties");
ctx.put("ws-security.encryption.username", "servicebus.ecogif.XX");
ctx.put("ws-security.asymmetric.signature.algorithm", "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
ctx.put("ws-security.callback-handler", "externalWebService.XXX.newDebts.CertificatePasswordCallbackHandler");
PersonDebtInquiryResult personDebtInquiryResult;
if (Empty.isNotEmpty(iricaDebtsInquiry.getNationalCode()))
{
personDebtInquiryResult=debtWebService.personDebtInquiryByNationalID("000000001");
}
exception occurs in last line.
all addresses are correct.
also there is some .jks file for config that i put them in ctx (in code). what is the correct path of this file so that can be understand by code. is it possible that problem occurs because of wrong path?
I know this error has been posted before but I can't understand the stack trace and would love somebodies help.
Basically when I enter the application the getValue("client") is null:
HttpSession validuser = request.getSession();
if (validuser.getValue("client") == null) {
response.sendRedirect("/profile/factfind/includes/session_timeout.jsp");
}
And I'm thinking it's something to do with the following error:
2013-01-09 13:14:35 NamingContextListener[/Tomcat-Standalone/localhost/profile]: Creating JNDI naming context
2013-01-09 13:14:35 StandardManager[/profile]: Seeding random number generator class java.security.SecureRandom
2013-01-09 13:14:35 StandardManager[/profile]: Seeding of random number generator has been completed
2013-01-09 13:14:35 StandardContext[/profile]: Posting standard context attributes
2013-01-09 13:14:35 StandardContext[/profile]: Configuring application event listeners
2013-01-09 13:14:35 StandardContext[/profile]: Sending application start events
2013-01-09 13:14:35 StandardContext[/profile]: Starting filters
2013-01-09 13:14:35 StandardContext[/profile]: Starting completed
2013-01-09 13:14:37 StandardContext[/profile]: Servlet /profile threw load() exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: -1 in the jsp file: null
Generated servlet error:
[javac] Compiling 1 source file
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:248)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:343)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:427)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:142)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:720)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:888)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:768)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3484)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3710)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:777)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:760)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:538)
at org.apache.catalina.core.StandardHostDeployer.addChild(StandardHostDeployer.java:667)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:216)
at org.apache.commons.digester.SetNextRule.end(SetNextRule.java:217)
at org.apache.commons.digester.Rule.end(Rule.java:253)
at org.apache.commons.digester.Digester.endElement(Digester.java:1222)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.commons.digester.Digester.parse(Digester.java:1765)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:343)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:762)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:443)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:377)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:808)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:335)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1156)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:697)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1148)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:311)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2213)
at org.apache.catalina.startup.Catalina.start(Catalina.java:484)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:371)
at org.apache.catalina.startup.Catalina.process(Catalina.java:134)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:151)
The session exists in a different application that then loads "profile" so I'm not too sure what happens when one launches the other.
Any help would be much appreciated. Thanks.
Turns out the fix for me was the same as some forums had suggested. I create a new Tomcat installation in a directory with no spaces (i.e C:\Tomcat4.1) and that worked.
Don't know why or how but it did.
I think that's a problem
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: -1 in the jsp file: null
Cleanup your project (or manually remove all .class files) then try to compile from scratch. If error gone - check it should work. If not - you should apparently get this first error gone.
It seems getValue(String) method is deprecated. so try the following code null == validuser.getAttribute(String)
I'm using in a Java project RMI + Hibernate and I'm experiencing problems related to NotUniqueException with the error "Different objects with the same identifier".
I've got several doubts:
I'm pretty surre that I don't copy nor create new objects with the same ide
ntifiers. Is it possible that RMI creates a new object from another one when I use it?
Which method is using Hibernate to know that two objects are the same? equals?
I know that Serializable is related to Hibernate but I don't know in what way?
How can I solve the "Differents objects error" using RMI at the same time?
Is it correct every time I use delete or save over an object use merge before?
The stack traces is:
org.orm.PersistentException: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [dcl.Administrador#10]
at org.orm.PersistentSession.saveOrUpdate(PersistentSession.java:648)
at org.orm.PersistentManager.saveObject(PersistentManager.java:274)
at dcl.AdministradorDAO.save(AdministradorDAO.java:240)
at dcl.BdAdministrador.guardarAdministrador(BdAdministrador.java:62)
at dcl.BdAdministrador.actualizarAdministrador(BdAdministrador.java:109)
at dcl.BdPrincipal.actualizarAdministrador(BdPrincipal.java:555)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Thanks in advance.
If you're doing something like returning a hibernate object from an RMI method, then passing it back into another one, then you'll potentially need to reattach the object to the session. (see What is the proper way to re-attach detached objects in Hibernate?).
Perhaps give some more info on what you're attempting if this doesn't help.
Bit of a specific one this..
I'm having trouble using the Openblox diameter stack when using Spring MVC, specifically the init method call on the transport stack:
import com.traffix.openblox.core.transport.TransportStack;
Stack stack = new TransportStack();
stack.init(configureStack());
I'm getting a null pointer exception on the call to init - note that the Configuration returned from configureStack() is valid and works on non-Spring MVC projects. Heres the stack trace:
2776 [pool-2-thread-1] WARN com.traffix.openblox.core.fsm.StateMachine - Idle failed to process <Initiate Transport Stack( Idle)
java.lang.NullPointerException
at com.traffix.openblox.core.utils.logging.StackLogger.init(Unknown Source)
at com.traffix.openblox.core.transport.Stack.g(Unknown Source)
at com.traffix.openblox.core.transport.TransportStack.g(Unknown Source)
at com.traffix.openblox.core.transport.u.N(Unknown Source)
at com.traffix.openblox.core.transport.c$a.processEvent(Unknown Source)
at com.traffix.openblox.core.fsm.StateMachine.a(Unknown Source)
at com.traffix.openblox.core.fsm.StateMachine.a(Unknown Source)
at com.traffix.openblox.core.transport.u.a(Unknown Source)
at com.traffix.openblox.core.transport.Stack.init(Unknown Source)
at com.rory.services.pcrf.simulator.PcrfSimulator.initialize(PcrfSimulator.java:131)
at com.rory.services.pcrf.simulator.PcrfSimulator.<init>(PcrfSimulator.java:113)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
There is some sort of conflict between Openblox and Tomcat. Workaround for now is by removing conf/logging.properties from the Tomcat directory.
I'm trying to replicate the java guestbook example on Quercus on AppEngine and I'm getting an error having to do with preparing the query:
$greetings = $datastore->prepare($query)->asIterable();
I'm not a java developer so I can't make sense of the error trace. How can I get the greeting items without triggering this error?
Here is the entire error page:
HTTP ERROR 500
Problem accessing /index.php. Reason:
INTERNAL_SERVER_ERROR
Caused by:
java.lang.NullPointerException at
com.google.appengine.api.datastore.dev.LocalDatastoreService.next(LocalDatastoreService.java:1089)
at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
java.lang.reflect.Method.invoke(Unknown Source) at
com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.callInternal(ApiProxyLocalImpl.java:498)
at
com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:452)
at
com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:430)
at java.util.concurrent.Executors$PrivilegedCallable$1.run(Unknown
Source) at java.security.AccessController.doPrivileged(Native Method)
at java.util.concurrent.Executors$PrivilegedCallable.call(Unknown
Source) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown
Source) at java.util.concurrent.FutureTask.run(Unknown Source) at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
If it's a null pointer exception then you are trying to access a method or property of a null object
First you need to check if $datastore is null, then if the return of the query is not null. Also you need to check if that error is on that particular line of code (maybe it fails somewhere else)
You can access the database at this link /_ah/admin. Maybe there is a corrupt entity in there