Binding to com.google.inject.Provider not found

14 views
Skip to first unread message

艾文哲.贝维斯

unread,
Mar 18, 2008, 1:35:34 PM3/18/08
to warp-core
hi dhanji
i spent too long time on warp-persist&struts2
But the repayment is not considerable.
I was really tired.....

I got this exception, even though i find some same question on forum,
but no answer could solve mine


start up the server info:
-----------------------------
2008-3-19 1:10:41 org.apache.catalina.core.AprLifecycleListener init
info: The Apache Tomcat Native library which allows optimal
performance in production environments was not found on the
java.library.path: C:\Program Files\Java\jre1.6.0_03\bin;E:\Programming
\Servers\apache-tomcat-6.0.14\bin
2008-3-19 1:10:42 org.apache.coyote.http11.Http11Protocol init
info: Initializing Coyote HTTP/1.1 on http-8080
2008-3-19 1:10:42 org.apache.catalina.startup.Catalina load
info: Initialization processed in 1673 ms
2008-3-19 1:10:42 org.apache.catalina.core.StandardService start
info: Starting service Catalina
2008-3-19 1:10:42 org.apache.catalina.core.StandardEngine start
info: Starting Servlet Engine: Apache Tomcat/6.0.14
2008-3-19 1:10:44 org.apache.catalina.core.ApplicationContext log
info: ContextListener: contextInitialized()
2008-3-19 1:10:44 org.apache.catalina.core.ApplicationContext log
info: SessionListener: contextInitialized()
2008-03-19 01:10:50,531 INFO (com.wideplay.warp.WarpFilter:94) -
Using module package: com.asu.cmoney.init ; server module root dir:
file:/E:/Programming/Servers/apache-tomcat-6.0.14/webapps/warp/WEB-INF/
classes/com/asu/cmoney/init/
2008-03-19 01:10:51,343 INFO
(com.wideplay.warp.internal.pages.PageHandlerBuilder:219) - Class
found that did not have a matching template (not an error or warning,
just letting u know) : com.asu.cmoney.init.AppServiceModule
$Initializer
2008-03-19 01:10:51,343 INFO
(com.wideplay.warp.internal.pages.PageHandlerBuilder:219) - Class
found that did not have a matching template (not an error or warning,
just letting u know) : com.asu.cmoney.init.AppServiceModule
2008-03-19 01:10:51,343 INFO
(com.wideplay.warp.internal.pages.PageHandlerBuilder:219) - Class
found that did not have a matching template (not an error or warning,
just letting u know) : com.asu.cmoney.init.AppWarpModule
2008-03-19 01:10:51,359 INFO
(com.wideplay.warp.internal.pages.PageHandlerBuilder:219) - Class
found that did not have a matching template (not an error or warning,
just letting u know) : com.asu.cmoney.init.GuiceModule
2008-03-19 01:10:51,406 INFO (com.asu.cmoney.init.AppWarpModule:20) -
###WarpModule loading....###
2008-03-19 01:10:52,328 INFO (org.hibernate.cfg.Environment:500) -
Hibernate 3.2.1
2008-03-19 01:10:52,375 INFO (org.hibernate.cfg.Environment:518) -
loaded properties from resource hibernate.properties:
{hibernate.connection.driver_class=com.mysql.jdbc.Driver,
hibernate.current_session_context_class=managed,
hibernate.dialect=org.hibernate.dialect.MySQLDialect,
hibernate.connection.username=root, hibernate.hbm2ddl.auto=update,
hibernate.connection.url=jdbc:mysql://localhost:3306/cmoney,
hibernate.bytecode.use_reflection_optimizer=false,
hibernate.show_sql=true, hibernate.connection.password=****}
2008-03-19 01:10:52,375 INFO (org.hibernate.cfg.Environment:667) -
Bytecode provider name : cglib
2008-03-19 01:10:52,453 INFO (org.hibernate.cfg.Environment:584) -
using JDK 1.4 java.sql.Timestamp handling
2008-03-19 01:10:53,281 INFO (org.hibernate.cfg.Configuration:1423) -
configuring from resource: hibernate.cfg.xml
2008-03-19 01:10:53,281 INFO (org.hibernate.cfg.Configuration:1400) -
Configuration resource: hibernate.cfg.xml
2008-03-19 01:10:54,312 INFO (org.hibernate.cfg.Configuration:1538) -
Configured SessionFactory: null
2008-03-19 01:10:57,046 INFO
(org.hibernate.connection.DriverManagerConnectionProvider:41) - Using
Hibernate built-in connection pool (not for production use!)
2008-03-19 01:10:57,046 INFO
(org.hibernate.connection.DriverManagerConnectionProvider:42) -
Hibernate connection pool size: 20
2008-03-19 01:10:57,062 INFO
(org.hibernate.connection.DriverManagerConnectionProvider:45) -
autocommit mode: false
2008-03-19 01:10:57,109 INFO
(org.hibernate.connection.DriverManagerConnectionProvider:80) - using
driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/
cmoney
2008-03-19 01:10:57,125 INFO
(org.hibernate.connection.DriverManagerConnectionProvider:86) -
connection properties: {user=root, password=****}
2008-03-19 01:10:58,203 INFO (org.hibernate.cfg.SettingsFactory:81) -
RDBMS: MySQL, version: 5.0.51a-community-nt
2008-03-19 01:10:58,203 INFO (org.hibernate.cfg.SettingsFactory:82) -
JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.0.8
( Revision: ${svn.Revision} )
2008-03-19 01:10:58,531 INFO (org.hibernate.dialect.Dialect:151) -
Using dialect: org.hibernate.dialect.MySQLDialect
2008-03-19 01:10:59,062 INFO
(org.hibernate.transaction.TransactionFactoryFactory:31) - Using
default transaction strategy (direct JDBC transactions)
2008-03-19 01:10:59,093 INFO
(org.hibernate.transaction.TransactionManagerLookupFactory:33) - No
TransactionManagerLookup configured (in JTA environment, use of read-
write or transactional second-level cache is not recommended)
2008-03-19 01:10:59,093 INFO (org.hibernate.cfg.SettingsFactory:134)
- Automatic flush during beforeCompletion(): disabled
2008-03-19 01:10:59,093 INFO (org.hibernate.cfg.SettingsFactory:138)
- Automatic session close at end of transaction: disabled
2008-03-19 01:10:59,093 INFO (org.hibernate.cfg.SettingsFactory:145)
- JDBC batch size: 15
2008-03-19 01:10:59,109 INFO (org.hibernate.cfg.SettingsFactory:148)
- JDBC batch updates for versioned data: disabled
2008-03-19 01:10:59,125 INFO (org.hibernate.cfg.SettingsFactory:153)
- Scrollable result sets: enabled
2008-03-19 01:10:59,125 INFO (org.hibernate.cfg.SettingsFactory:161)
- JDBC3 getGeneratedKeys(): enabled
2008-03-19 01:10:59,125 INFO (org.hibernate.cfg.SettingsFactory:169)
- Connection release mode: auto
2008-03-19 01:10:59,140 INFO (org.hibernate.cfg.SettingsFactory:193)
- Maximum outer join fetch depth: 2
2008-03-19 01:10:59,140 INFO (org.hibernate.cfg.SettingsFactory:196)
- Default batch fetch size: 1
2008-03-19 01:10:59,140 INFO (org.hibernate.cfg.SettingsFactory:200)
- Generate SQL with comments: disabled
2008-03-19 01:10:59,156 INFO (org.hibernate.cfg.SettingsFactory:204)
- Order SQL updates by primary key: disabled
2008-03-19 01:10:59,156 INFO (org.hibernate.cfg.SettingsFactory:369)
- Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
2008-03-19 01:10:59,203 INFO
(org.hibernate.hql.ast.ASTQueryTranslatorFactory:24) - Using
ASTQueryTranslatorFactory
2008-03-19 01:10:59,203 INFO (org.hibernate.cfg.SettingsFactory:212)
- Query language substitutions: {}
2008-03-19 01:10:59,203 INFO (org.hibernate.cfg.SettingsFactory:217)
- JPA-QL strict compliance: disabled
2008-03-19 01:10:59,203 INFO (org.hibernate.cfg.SettingsFactory:222)
- Second-level cache: enabled
2008-03-19 01:10:59,203 INFO (org.hibernate.cfg.SettingsFactory:226)
- Query cache: disabled
2008-03-19 01:10:59,203 INFO (org.hibernate.cfg.SettingsFactory:356)
- Cache provider: org.hibernate.cache.NoCacheProvider
2008-03-19 01:10:59,203 INFO (org.hibernate.cfg.SettingsFactory:241)
- Optimize cache for minimal puts: disabled
2008-03-19 01:10:59,218 INFO (org.hibernate.cfg.SettingsFactory:250)
- Structured second-level cache entries: disabled
2008-03-19 01:10:59,375 INFO (org.hibernate.cfg.SettingsFactory:270)
- Echoing all SQL to stdout
2008-03-19 01:10:59,375 INFO (org.hibernate.cfg.SettingsFactory:277)
- Statistics: disabled
2008-03-19 01:10:59,375 INFO (org.hibernate.cfg.SettingsFactory:281)
- Deleted entity synthetic identifier rollback: disabled
2008-03-19 01:10:59,390 INFO (org.hibernate.cfg.SettingsFactory:296)
- Default entity-mode: pojo
2008-03-19 01:10:59,765 INFO (org.hibernate.impl.SessionFactoryImpl:
161) - building session factory
2008-03-19 01:10:59,828 INFO
(org.hibernate.impl.SessionFactoryObjectFactory:82) - Not binding
factory to JNDI, no JNDI name configured
2008-03-19 01:10:59,875 INFO (org.hibernate.tool.hbm2ddl.SchemaUpdate:
115) - Running hbm2ddl schema update
2008-03-19 01:10:59,875 INFO (org.hibernate.tool.hbm2ddl.SchemaUpdate:
126) - fetching database metadata
2008-03-19 01:10:59,875 INFO (org.hibernate.tool.hbm2ddl.SchemaUpdate:
138) - updating schema
2008-03-19 01:10:59,890 INFO (org.hibernate.tool.hbm2ddl.SchemaUpdate:
160) - schema update complete
2008-03-19 01:10:59,953 INFO (com.asu.cmoney.init.AppServiceModule
$Initializer:28) - ###Warp Initialized...
2008-03-19 01:11:00,937 INFO (org.directwebremoting.impl.StartupUtil:
51) - DWR Version 2.0.3 starting.
2008-03-19 01:11:00,937 INFO (org.directwebremoting.impl.StartupUtil:
51) - - Servlet Engine: Apache Tomcat/6.0.14
2008-03-19 01:11:00,937 INFO (org.directwebremoting.impl.StartupUtil:
51) - - Java Version: 1.6.0_03
2008-03-19 01:11:00,937 INFO (org.directwebremoting.impl.StartupUtil:
51) - - Java Vendor: Sun Microsystems Inc.
2008-03-19 01:11:04,687 INFO
(com.opensymphony.xwork2.config.providers.XmlConfigurationProvider:
140) - Parsing configuration file [struts-default.xml]
2008-03-19 01:11:05,390 INFO
(com.opensymphony.xwork2.config.providers.XmlConfigurationProvider:
140) - Parsing configuration file [struts-plugin.xml]
2008-03-19 01:11:05,484 INFO
(com.opensymphony.xwork2.config.providers.XmlConfigurationProvider:
140) - Parsing configuration file [struts.xml]
2008-03-19 01:11:05,546 INFO
(org.apache.struts2.config.BeanSelectionProvider:203) - Choosing bean
(guice) for class com.opensymphony.xwork2.ObjectFactory
2008-03-19 01:11:05,546 INFO
(org.apache.struts2.config.BeanSelectionProvider:203) - Choosing bean
(struts) for class com.opensymphony.xwork2.util.XWorkConverter
2008-03-19 01:11:05,546 INFO
(org.apache.struts2.config.BeanSelectionProvider:203) - Choosing bean
(struts) for interface com.opensymphony.xwork2.TextProvider
2008-03-19 01:11:05,546 INFO
(org.apache.struts2.config.BeanSelectionProvider:203) - Choosing bean
(struts) for interface com.opensymphony.xwork2.ActionProxyFactory
2008-03-19 01:11:05,562 INFO
(org.apache.struts2.config.BeanSelectionProvider:203) - Choosing bean
(struts) for interface
com.opensymphony.xwork2.util.ObjectTypeDeterminer
2008-03-19 01:11:05,562 INFO
(org.apache.struts2.config.BeanSelectionProvider:203) - Choosing bean
(struts) for interface
org.apache.struts2.dispatcher.mapper.ActionMapper
2008-03-19 01:11:05,562 DEBUG
(org.apache.struts2.config.BeanSelectionProvider:216) - Choosing bean
(jakarta) for interface
org.apache.struts2.dispatcher.multipart.MultiPartRequest to be loaded
from the ObjectFactory
2008-03-19 01:11:05,593 DEBUG
(org.apache.struts2.config.BeanSelectionProvider:216) - Choosing bean
(struts) for class
org.apache.struts2.views.freemarker.FreemarkerManager to be loaded
from the ObjectFactory
2008-03-19 01:11:05,625 DEBUG
(org.apache.struts2.config.BeanSelectionProvider:216) - Choosing bean
(struts) for class org.apache.struts2.views.velocity.VelocityManager
to be loaded from the ObjectFactory
2008-03-19 01:11:08,062 INFO
(com.opensymphony.xwork2.util.ObjectTypeDeterminerFactory:28) -
Setting DefaultObjectTypeDeterminer as default ...
2008-3-19 1:11:08 org.apache.coyote.http11.Http11Protocol start
info: Starting Coyote HTTP/1.1 on http-8080
2008-3-19 1:11:08 org.apache.jk.common.ChannelSocket init
info: JK: ajp13 listening on /0.0.0.0:8009
2008-3-19 1:11:08 org.apache.jk.server.JkMain start
info: Jk running ID=0 time=0/94 config=null
2008-3-19 1:11:08 org.apache.catalina.startup.Catalina start
info: Server startup in 26188 ms
---------------
when i request
---------------
2008-3-19 1:11:39 com.google.inject.struts2.GuiceObjectFactory
createInjector
info: Creating injector...
2008-3-19 1:11:40 com.google.inject.struts2.GuiceObjectFactory$1
configure
info: Installing com.asu.cmoney.init.GuiceModule@19f1a8a...
com.google.inject.CreationException: Guice configuration errors:



1) Error at
com.asu.cmoney.service.impl.HelloImpl.session(HelloImpl.java:11):
Binding to com.google.inject.Provider<org.hibernate.Session> not
found. No bindings to that type were found.

1 error[s]
at com.google.inject.BinderImpl.createInjector(BinderImpl.java:277)
at com.google.inject.Guice.createInjector(Guice.java:79)
at com.google.inject.Guice.createInjector(Guice.java:53)
at com.google.inject.Guice.createInjector(Guice.java:43)
at
com.google.inject.struts2.GuiceObjectFactory.createInjector(GuiceObjectFactory.java:
118)
at
com.google.inject.struts2.GuiceObjectFactory.buildBean(GuiceObjectFactory.java:
107)
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:
154)
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:
143)
at
com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:
113)
at
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:
275)
at
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:
365)
at com.opensymphony.xwork2.DefaultActionInvocation.access
$000(DefaultActionInvocation.java:38)
at com.opensymphony.xwork2.DefaultActionInvocation
$1.doProfiling(DefaultActionInvocation.java:83)
at
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:
455)
at
com.opensymphony.xwork2.DefaultActionInvocation.<init>(DefaultActionInvocation.java:
74)
at
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:
189)
at
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:
41)
at
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:
494)
at
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:
419)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
175)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
128)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
263)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
844)
at org.apache.coyote.http11.Http11Protocol
$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:
447)
at java.lang.Thread.run(Unknown Source)


----------------------------




as you see, i can startup successfully

but when guice start to create injectors
it sad *Binding to com.google.inject.Provider<Session> not found. No
bindings to that type were found.*
I tried and tried, step by step, again and again , lib, code (Dhanji ,
i'd repair my code add and delete libs by your words of mail)

code again
---------------
public class AppWarpModule implements WarpModule {
private Log logger = LogFactory.getLog(getClass());
private Injector injector;

public void configure(Warp warp) {
logger.info("###WarpModule loading....###");

Module module = PersistenceService.usingHibernate()
.across(UnitOfWork.REQUEST).transactedWith(
TransactionStrategy.LOCAL)// .forAll(Matchers.any())
.buildModule();
injector = Guice.createInjector(new AppServiceModule(), module);
}
}

---------------
public class AppServiceModule extends AbstractModule {
private final Log logger = LogFactory.getLog(getClass());

protected void configure() {
bind(Configuration.class).toInstance(
new Configuration().configure("hibernate.cfg.xml"));
bind(Initializer.class).asEagerSingleton();

}

@Singleton
public static class Initializer {
private final Log logger = LogFactory.getLog(getClass());

@Inject
Initializer(com.wideplay.warp.persist.PersistenceService service) {
service.start();
logger.info("###Warp Initialized...");
}
}

}
-----------------------
public class HelloAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private final Log logger = LogFactory.getLog(getClass());

@Inject
Provider<Session> session;

@Transactional
public String execute() {
logger.info("in the end , i got the session : " + session.get());
// logger.info(session.get().hashCode());
return SUCCESS;
}
}
-------------
there is no codes in subClassOfGuiceModule
-------------

any more infomations you need?

anybody can clear explanation this question, and helps me to solve it?

thanks

-Bevis

Dhanji R. Prasanna

unread,
Mar 18, 2008, 5:59:53 PM3/18/08
to warp...@googlegroups.com
Hi

Don't worry -- let's figure out this problem. Im sure it is very simple, I am betting it is just not creating the right injector.
Zip up your entire source code including libs and struts2 files and build files. Then upload it on google groups page:


I will take a look at it then.

Dhanji.

艾文哲.贝维斯

unread,
Mar 18, 2008, 9:37:09 PM3/18/08
to warp-core
Thanks for your patience the help , Dhanji
i'm uploading the zip file, and it's will done in a few minutes
Thanks again

艾文哲.贝维斯

unread,
Mar 18, 2008, 11:20:17 PM3/18/08
to warp-core
i uploaded the zip file with libs about 2 hours ...
it still "uploading..."

so i delete the libs

it had uploaded

Dhanji R. Prasanna

unread,
Mar 19, 2008, 12:52:00 AM3/19/08
to warp...@googlegroups.com
As I suspected you are not creating the injector at all!

Two points:

- you are using Warp-Mvc's startup listener (this is completely unnecessary, and won't work with struts2)
- you need to configure struts2 to use Guice as its object factory:
add these to struts.xml:
<constant name="struts.objectFactory" value="guice" />
<constant name="guice.module" value="com.asu.cmoney.init.AppServiceModule"/>

Then change your Guice module to install warp-persist:

public class AppServiceModule extends AbstractModule {

private final Log logger = LogFactory.getLog(getClass());


protected void configure() {

             install(PersistenceService.usingHibernate().across(TRANSACTION).buildModule());

bind(Configuration.class).toInstance(

new Configuration().configure("hibernate.cfg.xml"));

bind(Initializer.class).asEagerSingleton();

             

}

... //initializer, etc. as it was before...


You can get rid of AppWarpModule and GuiceModule.

Dhanji.

2008/3/19 艾文哲.贝维斯 <Avenge...@gmail.com>:

艾文哲.贝维斯

unread,
Mar 19, 2008, 2:49:08 AM3/19/08
to warp-core
Yeah!
I have completed it under your help.
you're right ,it was not creating the injector at all!
thank you very much.

Reply all
Reply to author
Forward
0 new messages