You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michael Szalay <mi...@gmail.com> on 2008/04/17 21:56:03 UTC
Newbie Question about services and modules
Hi all
I tried to build my first service, but its not found within the registration
I try to lookup it in the page:
@Inject
private QuizService quizService;
There is a Module class which should build my service:
package com.szalay.quiz.services;
import org.apache.tapestry.ioc.ServiceBinder;
/**
*
* @author michael
*/
public class QuizModule {
/**
* this is called by tapestry at application startup
*
* @param binder
*/
public void bind(ServiceBinder binder) {
binder.bind(QuizService.class,
QuizServiceImpl.class).scope("singleton");
}
}
QuizService:
package com.szalay.quiz.services;
import com.szalay.quiz.entity.Quiz;
import java.util.Collection;
/**
*
* @author michael
*/
public interface QuizService {
public Collection<Quiz> getLatestQuiz(int number) throws Exception;
public Integer getNumberOfQuizes() throws Exception;
}
QuizServiceImpl:
package com.szalay.quiz.services;
import com.szalay.quiz.entity.Quiz;
import java.util.Collection;
/**
*
* @author michael
*/
public class QuizServiceImpl implements QuizService {
public Collection<Quiz> getLatestQuiz(int number) throws Exception {
...
}
public Integer getNumberOfQuizes() throws Exception {
...
}
}
But this gets the error:
Caused by: java.lang.RuntimeException: No service implements the interface
com.szalay.quiz.services.QuizService.
at
org.apache.tapestry.ioc.internal.RegistryImpl.getService(RegistryImpl.java:517)
at
org.apache.tapestry.ioc.internal.ObjectLocatorImpl.getService(ObjectLocatorImpl.java:45)
at
org.apache.tapestry.internal.services.ServiceInjectionProvider.provideInjection(ServiceInjectionProvider.java:40)
here is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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">
<!-- tapestry stuff -->
<context-param>
<param-name>tapestry.app-package</param-name>
<param-value>com.szalay.quiz</param-value>
</context-param>
<filter>
<filter-name>app</filter-name>
<filter-class>org.apache.tapestry.TapestryFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>app</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- session timeout -->
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>
I have not idea about what is wrong. Anyone of you?
Regards
Michael
Re: Newbie Question about services and modules
Posted by Chris Lewis <ch...@bellsouth.net>.
Sorry I missed the filter-mapping part, which I believe needs to match
the filter name. So you should have:
...
<filter>
<filter-name>Quiz</filter-name>
<filter-class>org.apache.tapestry.TapestryFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Quiz</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
...
Chris Lewis wrote:
> Hi Michael,
>
> I believe the problem is your filter name in web.xml. See this part:
>
> ...
>
> <filter>
> <filter-name>app</filter-name>
> <filter-class>org.apache.tapestry.TapestryFilter</filter-class>
> </filter>
>
> ...
>
> If I remember correctly T5 uses the filter name to deduce your
> application module. By default (using the maven quickstart archetype)
> this is named 'app', and a default module is created for you named
> AppModule.java in the services directory. My guess is you renamed your
> module but did not rename your filter (I've done this a couple of times).
>
> chris
>
> Michael Szalay wrote:
>
>> Hi all
>>
>> I tried to build my first service, but its not found within the registration
>>
>> I try to lookup it in the page:
>>
>> @Inject
>> private QuizService quizService;
>>
>> There is a Module class which should build my service:
>>
>> package com.szalay.quiz.services;
>>
>> import org.apache.tapestry.ioc.ServiceBinder;
>>
>> /**
>> *
>> * @author michael
>> */
>> public class QuizModule {
>>
>> /**
>> * this is called by tapestry at application startup
>> *
>> * @param binder
>> */
>> public void bind(ServiceBinder binder) {
>> binder.bind(QuizService.class,
>> QuizServiceImpl.class).scope("singleton");
>> }
>> }
>>
>> QuizService:
>>
>> package com.szalay.quiz.services;
>>
>> import com.szalay.quiz.entity.Quiz;
>> import java.util.Collection;
>>
>> /**
>> *
>> * @author michael
>> */
>> public interface QuizService {
>>
>> public Collection<Quiz> getLatestQuiz(int number) throws Exception;
>>
>> public Integer getNumberOfQuizes() throws Exception;
>> }
>>
>>
>> QuizServiceImpl:
>>
>> package com.szalay.quiz.services;
>>
>> import com.szalay.quiz.entity.Quiz;
>> import java.util.Collection;
>>
>> /**
>> *
>> * @author michael
>> */
>> public class QuizServiceImpl implements QuizService {
>>
>> public Collection<Quiz> getLatestQuiz(int number) throws Exception {
>> ...
>> }
>>
>> public Integer getNumberOfQuizes() throws Exception {
>> ...
>> }
>>
>> }
>>
>>
>> But this gets the error:
>>
>> Caused by: java.lang.RuntimeException: No service implements the interface
>> com.szalay.quiz.services.QuizService.
>> at
>> org.apache.tapestry.ioc.internal.RegistryImpl.getService(RegistryImpl.java:517)
>> at
>> org.apache.tapestry.ioc.internal.ObjectLocatorImpl.getService(ObjectLocatorImpl.java:45)
>> at
>> org.apache.tapestry.internal.services.ServiceInjectionProvider.provideInjection(ServiceInjectionProvider.java:40)
>>
>>
>> here is my web.xml
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <web-app version="2.5" 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">
>>
>> <!-- tapestry stuff -->
>> <context-param>
>> <param-name>tapestry.app-package</param-name>
>> <param-value>com.szalay.quiz</param-value>
>> </context-param>
>> <filter>
>> <filter-name>app</filter-name>
>> <filter-class>org.apache.tapestry.TapestryFilter</filter-class>
>> </filter>
>> <filter-mapping>
>> <filter-name>app</filter-name>
>> <url-pattern>/*</url-pattern>
>> </filter-mapping>
>>
>> <!-- session timeout -->
>> <session-config>
>> <session-timeout>
>> 30
>> </session-timeout>
>> </session-config>
>>
>> </web-app>
>>
>>
>>
>> I have not idea about what is wrong. Anyone of you?
>>
>> Regards
>>
>> Michael
>>
>>
>>
>
>
--
http://thegodcode.net
Re: Newbie Question about services and modules
Posted by Chris Lewis <ch...@bellsouth.net>.
Hi Michael,
I believe the problem is your filter name in web.xml. See this part:
...
<filter>
<filter-name>app</filter-name>
<filter-class>org.apache.tapestry.TapestryFilter</filter-class>
</filter>
...
If I remember correctly T5 uses the filter name to deduce your
application module. By default (using the maven quickstart archetype)
this is named 'app', and a default module is created for you named
AppModule.java in the services directory. My guess is you renamed your
module but did not rename your filter (I've done this a couple of times).
chris
Michael Szalay wrote:
> Hi all
>
> I tried to build my first service, but its not found within the registration
>
> I try to lookup it in the page:
>
> @Inject
> private QuizService quizService;
>
> There is a Module class which should build my service:
>
> package com.szalay.quiz.services;
>
> import org.apache.tapestry.ioc.ServiceBinder;
>
> /**
> *
> * @author michael
> */
> public class QuizModule {
>
> /**
> * this is called by tapestry at application startup
> *
> * @param binder
> */
> public void bind(ServiceBinder binder) {
> binder.bind(QuizService.class,
> QuizServiceImpl.class).scope("singleton");
> }
> }
>
> QuizService:
>
> package com.szalay.quiz.services;
>
> import com.szalay.quiz.entity.Quiz;
> import java.util.Collection;
>
> /**
> *
> * @author michael
> */
> public interface QuizService {
>
> public Collection<Quiz> getLatestQuiz(int number) throws Exception;
>
> public Integer getNumberOfQuizes() throws Exception;
> }
>
>
> QuizServiceImpl:
>
> package com.szalay.quiz.services;
>
> import com.szalay.quiz.entity.Quiz;
> import java.util.Collection;
>
> /**
> *
> * @author michael
> */
> public class QuizServiceImpl implements QuizService {
>
> public Collection<Quiz> getLatestQuiz(int number) throws Exception {
> ...
> }
>
> public Integer getNumberOfQuizes() throws Exception {
> ...
> }
>
> }
>
>
> But this gets the error:
>
> Caused by: java.lang.RuntimeException: No service implements the interface
> com.szalay.quiz.services.QuizService.
> at
> org.apache.tapestry.ioc.internal.RegistryImpl.getService(RegistryImpl.java:517)
> at
> org.apache.tapestry.ioc.internal.ObjectLocatorImpl.getService(ObjectLocatorImpl.java:45)
> at
> org.apache.tapestry.internal.services.ServiceInjectionProvider.provideInjection(ServiceInjectionProvider.java:40)
>
>
> here is my web.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app version="2.5" 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">
>
> <!-- tapestry stuff -->
> <context-param>
> <param-name>tapestry.app-package</param-name>
> <param-value>com.szalay.quiz</param-value>
> </context-param>
> <filter>
> <filter-name>app</filter-name>
> <filter-class>org.apache.tapestry.TapestryFilter</filter-class>
> </filter>
> <filter-mapping>
> <filter-name>app</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
>
> <!-- session timeout -->
> <session-config>
> <session-timeout>
> 30
> </session-timeout>
> </session-config>
>
> </web-app>
>
>
>
> I have not idea about what is wrong. Anyone of you?
>
> Regards
>
> Michael
>
>
--
http://thegodcode.net
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Newbie Question about services and modules
Posted by Michael Szalay <mi...@gmail.com>.
Thanks a lot for your hints.
The problem was the name of the servlet filter and the build method, which
has to be static.
Regards
Michael
On Thu, Apr 17, 2008 at 10:01 PM, Igor Drobiazko <ig...@gmail.com>
wrote:
> Method bind shoould be static
>
> On Thu, Apr 17, 2008 at 9:56 PM, Michael Szalay <mi...@gmail.com>
> wrote:
>
> > Hi all
> >
> > I tried to build my first service, but its not found within the
> > registration
> >
> > I try to lookup it in the page:
> >
> > @Inject
> > private QuizService quizService;
> >
> > There is a Module class which should build my service:
> >
> > package com.szalay.quiz.services;
> >
> > import org.apache.tapestry.ioc.ServiceBinder;
> >
> > /**
> > *
> > * @author michael
> > */
> > public class QuizModule {
> >
> > /**
> > * this is called by tapestry at application startup
> > *
> > * @param binder
> > */
> > public void bind(ServiceBinder binder) {
> > binder.bind(QuizService.class,
> > QuizServiceImpl.class).scope("singleton");
> > }
> > }
> >
> > QuizService:
> >
> > package com.szalay.quiz.services;
> >
> > import com.szalay.quiz.entity.Quiz;
> > import java.util.Collection;
> >
> > /**
> > *
> > * @author michael
> > */
> > public interface QuizService {
> >
> > public Collection<Quiz> getLatestQuiz(int number) throws Exception;
> >
> > public Integer getNumberOfQuizes() throws Exception;
> > }
> >
> >
> > QuizServiceImpl:
> >
> > package com.szalay.quiz.services;
> >
> > import com.szalay.quiz.entity.Quiz;
> > import java.util.Collection;
> >
> > /**
> > *
> > * @author michael
> > */
> > public class QuizServiceImpl implements QuizService {
> >
> > public Collection<Quiz> getLatestQuiz(int number) throws Exception {
> > ...
> > }
> >
> > public Integer getNumberOfQuizes() throws Exception {
> > ...
> > }
> >
> > }
> >
> >
> > But this gets the error:
> >
> > Caused by: java.lang.RuntimeException: No service implements the
> interface
> > com.szalay.quiz.services.QuizService.
> > at
> >
> >
> org.apache.tapestry.ioc.internal.RegistryImpl.getService(RegistryImpl.java:517)
> > at
> >
> >
> org.apache.tapestry.ioc.internal.ObjectLocatorImpl.getService(ObjectLocatorImpl.java:45)
> > at
> >
> >
> org.apache.tapestry.internal.services.ServiceInjectionProvider.provideInjection(ServiceInjectionProvider.java:40)
> >
> >
> > here is my web.xml
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <web-app version="2.5" 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">
> >
> > <!-- tapestry stuff -->
> > <context-param>
> > <param-name>tapestry.app-package</param-name>
> > <param-value>com.szalay.quiz</param-value>
> > </context-param>
> > <filter>
> > <filter-name>app</filter-name>
> > <filter-class>org.apache.tapestry.TapestryFilter</filter-class>
> > </filter>
> > <filter-mapping>
> > <filter-name>app</filter-name>
> > <url-pattern>/*</url-pattern>
> > </filter-mapping>
> >
> > <!-- session timeout -->
> > <session-config>
> > <session-timeout>
> > 30
> > </session-timeout>
> > </session-config>
> >
> > </web-app>
> >
> >
> >
> > I have not idea about what is wrong. Anyone of you?
> >
> > Regards
> >
> > Michael
> >
>
>
>
> --
> Best regards,
>
> Igor Drobiazko
>
Re: Newbie Question about services and modules
Posted by Igor Drobiazko <ig...@gmail.com>.
Method bind shoould be static
On Thu, Apr 17, 2008 at 9:56 PM, Michael Szalay <mi...@gmail.com>
wrote:
> Hi all
>
> I tried to build my first service, but its not found within the
> registration
>
> I try to lookup it in the page:
>
> @Inject
> private QuizService quizService;
>
> There is a Module class which should build my service:
>
> package com.szalay.quiz.services;
>
> import org.apache.tapestry.ioc.ServiceBinder;
>
> /**
> *
> * @author michael
> */
> public class QuizModule {
>
> /**
> * this is called by tapestry at application startup
> *
> * @param binder
> */
> public void bind(ServiceBinder binder) {
> binder.bind(QuizService.class,
> QuizServiceImpl.class).scope("singleton");
> }
> }
>
> QuizService:
>
> package com.szalay.quiz.services;
>
> import com.szalay.quiz.entity.Quiz;
> import java.util.Collection;
>
> /**
> *
> * @author michael
> */
> public interface QuizService {
>
> public Collection<Quiz> getLatestQuiz(int number) throws Exception;
>
> public Integer getNumberOfQuizes() throws Exception;
> }
>
>
> QuizServiceImpl:
>
> package com.szalay.quiz.services;
>
> import com.szalay.quiz.entity.Quiz;
> import java.util.Collection;
>
> /**
> *
> * @author michael
> */
> public class QuizServiceImpl implements QuizService {
>
> public Collection<Quiz> getLatestQuiz(int number) throws Exception {
> ...
> }
>
> public Integer getNumberOfQuizes() throws Exception {
> ...
> }
>
> }
>
>
> But this gets the error:
>
> Caused by: java.lang.RuntimeException: No service implements the interface
> com.szalay.quiz.services.QuizService.
> at
>
> org.apache.tapestry.ioc.internal.RegistryImpl.getService(RegistryImpl.java:517)
> at
>
> org.apache.tapestry.ioc.internal.ObjectLocatorImpl.getService(ObjectLocatorImpl.java:45)
> at
>
> org.apache.tapestry.internal.services.ServiceInjectionProvider.provideInjection(ServiceInjectionProvider.java:40)
>
>
> here is my web.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app version="2.5" 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">
>
> <!-- tapestry stuff -->
> <context-param>
> <param-name>tapestry.app-package</param-name>
> <param-value>com.szalay.quiz</param-value>
> </context-param>
> <filter>
> <filter-name>app</filter-name>
> <filter-class>org.apache.tapestry.TapestryFilter</filter-class>
> </filter>
> <filter-mapping>
> <filter-name>app</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
>
> <!-- session timeout -->
> <session-config>
> <session-timeout>
> 30
> </session-timeout>
> </session-config>
>
> </web-app>
>
>
>
> I have not idea about what is wrong. Anyone of you?
>
> Regards
>
> Michael
>
--
Best regards,
Igor Drobiazko
Re: Newbie Question about services and modules
Posted by Peter Beshai <pe...@gmail.com>.
In your AppModule class you probably need to add
@SubModule({QuizModule.class}) above the class definition.
e.g.
@SubModule( { DAOModule.class })
public class AppModule
{
...
}
Also, you may want to make the bind method static, unless you're using
instance variables with it.
Peter Beshai
On Thu, Apr 17, 2008 at 3:56 PM, Michael Szalay <mi...@gmail.com>
wrote:
> Hi all
>
> I tried to build my first service, but its not found within the
> registration
>
> I try to lookup it in the page:
>
> @Inject
> private QuizService quizService;
>
> There is a Module class which should build my service:
>
> package com.szalay.quiz.services;
>
> import org.apache.tapestry.ioc.ServiceBinder;
>
> /**
> *
> * @author michael
> */
> public class QuizModule {
>
> /**
> * this is called by tapestry at application startup
> *
> * @param binder
> */
> public void bind(ServiceBinder binder) {
> binder.bind(QuizService.class,
> QuizServiceImpl.class).scope("singleton");
> }
> }
>
> QuizService:
>
> package com.szalay.quiz.services;
>
> import com.szalay.quiz.entity.Quiz;
> import java.util.Collection;
>
> /**
> *
> * @author michael
> */
> public interface QuizService {
>
> public Collection<Quiz> getLatestQuiz(int number) throws Exception;
>
> public Integer getNumberOfQuizes() throws Exception;
> }
>
>
> QuizServiceImpl:
>
> package com.szalay.quiz.services;
>
> import com.szalay.quiz.entity.Quiz;
> import java.util.Collection;
>
> /**
> *
> * @author michael
> */
> public class QuizServiceImpl implements QuizService {
>
> public Collection<Quiz> getLatestQuiz(int number) throws Exception {
> ...
> }
>
> public Integer getNumberOfQuizes() throws Exception {
> ...
> }
>
> }
>
>
> But this gets the error:
>
> Caused by: java.lang.RuntimeException: No service implements the interface
> com.szalay.quiz.services.QuizService.
> at
>
> org.apache.tapestry.ioc.internal.RegistryImpl.getService(RegistryImpl.java:517)
> at
>
> org.apache.tapestry.ioc.internal.ObjectLocatorImpl.getService(ObjectLocatorImpl.java:45)
> at
>
> org.apache.tapestry.internal.services.ServiceInjectionProvider.provideInjection(ServiceInjectionProvider.java:40)
>
>
> here is my web.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app version="2.5" 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">
>
> <!-- tapestry stuff -->
> <context-param>
> <param-name>tapestry.app-package</param-name>
> <param-value>com.szalay.quiz</param-value>
> </context-param>
> <filter>
> <filter-name>app</filter-name>
> <filter-class>org.apache.tapestry.TapestryFilter</filter-class>
> </filter>
> <filter-mapping>
> <filter-name>app</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
>
> <!-- session timeout -->
> <session-config>
> <session-timeout>
> 30
> </session-timeout>
> </session-config>
>
> </web-app>
>
>
>
> I have not idea about what is wrong. Anyone of you?
>
> Regards
>
> Michael
>