sirthias / pegdown

A pure-Java Markdown processor based on a parboiled PEG parser supporting a number of extensions
http://pegdown.org
Apache License 2.0
1.29k stars 218 forks source link

Unable to run on Google AppEngine #4

Open ghost opened 13 years ago

ghost commented 13 years ago

This component cannot be used on GAE due to reflection restrictions (http://code.google.com/appengine/docs/java/runtime.html - see chapter Reflection).

Stack trace is below: Caused by: java.lang.SecurityException: java.lang.IllegalAccessException: Reflection is not allowed on protected final java.lang.Class java.lang.ClassLoader.findLoadedClass(java.lang.String) at com.google.appengine.runtime.Request.process-0cd4e3037a565acb(Request.java) at java.lang.reflect.Method.setAccessible(Method.java:134) at org.parboiled.transform.AsmUtils.findLoadedClass(AsmUtils.java:173)

sirthias commented 13 years ago

Yes, this is a known problem and hard to overcome with the Java version of the underlying parboiled parsing framework. One way around this is to reimplement the markdown parser using parboiled for Scala which does not require runtime class generation and loading and will therefore run play nicely with GAE. It's planned...

larsschwegmann commented 11 years ago

Got the same problem but not on AppEngine. I'm using Java Server Pages on a tomcat Server through Netbeans... I get this error:

WARNING: StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor at org.parboiled.Parboiled.createParser(Parboiled.java:54) at org.pegdown.PegDownProcessor.(PegDownProcessor.java:48) at org.pegdown.PegDownProcessor.(PegDownProcessor.java:39) at org.apache.jsp.kursUebersicht_jsp._jspService(kursUebersicht_jsp.java from :255) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111) at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378) at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:680) Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.ClassVisitor at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1518) at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1368) ... 35 more

sirthias commented 11 years ago

A ClassNotFoundException is not the same as an IllegalAccessException. Apparently you have no (or the wrong version of) ASM on the classpath.

larsschwegmann commented 11 years ago

what is an ASM? And how can I fix this? I added these libraries to my project: pegdown-1.1.0.jar, parboiled-core-1.1.1.jar, parboiled-java-1.1.1.jar, parboiled-scala_2.10-1.1.1.jar.

My code looks like this:

PegDownProcessor mdown = new PegDownProcessor();
mdown.mardownToHtml(aString);

And it always throws this exception. Any idea how to fix this?

sirthias commented 11 years ago

In order to use pegdown 1.1.0 you need to have the following libraries on your classpath:

All these are available from maven central.

larsschwegmann commented 11 years ago

Thanks! It works now :)

Von meinem iPhone gesendet

Am 04.10.2012 um 14:19 schrieb Mathias notifications@github.com:

In order to use pegdown 1.1.0 you need to have the following libraries on your classpath:

pegdown-1.1.0.jar parboiled-core-1.0.2.jar parboiled-java-1.0.2.jar asm-all-3.3.1.jar All these are available from maven central.

— Reply to this email directly or view it on GitHub.

svenjacobs commented 11 years ago

Is this still an issue? Because I'm using Pegdown 1.3.0 on GAE 1.7.7 succesfully. I have only tested it on a local GAE dev server so far but there should be no difference, right?

sirthias commented 11 years ago

Since I've little experience with GAE I don't know. Maybe the latest versions of GAE have relaxed the class-loading restrictions that earlier versions suffered from. pegdown (or rather the underlying parboiled-for-java) need to be able to load classes from generated bytecode at runtime. If that is allowed all is well.