[JCI] Complication Error

8 messages Options
Embed this post
Permalink
Ben Short

[JCI] Complication Error

Reply Threaded More More options
Print post
Permalink
Hi,

I'm trying to compile a JSP file and have looked at the examples but
can't get it to work.

My code:

JspGenerator jspGenerator = new JspGenerator();

                final byte[] jspSource =
jspGenerator.generateJavaSource("simple.jsp", new
File("target/test-classes/simple.jsp"));

                JavaCompiler compiler = new JavaCompilerFactory().createCompiler("eclipse");

                ResourceReader resourceReader = new ResourceReader() {
                        public byte[] getBytes(String s) {
                                return jspSource;
                        }

                        public boolean isAvailable(String s) {
                                return true;
                        }
                };

                ResourceStore store = new ResourceStore() {
                        public byte[] read(String s) {
                                System.out.println("");
                                return null;
                        }

                        public void remove(String s) {
                                System.out.println("");
                        }

                        public void write(String s, byte[] bytes) {
                                System.out.println("");
                        }
                };

                final CompilationResult result = compiler.compile(new
String[]{"simple.jsp"}, resourceReader, store);


                System.out.println( result.getErrors().length + " errors");
                System.out.println( result.getWarnings().length + " warnings");

simple.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head><title>Simple jsp page</title></head>
  <body>Place your content here</body>
</html>

And the error

The type java.lang.Object cannot be resolved. It is indirectly
referenced from required .class files

I had to add the following to the end of the JspReader

                        output.flush();

else

                        return outputStream.toByteArray();


Can anyone give me any pointers on how to proceed.

Regards

Ben Short

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Torsten Curdt

Re: [JCI] Complication Error

Reply Threaded More More options
Print post
Permalink
Do you fail to compile or fail to load the page created?
Looks like a class loading problem.

cheers
--
Torsten

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Ben Short

Re: [JCI] Complication Error

Reply Threaded More More options
Print post
Permalink
Hi Torsten,

The CompilationResult reports the problem on line 1747 of the following file

org.apache.commons.jci.compilers.EclipseCompilationProblem

Regards

Ben Short

2009/10/19 Torsten Curdt <[hidden email]>:

> Do you fail to compile or fail to load the page created?
> Looks like a class loading problem.
>
> cheers
> --
> Torsten
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Torsten Curdt-3

Re: [JCI] Complication Error

Reply Threaded More More options
Print post
Permalink
http://commons.apache.org/jci/xref/org/apache/commons/jci/compilers/EclipseCompilationProblem.html

I count only 79 lines :)

On Mon, Oct 19, 2009 at 19:09, Ben Short <[hidden email]> wrote:

> Hi Torsten,
>
> The CompilationResult reports the problem on line 1747 of the following file
>
> org.apache.commons.jci.compilers.EclipseCompilationProblem
>
> Regards
>
> Ben Short
>
> 2009/10/19 Torsten Curdt <[hidden email]>:
>> Do you fail to compile or fail to load the page created?
>> Looks like a class loading problem.
>>
>> cheers
>> --
>> Torsten
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Ben Short

Re: [JCI] Complication Error

Reply Threaded More More options
Print post
Permalink
lol sorry that's the object id isn't it.

Then I have no more information to give you at present.

2009/10/19 Torsten Curdt <[hidden email]>:

> http://commons.apache.org/jci/xref/org/apache/commons/jci/compilers/EclipseCompilationProblem.html
>
> I count only 79 lines :)
>
> On Mon, Oct 19, 2009 at 19:09, Ben Short <[hidden email]> wrote:
>> Hi Torsten,
>>
>> The CompilationResult reports the problem on line 1747 of the following file
>>
>> org.apache.commons.jci.compilers.EclipseCompilationProblem
>>
>> Regards
>>
>> Ben Short
>>
>> 2009/10/19 Torsten Curdt <[hidden email]>:
>>> Do you fail to compile or fail to load the page created?
>>> Looks like a class loading problem.
>>>
>>> cheers
>>> --
>>> Torsten
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Ben Short

Re: [JCI] Complication Error

Reply Threaded More More options
Print post
Permalink
Ah I think I have cracked it...

Changed

ResourceReader resourceReader = new ResourceReader() {
                        public byte[] getBytes(String s) {
                                return jspSource;
                        }

                        public boolean isAvailable(String s) {
                return true;
                        }
                };


to

ResourceReader resourceReader = new ResourceReader() {
                        public byte[] getBytes(String s) {
                                return jspSource;
                        }

                        public boolean isAvailable(String s) {
                return "simple.jsp".equals(s);
                        }
                };

Thanks.

Ben

2009/10/19 Ben Short <[hidden email]>:

> lol sorry that's the object id isn't it.
>
> Then I have no more information to give you at present.
>
> 2009/10/19 Torsten Curdt <[hidden email]>:
>> http://commons.apache.org/jci/xref/org/apache/commons/jci/compilers/EclipseCompilationProblem.html
>>
>> I count only 79 lines :)
>>
>> On Mon, Oct 19, 2009 at 19:09, Ben Short <[hidden email]> wrote:
>>> Hi Torsten,
>>>
>>> The CompilationResult reports the problem on line 1747 of the following file
>>>
>>> org.apache.commons.jci.compilers.EclipseCompilationProblem
>>>
>>> Regards
>>>
>>> Ben Short
>>>
>>> 2009/10/19 Torsten Curdt <[hidden email]>:
>>>> Do you fail to compile or fail to load the page created?
>>>> Looks like a class loading problem.
>>>>
>>>> cheers
>>>> --
>>>> Torsten
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Ben Short

Re: [JCI] Complication Error

Reply Threaded More More options
Print post
Permalink
Hi,

Is the JspGenerator mean to be production ready? As I don't believe it
working correctly. Given the simple.jsp it generates the simple.java
which just writes everything to the http response.

simple.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="javax.jcr.Node" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">

<%
    Node currentNode = (Node)request.getAttribute("currentNode");
%>

<html>
  <head><title>Simple jsp page</title></head>
  <body>Place your content here</body>
</html>

simple.java

import java.io.PrintWriter;
import java.io.IOException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
public class simple extends HttpServlet {
  protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
    final PrintWriter out = response.getWriter();
    out.write("<%@ page contentType=\"text/html;charset=UTF-8\"
language=\"java\" %>");
    out.write("<%@ page import=\"javax.jcr.Node\" %>");
    out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\"");
    out.write("        \"http://www.w3.org/TR/html4/loose.dtd\">");
    out.write("");
    out.write("<%");
    out.write("    Node currentNode =
(Node)request.getAttribute(\"currentNode\");");
    out.write("%>");
    out.write("");
    out.write("<html>");
    out.write("  <head><title>Simple jsp page</title></head>");
    out.write("  <body>Place your content here</body>");
    out.write("</html>");
    out.close();
    out.flush();
  }
}

2009/10/19 Ben Short <[hidden email]>:

> Ah I think I have cracked it...
>
> Changed
>
> ResourceReader resourceReader = new ResourceReader() {
>                        public byte[] getBytes(String s) {
>                                return jspSource;
>                        }
>
>                        public boolean isAvailable(String s) {
>                return true;
>                        }
>                };
>
>
> to
>
> ResourceReader resourceReader = new ResourceReader() {
>                        public byte[] getBytes(String s) {
>                                return jspSource;
>                        }
>
>                        public boolean isAvailable(String s) {
>                return "simple.jsp".equals(s);
>                        }
>                };
>
> Thanks.
>
> Ben
>
> 2009/10/19 Ben Short <[hidden email]>:
>> lol sorry that's the object id isn't it.
>>
>> Then I have no more information to give you at present.
>>
>> 2009/10/19 Torsten Curdt <[hidden email]>:
>>> http://commons.apache.org/jci/xref/org/apache/commons/jci/compilers/EclipseCompilationProblem.html
>>>
>>> I count only 79 lines :)
>>>
>>> On Mon, Oct 19, 2009 at 19:09, Ben Short <[hidden email]> wrote:
>>>> Hi Torsten,
>>>>
>>>> The CompilationResult reports the problem on line 1747 of the following file
>>>>
>>>> org.apache.commons.jci.compilers.EclipseCompilationProblem
>>>>
>>>> Regards
>>>>
>>>> Ben Short
>>>>
>>>> 2009/10/19 Torsten Curdt <[hidden email]>:
>>>>> Do you fail to compile or fail to load the page created?
>>>>> Looks like a class loading problem.
>>>>>
>>>>> cheers
>>>>> --
>>>>> Torsten
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: [hidden email]
>>>>> For additional commands, e-mail: [hidden email]
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Torsten Curdt-3

Re: [JCI] Complication Error

Reply Threaded More More options
Print post
Permalink
> Is the JspGenerator mean to be production ready?

It is just an example for jci and by no means meant for production as is.

> Given the simple.jsp it generates the simple.java
> which just writes everything to the http response.

I should auto-compile that java code and execute it though.

cheers
--
Torsten

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]