-
1. Re: Entity Manager null
js8523 Mar 3, 2006 4:12 AM (in response to neillane)Make sure that you have the seam servlet filter invoked before your filter and that you pass it conversationid as a parameter. See the documentation on the SeamServletFilter.
the entry in the web.xml is this.<filter> <filter-name>Seam Servlet Filter</filter-name> <filter-class>org.jboss.seam.servlet.SeamServletFilter</filter-class> </filter> <filter-mapping> <filter-name>Seam Servlet Filter</filter-name> <url-pattern>/servlet/*</url-pattern> </filter-mapping>
Hope this resolves your issue,
James -
2. Re: Entity Manager null
neillane Mar 6, 2006 5:33 AM (in response to neillane)Hi James
I have changed the servlet mapping to be /servlet/.... and added the filter code to the web.xml file in my application as per your code snippet.
I am able to call the doPost method in my servlet which in turn callsEnvelopeUploadBean uploader = null; try { uploader = new EnvelopeUploadBean(); } catch (Exception e) { e.printStackTrace(); } String result = uploader.uploadEnvelope(inputStream);
This then runs everything in the *bean* correctly.
However - I am still unable to get the EntityManager (it is still null when I am trying to persist the data to my database)
I have searched the reference docs for info on the SeamServletFilter and how to use it with very little success.
If possible, could you explain, or point me in right dicetion as to how to involk the filter and make it possible for me to use the EntityManager
Thanks
Neil -
3. Re: Entity Manager null
andy.2003 Mar 6, 2006 6:10 AM (in response to neillane)I'd got this porblems as well, while trying to inject the Entitymanager, my Problem was, that the bean accessing the EntityManager wasn't an ejb3 sessionbean. So this solved my problem:
@Stateless public class foo{ @PersistentContext EntityManager em ... }
after making the Bean a Sessionbean the EntityManager was injected correctly -
4. Re: Entity Manager null
neillane Mar 6, 2006 6:40 AM (in response to neillane)I have the following
@Stateless @Name("envelopeUpload") public class EnvelopeUploadBean implements EnvelopeUpload, Serializable { @PersistenceContext private EntityManager em; .....
I have even tried with the unit name of the context ( the DS) and that doesnt work either.
The other Objects that I am injecting are working fine. I can get the Object the I am going to persist and set all the vars. -
5. Re: Entity Manager null
andy.2003 Mar 6, 2006 7:16 AM (in response to neillane)did you set up the datasource the right way? (persistence.xml etc.)
-
6. Re: Entity Manager null
neillane Mar 6, 2006 8:42 AM (in response to neillane)I would think so.
All the other functions of retrieving data from the database and displaying it in datatables are working fine in my web app. It is just the bean that is called by the servlet, where the em is null and I cant seem to instantiate it.
The persistance.xml<persistence> <persistence-unit name="NerveCentre-DS"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>java:/NerveCentreDS</jta-data-source> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/> <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/> <property name="hibernate.transaction.flush_before_completion" value="true"/> <property name="hibernate.hbm2ddl.auto" value="create-drop"/> <property name="hibernate.show_sql" value="true"/> </properties> </persistence-unit> </persistence>
The DS<?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>NerveCentreDS</jndi-name> <connection-url>jdbc:mysql://127.0.0.1:3306/nerve-centre</connection-url> <driver-class>com.mysql.jdbc.Driver</driver-class> <user-name>root</user-name> <password></password> <exception-sorter-class-name> org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter </exception-sorter-class-name> <metadata> <type-mapping>mySQL</type-mapping> </metadata> </local-tx-datasource> </datasources>