deltaspike-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gerhard Petracek <gerhard.petra...@gmail.com>
Subject Re: Unsatisfied dependencies for type TransactionStrategy error on tomcat8
Date Sun, 27 Oct 2013 14:57:16 GMT
hi,

here i've basically the same in a demo-app (just with owb instead of weld)
and it works fine.
-> if your setup works with tomcat 7, you could contact the weld-list
(since our tests pass with weld 2.0.4).

fyi: you can use TransactionHelper for #2.

regards,
gerhard



2013/10/27 εδΈ‰ιƒŽ <mihaisheng@163.com>

>
> hi everyone:
>
> i write a simple apache deltaspike jpa demo,run to error on tomcat8.0.
> (i use tomcat8.0rc5 ; jdk1.7 ,deltaspike0.5)
>
> 1,first,i define a EntityManagerProducer
> public class EntityManagerProducer
> {
>     @PersistenceContext(unitName = "persistence0")
>     private EntityManager entityManager;
>     @Produces
>     @RequestScoped
>     protected EntityManager createEntityManager()
>     {
>         return this.entityManager;
>     }
>     protected void closeEntityManager(@Disposes EntityManager
> entityManager)
>     {
>         if (entityManager.isOpen())
>         {
>             entityManager.close();
>         }
>     }
> }
>
>
> 2,and i want do some database transactional work manually(i wanna a manual
> way).
> ---------------------------
> @Named
> @SessionScoped
> public class Test implements Serializable
> {
>     private static final long serialVersionUID = -1231439157655757940L;
>     public String test1(){
>         EntityManager
> entityManager0=BeanProvider.getContextualReference(EntityManager.class,false);
>         entityManager0.getTransaction().begin();
>         try{
>             //just fill some test data to database
>             String sql="insert into grandscape_user
> (user_name,user_password) values (:u,:p)";
>             Query query=entityManager0.createNativeQuery(sql);
>             query.setParameter("u", "Jason Porter");
>             query.setParameter("p", "secrete");
>             query.executeUpdate();
>             entityManager0.getTransaction().commit();
>             return "success";
>         }catch(Exception ex){
>             entityManager0.getTransaction().rollback();
>             return ex.getMessage();
>         }
>     }
> }
> -------------------
>
>
> 3,and persistence.xml.
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence xmlns="http://java.sun.com/xml/ns/persistence"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
>     version="2.0">
>     <persistence-unit name="persistence0"
> transaction-type="RESOURCE_LOCAL">
>         <provider>org.hibernate.ejb.HibernatePersistence</provider>
>         <properties>
>             <property name="hibernate.connection.driver_class"
> value="com.mysql.jdbc.Driver"/>
>             <property name="hibernate.connection.url"
> value="jdbc:mysql://localhost:3306/grandscape_websit/"></property>
>             <property name="hibernate.connection.username" value="root" />
>             <property name="hibernate.connection.password" value="root" />
>             <property name="hibernate.dialect"
> value="org.hibernate.dialect.MySQLInnoDBDialect"/>
>             <property name="hibernate.connection.autocommit" value="true"
> />
>             <property name="hibernate.hbm2ddl.auto" value="validate"/>
>             <property name="hibernate.show_sql" value="false"/>
>             <property name="hibernate.cache.use_second_level_cache"
> value="true"/>
>             <property name="hibernate.cache.provider_class"
> value="net.sf.ehcache.hibernate.SingletonEhCacheProvider"/>
>             <property name="hibernate.search.default.directory_provider"
> value="org.hibernate.search.store.FSDirectoryProvider"/>
>             <property name="hibernate.search.default.indexBase"
> value="./lucene/indexes"/>
>             <property name="hibernate.search.default.batch.merge_factor"
> value="10"/>
>             <property
> name="hibernate.search.default.batch.max_buffered_docs" value="10"/>
>         </properties>
>     </persistence-unit>
> </persistence>
> ------------
>
>
> 4,finally,when i deployed the program to tomcat,the error occured:
> ----------
> 26-Oct-2013 12:04:51.642 SEVERE [http-nio-8080-exec-6]
> org.apache.catalina.core.StandardContext.listenerStart Exception sending
> context initialized event to listener instance of class
> org.jboss.weld.environment.servlet.Listener
>  org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied
> dependencies for type TransactionStrategy with qualifiers @Default
>   at injection point [BackedAnnotatedField] @Inject private
> org.apache.deltaspike.jpa.impl.transaction.TransactionalInterceptor.transactionStrategy
>   at
> org.apache.deltaspike.jpa.impl.transaction.TransactionalInterceptor.transactionStrategy(TransactionalInterceptor.java:0)
>
>     at
> org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:405)
>     at
> org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:327)
>     at
> org.jboss.weld.bootstrap.Validator.validateInterceptor(Validator.java:565)
>     at
> org.jboss.weld.bootstrap.ConcurrentValidator$2.doWork(ConcurrentValidator.java:88)
>     at
> org.jboss.weld.bootstrap.ConcurrentValidator$2.doWork(ConcurrentValidator.java:86)
>     at
> org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
>     at
> org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
>     at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
>     at java.util.concurrent.FutureTask.run(Unknown Source)
>     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
>     at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>     at java.lang.Thread.run(Unknown Source)
>
> 26-Oct-2013 12:04:52.161 SEVERE [http-nio-8080-exec-6]
> org.apache.catalina.core.StandardContext.listenerStop Exception sending
> context destroyed event to listener instance of class
> org.jboss.weld.environment.servlet.Listener
>  java.lang.NullPointerException
>     at
> org.jboss.weld.servlet.WeldInitialListener.contextDestroyed(WeldInitialListener.java:76)
>     at
> org.jboss.weld.servlet.api.helpers.ForwardingServletListener.contextDestroyed(ForwardingServletListener.java:30)
>     at
> org.jboss.weld.environment.servlet.Listener.contextDestroyed(Listener.java:86)
>     at
> org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4871)
>     at
> org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5499)
>     at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
>     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
>     at
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
>     at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)
>     at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:698)
>     at
> org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:968)
>     at
> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:456)
>     at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1534)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>     at java.lang.reflect.Method.invoke(Unknown Source)
>     at
> org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
>     at
> com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(Unknown Source)
>     at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(Unknown Source)
>     at
> org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1430)
>     at
> org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:704)
>     at
> org.apache.catalina.manager.ManagerServlet.doPut(ManagerServlet.java:430)
>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
>     at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
>     at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
>     at
> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
>     at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
>     at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
>     at
> org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
>     at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
>     at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
>     at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:221)
>     at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:107)
>     at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:616)
>     at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
>     at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:76)
>     at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:934)
>     at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:90)
>     at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:515)
>     at
> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1012)
>     at
> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:642)
>     at
> org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
>     at
> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
>     at
> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1555)
>     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
>     at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>     at java.lang.Thread.run(Unknown Source)
> --------
>
> 5.the pom.xml
> ------
> <?xml version="1.0"?>
> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="
> http://maven.apache.org/POM/4.0.0"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>grandscape</groupId>
>   <artifactId>prog_tomcat</artifactId>
>   <version>0.0.1-SNAPSHOT</version>
>   <packaging>war</packaging>
>   <name>prog_tomcat Maven Webapp</name>
>   <url>http://maven.apache.org</url>
>
>   <properties>
>         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>         <deltaspike.version>0.5</deltaspike.version>
>         <picketlink.version>2.5.2.Final</picketlink.version>
>   </properties>
>   <dependencies>
>         <dependency>
>             <groupId>junit</groupId>
>             <artifactId>junit</artifactId>
>             <version>4.11</version>
>             <scope>test</scope>
>         </dependency>
>         <dependency>
>             <groupId>com.sun.faces</groupId>
>             <artifactId>jsf-api</artifactId>
>             <version>2.2.4</version>
>         </dependency>
>         <dependency>
>             <groupId>com.sun.faces</groupId>
>             <artifactId>jsf-impl</artifactId>
>             <version>2.2.4</version>
>         </dependency>
>         <dependency>
>             <groupId>javax.enterprise</groupId>
>             <artifactId>cdi-api</artifactId>
>             <version>1.1</version>
>         </dependency>
>         <dependency>
>             <groupId>org.jboss.weld.servlet</groupId>
>             <artifactId>weld-servlet</artifactId>
>             <version>2.0.4.Final</version>
>         </dependency>
>         <dependency>
>             <groupId>log4j</groupId>
>             <artifactId>log4j</artifactId>
>             <version>1.2.17</version>
>             <scope>compile</scope>
>         </dependency>
>         <dependency>
>             <groupId>org.slf4j</groupId>
>             <artifactId>slf4j-api</artifactId>
>             <version>1.7.5</version>
>             <scope>compile</scope>
>         </dependency>
>         <dependency>
>             <groupId>org.slf4j</groupId>
>             <artifactId>slf4j-log4j12</artifactId>
>             <version>1.7.5</version>
>             <scope>compile</scope>
>         </dependency>
>
>           <dependency>
>             <groupId>commons-logging</groupId>
>             <artifactId>commons-logging</artifactId>
>             <version>1.1.3</version>
>         </dependency>
>         <dependency>
>             <groupId>org.apache.deltaspike.core</groupId>
>             <artifactId>deltaspike-core-api</artifactId>
>             <version>${deltaspike.version}</version>
>             <scope>compile</scope>
>         </dependency>
>         <dependency>
>             <groupId>org.apache.deltaspike.core</groupId>
>             <artifactId>deltaspike-core-impl</artifactId>
>             <version>${deltaspike.version}</version>
>             <scope>runtime</scope>
>         </dependency>
>          <dependency>
>             <version>1.0.1.Final</version>
>             <groupId>org.hibernate.javax.persistence</groupId>
>             <artifactId>hibernate-jpa-2.0-api</artifactId>
>             <scope>provided</scope>
>         </dependency>
>
>         <dependency>
>             <groupId>org.hibernate</groupId>
>             <artifactId>hibernate-core</artifactId>
>             <version>4.2.6.Final</version>
>         </dependency>
>
>         <dependency>
>             <groupId>org.apache.deltaspike.modules</groupId>
>             <artifactId>deltaspike-jpa-module-api</artifactId>
>             <version>${deltaspike.version}</version>
>             <scope>compile</scope>
>         </dependency>
>         <dependency>
>             <groupId>org.apache.deltaspike.modules</groupId>
>             <artifactId>deltaspike-jpa-module-impl</artifactId>
>             <version>${deltaspike.version}</version>
>             <scope>runtime</scope>
>         </dependency>
>     </dependencies>
>    <repositories>
>         <repository>
>         <id>people.apache.snapshots</id>
>         <url>
>             http://repository.apache.org/content/groups/snapshots-group/
>         </url>
>         <releases>
>             <enabled>false</enabled>
>         </releases>
>         <snapshots>
>             <enabled>true</enabled>
>         </snapshots>
>         </repository>
>     </repositories>
>      <pluginRepositories> <pluginRepository>
>     <id>apache.snapshots</id>
>     <name>Apache Snapshots</name>
>     <url>
>         http://repository.apache.org/content/groups/snapshots-group/
>     </url>
>     <releases>
>         <enabled>false</enabled>
>     </releases>
>     <snapshots>
>         <enabled>true</enabled>
>     </snapshots>
> </pluginRepository></pluginRepositories>
>   <build>
>     <finalName>prog_tomcat</finalName>
>     <plugins>
>         <plugin>
>           <groupId>org.apache.tomcat.maven</groupId>
>           <artifactId>tomcat7-maven-plugin</artifactId>
>           <version>2.1</version>
>           <configuration>
>           <server>mytomcat</server>
>           <url>http://localhost:8080/manager/text</url>
>         <contextReloadable>true</contextReloadable>
>           </configuration>
>         </plugin>
>     </plugins>
>   </build>
> </project>
>
> thanks everyone !!!

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message