Getting Started

20 views
Skip to first unread message

Luther Baker

unread,
Oct 4, 2009, 10:45:48 AM10/4/09
to Google Sitebricks
I'm trying to create the Example from the GettingStarted page ... but
can't seem to find the implementation of 'scan' from

@Override
public Injector getInjector() {
return Guice.createInjector(new SitebricksModule() {
@Override
protected void configureSitebricks() {
scan(Example.class.getPackage()) //scan class
Example's package and all descendants
}
});
}

what am I missing?

Also - it is not perfectly obvious to me how to set this up. I built
the jar file from svn but which libs do I need to drop into WEB-INF/
lib? I see the 'full' zip file and I've exploded that out and mirrored
it's structure copying WEB-INF/lib/* to my corresponding lib
directory. Is that correct?

(maven support is going to be swe-e-e-et! :)

Thanks,

-Luther

Yuan

unread,
Oct 4, 2009, 2:57:06 PM10/4/09
to Google Sitebricks
you need to import aopalliance.jar, google-collect-1.0-rc2.jar, google-
sitebricks-0.7.jar, guice-2.0.jar, and guice-servlet.jar.

for the scan, you need import

import com.google.inject.Injector;
import com.google.inject.Guice;
import com.google.inject.servlet.GuiceServletContextListener;
import com.google.sitebricks.SitebricksModule;

all the examples from sitebricks and guice miss import statements
somehow.

Dhanji R. Prasanna

unread,
Oct 4, 2009, 7:17:34 PM10/4/09
to google-s...@googlegroups.com
Yea that should do it. It should include all the deps in it.

Yea, we deliberately leave out the import statements in examples to save space, maybe that's not such a good idea =(

Dhanji.

Dhanji R. Prasanna

unread,
Oct 4, 2009, 7:19:37 PM10/4/09
to google-s...@googlegroups.com
On Mon, Oct 5, 2009 at 10:17 AM, Dhanji R. Prasanna <dha...@gmail.com> wrote:


On Mon, Oct 5, 2009 at 1:45 AM, Luther Baker <luthe...@gmail.com> wrote:

I'm trying to create the Example from the GettingStarted page ... but
can't seem to find the implementation of 'scan' from

Luther Baker

unread,
Oct 4, 2009, 11:26:04 PM10/4/09
to google-s...@googlegroups.com
Thanks for the responses.

In this specific case, it wasn't necessarily the import statements that got me (Eclipse fills those in nicely) ... but instead, I thought 

    new SiteBricksModule()

was part of the example! I had created my own Module:

    return Guice.createInjector(new MyOwnModule() { ... })

and thought 'scan' was something I'd missed. I see now that I'm to actually use SiteBricksModule with my own package. I'll try that and let you know if I have any other trouble. Thanks again,

-Luther

Ramkumar

unread,
Oct 5, 2009, 10:12:32 PM10/5/09
to Google Sitebricks
I am having issues while deploying the example on Glassfishv3 Server.
I get the HTTP 404 error when I type the URL:
http://localhost:8080/sitebricks_getstarted/

I have deployed the example as a war file, sitebricks_getstarted.war.
I have placed the Example.html directly under the WEB-INF folder.

sitebricks_getstarted.war
|
WEB-INF
|
classes/org/example/web/*.classes (has 3 classes)
|
lib (has the 5 jar files)
|
Example.html

I have changed the Example.java to account for http://localhost:8080/sitebricks_getstarted/
by :

@At("/sitebricks_getstarted/")
public class Example {
private String message = "Hello";

public String getMessage() { return message; }
}

Have I placed the Example.html in the wrong directory?

Dhanji R. Prasanna

unread,
Oct 5, 2009, 10:14:39 PM10/5/09
to google-s...@googlegroups.com
What does your web.xml look like?

Josh McDonald

unread,
Oct 5, 2009, 10:15:16 PM10/5/09
to google-s...@googlegroups.com
I find in most cases (when getting started), a 404 means there was a problem with deploying, and the server logs should give you more info.

-Josh

2009/10/6 Ramkumar <ramku...@gmail.com>



--
"Therefore, send not to know For whom the bell tolls. It tolls for thee."

Josh 'G-Funk' McDonald
  -  jo...@joshmcdonald.info
  -  http://twitter.com/sophistifunk
  -  http://flex.joshmcdonald.info/

Ramkumar

unread,
Oct 6, 2009, 9:04:08 PM10/6/09
to Google Sitebricks
My web.xml looks like below. http://localhost:8080/sitebricks_getstarted/
still goes to the default index.html

The glassfish logs does not reveal anything.

====web.xml====

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">

<display-name>Archetype Created Web Application</display-name>
<filter>
<filter-name>webFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-
class>
</filter>

<filter-mapping>
<filter-name>webFilter</filter-name>
<url-pattern>/sitebricks_getstarted/*</url-pattern>
</filter-mapping>

<listener>
<listener-class>org.example.web.MyGuiceCreator</listener-
class>
</listener>

</web-app>

On Oct 6, 10:15 am, Josh McDonald <j...@joshmcdonald.info> wrote:
> I find in most cases (when getting started), a 404 means there was a problem
> with deploying, and the server logs should give you more info.
>
> -Josh
>
> 2009/10/6 Ramkumar <ramkuma...@gmail.com>
>   -  j...@joshmcdonald.info

Josh McDonald

unread,
Oct 6, 2009, 9:55:52 PM10/6/09
to google-s...@googlegroups.com
It looks OK to me. Are you sure your web app is being deployed successfully, and to the root context? I don't have any experience with Glassfish so I'm not sure how to double-check that :-/

-Josh

2009/10/7 Ramkumar <ramku...@gmail.com>
  -  jo...@joshmcdonald.info

Dhanji R. Prasanna

unread,
Oct 7, 2009, 12:11:33 AM10/7/09
to google-s...@googlegroups.com
On Wed, Oct 7, 2009 at 12:04 PM, Ramkumar <ramku...@gmail.com> wrote:

My web.xml looks like below. http://localhost:8080/sitebricks_getstarted/
still goes to the default index.html

The glassfish logs does not reveal anything.

====web.xml====

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        version="2.5">

   <display-name>Archetype Created Web Application</display-name>
   <filter>
       <filter-name>webFilter</filter-name>
       <filter-class>com.google.inject.servlet.GuiceFilter</filter-
class>
   </filter>

   <filter-mapping>
       <filter-name>webFilter</filter-name>
       <url-pattern>/sitebricks_getstarted/*</url-pattern>

It needs to filter /*

Also are you sure you are not deploying to /sitebricks_getstarted ?
If you are then your page should be @At("/")

Remember that app URLs are contextual (this is just how the servlet framework works). Im pretty sure that's where you are getting mixed up.

Dhanji.

Ramkumar

unread,
Oct 7, 2009, 1:40:19 PM10/7/09
to Google Sitebricks
Sorry to keep bothering.

Corrected the mistake about the URLs - At('/') and <url-pattern>/*</
url-pattern>

I got the following error after deploying to Glassfishv3 and typing
================
com.google.sitebricks.dom4j.DocumentException: Error on line 5 of
document : White spaces are required between publicId and systemId.
Nested exception: White spaces are required between publicId and
systemId.
================

I deployed the same sitebricks_getstarted.war on Jetty-6.1.21 but the
result was the same error as above.

/Ramkumar

On Oct 7, 9:04 am, Ramkumar <ramkuma...@gmail.com> wrote:
> My web.xml looks like below.http://localhost:8080/sitebricks_getstarted/
> still goes to the default index.html
>
> The glassfish logs does not reveal anything.
>
> ====web.xml====
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app xmlns="http://java.sun.com/xml/ns/javaee"
>          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>          xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

Tim

unread,
Oct 7, 2009, 2:30:44 PM10/7/09
to Google Sitebricks
Remove the <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//
EN"> (or similar) from your page.

On Oct 7, 1:40 pm, Ramkumar <ramkuma...@gmail.com> wrote:
> Sorry to keep bothering.
>
> Corrected the mistake about the URLs - At('/') and <url-pattern>/*</
> url-pattern>
>
> I got the following error after deploying to Glassfishv3 and typing
> the URL:http://localhost:8080/sitebricks_getstarted/
>
> ================
> com.google.sitebricks.dom4j.DocumentException: Error on line 5 of
> document  : White spaces are required between publicId and systemId.
> Nested exception: White spaces are required between publicId and
> systemId.
> ================
>
> I deployed the same sitebricks_getstarted.war on Jetty-6.1.21 but the
> result was the same error as above.
>
> /Ramkumar
>
> On Oct 7, 9:04 am, Ramkumar <ramkuma...@gmail.com> wrote:
>
> > My web.xml looks like below.http://localhost:8080/sitebricks_getstarted/
> > still goes to the default index.html
>
> > The glassfish logs does not reveal anything.
>
> > ====web.xml====
>
> > <?xml version="1.0" encoding="UTF-8"?>
> > <web-app xmlns="http://java.sun.com/xml/ns/javaee"
> >          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >          xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/we..."

Ramkumar

unread,
Oct 7, 2009, 9:32:46 PM10/7/09
to Google Sitebricks
Thank you very much.

The example now works properly, both in Glassfishv3 and Jetty-6.1.21

/Ramkumar

Brad Dwyer

unread,
Oct 13, 2009, 8:06:32 AM10/13/09
to google-s...@googlegroups.com
Quick update.

I've got a fix for handling DTDs correctly. I've sent the patch to Dhanji to review. If all is good I'll commit it into svn.

Tim

unread,
Oct 13, 2009, 9:06:11 AM10/13/09
to google-s...@googlegroups.com
On Tue, Oct 13, 2009 at 8:06 AM, Brad Dwyer <br...@bradleydwyer.com> wrote:
I've got a fix for handling DTDs correctly. I've sent the patch to Dhanji to review. If all is good I'll commit it into svn.

Very cool.

--
Tim
Reply all
Reply to author
Forward
0 new messages