I'm at my wit's end here - never seemed to have faced this problem. I find it relatively easy to set up quick HelloWorld applications to ensure Restlet 2.0 is up and running. However, I'm facing a strange exception which I've never encountered before. I have the jars in my classpath as well as the WEB-INF/lib folder but for some reason I keep getting the following exception:
INFO: Unable to register the helper org.restlet.ext.json.JsonConverter
java.lang.NoClassDefFoundError: org/json/JSONException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.newInstance0(Class.java:326)
at java.lang.Class.newInstance(Class.java:308)
at org.restlet.engine.Engine.registerHelper(Engine.java:718)
at org.restlet.engine.Engine.registerHelpers(Engine.java:753)
at org.restlet.engine.Engine.registerHelpers(Engine.java:793)
at org.restlet.engine.Engine.discoverConverters(Engine.java:501)
at org.restlet.engine.Engine.<init>(Engine.java:337)
at org.restlet.engine.Engine.register(Engine.java:248)
at org.restlet.engine.Engine.register(Engine.java:237)
at org.restlet.engine.Engine.getInstance(Engine.java:149)
at org.restlet.engine.Engine.getLogger(Engine.java:204)
at org.restlet.Context.<init>(Context.java:160)
at org.restlet.Context.<init>(Context.java:133)
at org.restlet.ext.servlet.ServerServlet.createComponent(ServerServlet.java:422)
at org.restlet.ext.servlet.ServerServlet.getComponent(ServerServlet.java:763)
at org.restlet.ext.servlet.ServerServlet.init(ServerServlet.java:881)
at javax.servlet.GenericServlet.init(GenericServlet.java:242)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1428)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:1060)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:187)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassNotFoundException: org.json.JSONException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at org.glassfish.web.loader.WebappClassLoader.findClass(WebappClassLoader.java:959)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1430)
... 45 more
The following jars are in my classpath and the WEB-INF/lib folders:
org.json.jar
org.restlet.jar
org.restlet.ext.servlet
org.restlet.ext.json
I'm building the project using Eclipse and deploying on Glassfish. The web.xml etc are all fine and no deployment errors...however, this one has had me scratching my head for a while.
Any ideas?
I had the same or a similar problem. I want to override the jackson representation and remove some dependencies it imports but when I do, the jackson converter is not discovered.
Then I've found why in my case: the jar contains a META-INF/services folder with a file called org.restlet.engine.converter.ConverterHelper. That's how discovery works.
I've tried to add that files to my path and it didn't work, don't know. So I ended up registering the Jackson converter
Engine.getInstance().getRegisteredConverters().add(new JacksonConverter());
For some reason the error went away when I swapped the file with that from the Restlet Distribution - in the org.json folder of the Restlet Java EE version.
Seems maybe something was missing in the org.json.jar that I had from the json website, don't know...
It looks like your application isn't able to find a library. If you're building your app in Eclipse, have you made sure that the libraries are being exported? Go to the Build Path section, and make sure the checkbox for exporting libraries is checked.
Related
I am facing the following issue whenever I try to implement the .aar file instead of the direct lib module dependency.
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugCompileClasspath'.
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find :xxxlib-release:.
N:B: I have configured the library project for jitpack also with the publishing config. A few days back, there was no issue but now I am getting errors for both the .aar and jitpack versions of my library which I guess is related. Additionally, I have upgraded to Android Studio Bumblebee and using targetSdkVersion 29 or 30; kotlin = 1.6.0 and classpath 'com.android.tools.build:gradle:7.0.3'
I can't find out what am I missing here. Any help will be appriciated, thanks.
I have written a RESTful service in java and want to produce json out of the get method. I was struggling with many no class def found error due to issues in jar versions or dependencies.
For example
Jackson error: java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/Versioned
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/JsonMappingException$Reference
I have created a dynamic web project in eclipse and added the jars in classpath and Maven is not used here.
Any idea on the list of dependent jars ??
I have finally found the jar versions and dependencies
I've been dealing with this problem for couple of days now and I can't get around to solve it. The working setup that I need is: two separate databases, one for JUnit testing and the other for the pure application access purposes.
I've been using MySQL for the the application part, since I need the full control and support and the other database that I am considering is Derby or H2 since the speed is essential here.
Okay, the MySQL database is working as it should, the JUnit tests are 100% success when I run them through
and there are no problems there. However, when I try to configure my project with the second database, the
problems arise. I've been searching for answers and I found the following setup when adding additional database to your spring-roo project:
Additional ApplicationContext that I've put in: src/test/resources/META-INF/spring/ and named as: applicationContextTest.xml
As well as additional ApplicationContextSecurity file that I've created in the same folder and named applicationContext-securityTest.xml
Necessary changes in pom.xml, persistence.xml and web.xml files
And also I've configured #ApplicationContext in JUnit test class to use appropriate files
Also separate database_test.properties located in the same folder as mentioned above
The exception that I am constantly getting is that the EntityManager has not been injected. I know this is a scarce information to work on, but I just want to get few opinions before, lets say, posting the whole code and the files that go along so that you people can see if I have made some silly mistakes(which at this point I am sure I haven't) or that I am missing some additional changes that need to be made.
The configuration I am using is: latest spring roo, maven and eclipse 4.2.2
Here is the stack trace that I get for the exception:
java.lang.IllegalStateException: Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)
at eu.execom.assessmenttool.domain.ExamFormulae_Roo_Jpa_ActiveRecord.entityManager_aroundBody0(ExamFormulae_Roo_Jpa_ActiveRecord.aj:19)
at eu.execom.assessmenttool.domain.ExamFormulae_Roo_Jpa_ActiveRecord.ajc$interMethod$eu_execom_assessmenttool_domain_ExamFormulae_Roo_Jpa_ActiveRecord$eu_execom_assessmenttool_domain_ExamFormulae$entityManager(ExamFormulae_Roo_Jpa_ActiveRecord.aj:1)
at eu.execom.assessmenttool.domain.ExamFormulae.entityManager(ExamFormulae.java:1)
at eu.execom.assessmenttool.domain.ExamFormulae_Roo_Jpa_ActiveRecord.ajc$interMethodDispatch1$eu_execom_assessmenttool_domain_ExamFormulae_Roo_Jpa_ActiveRecord$eu_execom_assessmenttool_domain_ExamFormulae$entityManager(ExamFormulae_Roo_Jpa_ActiveRecord.aj)
at eu.execom.assessmenttool.domain.ExamFormulae_Roo_Jpa_ActiveRecord.findAllExamFormulaes_aroundBody4(ExamFormulae_Roo_Jpa_ActiveRecord.aj:28)
at eu.execom.assessmenttool.domain.ExamFormulae_Roo_Jpa_ActiveRecord.ajc$interMethod$eu_execom_assessmenttool_domain_ExamFormulae_Roo_Jpa_ActiveRecord$eu_execom_assessmenttool_domain_ExamFormulae$findAllExamFormulaes(ExamFormulae_Roo_Jpa_ActiveRecord.aj:1)
at eu.execom.assessmenttool.domain.ExamFormulae.findAllExamFormulaes(ExamFormulae.java:1)
at eu.execom.assessmenttool.domain.ExamFormulae_Roo_Jpa_ActiveRecord.ajc$interMethodDispatch1$eu_execom_assessmenttool_domain_ExamFormulae_Roo_Jpa_ActiveRecord$eu_execom_assessmenttool_domain_ExamFormulae$findAllExamFormulaes(ExamFormulae_Roo_Jpa_ActiveRecord.aj)
at eu.execom.assessmenttool.web.GenerateExamControllerTest.generateExamQuestions(GenerateExamControllerTest.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
I have experienced this problem before.
I have written a blog article on how to achieve this setup:
www.solubris.com/blog/overriding_spring_context_for_testing
I had this problem when the environment in which I executed the roo project could not load AspectJ for some reason.
Specifically, it occurred to me when:
The pom.xml in eclipse give errors on the aspectj dependencies (M2E plugin execution not covered error). Solution was to do a quick fix on the error, ignore plugin goal, then set it as execute on preferences, as explained here http://wiki.eclipse.org/M2E_plugin_execution_not_covered.
I was running the Roo project on Jetty version 8. Solution was to switch to version 9.
It maybe not your case but I hope will help others!
I'm trying to use MessagePack in a WAR application in Glassfish, but I'm getting this exception (although JavaAssist already is a library of the project):
java.lang.NoClassDefFoundError: javassist/ClassPath at
org.msgpack.template.builder.BuilderSelectorRegistry.initForJava(BuilderSelectorRegistry.java:58)
at
org.msgpack.template.builder.BuilderSelectorRegistry.(BuilderSelectorRegistry.java:38)
at
org.msgpack.template.TemplateRegistry.(TemplateRegistry.java:38)
at org.msgpack.MessagePack.register(MessagePack.java:149)
this happern When I call
org.msgpack.MessagePack.register()
Any ideas?
I posted the error in the MessagePack's JIRA and this is the answer:
I added this libraries to my classpath:
javassist.jar msgpack-0.5.2-devel.jar slf4j-api-1.6.2.jar
slf4j-ext-1.6.2.jar slf4j-simple-1.6.2.jar
Copying them directly to the lib folder of glassfish, to: C:\Program
Files\glassfish-3.1\glassfish\domains\domain1\lib
I'm gonna work now in adding them as part of my war
Thank you very much again.
I have a groovy application running locally on my desktop.
Apparently it runs error free. At least all unit tests I wrote are fulfilled.
I want to deploy the application using a war file. For this I use the command
grails war
in the home directory of the application. When doing this I am getting the following exception:
Error executing script War: java.lang.NullPointerException
gant.TargetExecutionException: java.lang.NullPointerException
at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:331)
at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334)
at gant.Gant$_dispatch_closure6.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:344)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:334)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.processTargets(Gant.groovy:495)
at gant.Gant.processTargets(Gant.groovy:480)
Caused by: java.lang.NullPointerException
at _GrailsWar_groovy$_run_closure5_closure25_closure26_closure28.doCall(_GrailsWar_groovy:289)
at _GrailsWar_groovy$_run_closure5_closure25_closure26_closure28.doCall(_GrailsWar_groovy)
at _GrailsWar_groovy$_run_closure5_closure25_closure26.doCall(_GrailsWar_groovy:282)
at _GrailsWar_groovy$_run_closure5_closure25_closure26.doCall(_GrailsWar_groovy)
at _GrailsWar_groovy$_run_closure5_closure25.doCall(_GrailsWar_groovy:258)
at _GrailsWar_groovy$_run_closure5.doCall(_GrailsWar_groovy:256)
at _GrailsWar_groovy$_run_closure4.doCall(_GrailsWar_groovy:239)
at War$_run_closure1.doCall(War.groovy:38)
at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324)
... 10 more
Any hint why?
Thanks a lot in advance
I think you'll have to find the source of Gant.groovy and see what it's doing on that line. Apparently there is some problem caused by your project's specific configuration (since such a show-stopper bug would have been caught if it always occurred), but the error message does not contain much information.
Alternatively, you could try upgrading Grails to the latest version 1.1.1 if you haven't already.