On 2012-04-13, at 10:55 AM, Ron X wrote:
hi
public class Application extends InjectableApplication {
private static Logger log = Logger.getLogger(Application.class);
public static void main(String[] argv) {
WOInject.init("com.legalsounds.Application", argv);
}
@Facebook Socialable socialPerson;
public Application() {
Injector injector = injector();
socialPerson = injector.getInstance(Socialable.class);
You are confusing the injector by providing Socialable.class, it must be
socialPerson = injector.getInstance(FacebookPerson.class);
I tell you the reason:
E.g. you've another bindable annotation named Twitter and you've TwitterPerson extending Socialable, what you expect the injector to return when you call injector.getInstance(Socialble.class) when it has no means to understand what implementation you're looking for?
Hope this helps.
Farrukh
..............fails at this line............
@Override
protected Module[] modules() {
return new Module[] { new SocialModule() };
}
}
public class SocialModule extends AbstractModule {
@Override
protected void configure() {
bind(Socialable.class).annotatedWith(Facebook.class).to(FacebookPerson.class).in(WOScopes.SESSION);
}
}
public class FacebookPerson implements Socialable {
private static Logger log = Logger.getLogger(FacebookPerson.class);
@Override
public void send(List<Socialable> socialPersonList) {
log.info(this);
}
}
stack trace:
WARN 32.7 MB used/48.36 MB free [ProcessChangesQueue] (ERXNSLogLog4jBridge.java:43) - A fatal exception occurred: Guice configuration errors:
1) No implementation for com.ronx.module.Socialable was bound.
while locating com.ronx.module.Socialable
1 error
[2012-4-13 0:49:49 PDT] <ProcessChangesQueue> com.google.inject.ConfigurationException: Guice configuration errors:
1) No implementation for com.ronx.module.Socialable was bound.
while locating com.ronx.module.Socialable
1 error
at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1004)
why it happens?
13 апреля 2012 г. 0:05 пользователь Henrique Prange
<email@hidden> написал:
Hi Ron,
On 12/04/2012, at 08:04, Ron X wrote:
> please tell me - how you start app with woinject?
> i can't do that!
>
Your Application class should look like this:
package com.ronx;
import com.woinject.InjectableApplication;
import com.woinject.WOInject;
public class Application extends InjectableApplication {
public static void main(String[] args) {
WOInject.init("com.ronx.Application", args);
}
...
}
> everytime i have
> Exception in thread "main" java.lang.NoClassDefFoundError: com/ronx/Application
> Caused by: java.lang.ClassNotFoundException: com.ronx.Application
> 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 java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
>
> or if i comment ERXApplication.main(argv, Application.class);
>
You should not start your application with the ERXApplication class when using WOInject.
Cheers,
Henrique
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden