[Installation, Configuration & DEPLOYMENT] - EntityManager Injection...
by repkin
I wanted the entitymanager have been injected by the container, I cant configure it. After a lot of trial, I decided to ask the question.
Here is the situation,
My ear file structure:
| surgeonfish.ear
| |----surgeonfish-ds.xml
| |----META-INF
| |----application.xml
| |----jboss-app.xml
| |----MANIFEST.MF
| |----surgeonfish.jar
| |----com.ao...
| |----META-INF
| |----persistence.xml
| |----MANIFEST.MF
| |----surgeonfish.war
| |----META-INF
| |----MANIFEST.MF
| |----WEB-INF
| |----classes
| |----lib
| |----web.xml
|
surgeonfish-ds.xml:
| <?xml version="1.0" encoding="UTF-8"?>
| <datasources>
| <local-tx-datasource>
| <jndi-name>time_reporting_data_source</jndi-name>
| <connection-url>jdbc:mysql://localhost:3306/timereporting</connection-url>
| <driver-class>com.mysql.jdbc.Driver</driver-class>
| <user-name>root</user-name>
| <password>test</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>
|
application.xml
| <application>
| <display-name>Surgeonfish</display-name>
| <module>
| <web>
| <web-uri>surgeonfish.war</web-uri>
| <context-root>/surgeonfish</context-root>
| </web>
| </module>
| <module>
| <ejb>surgeonfish.jar</ejb>
| </module>
| </application>
|
jboss-app.xml:
| <jboss-app>
| <module>
| <service>surgeonfish-ds.xml</service>
| </module>
| <loader-repository>
| surgeonfish:archive=surgeonfish.ear
| </loader-repository>
| </jboss-app>
|
Here my test bean:
| package com.ao...;
|
|
| import javax.ejb.Local;
| import javax.ejb.Stateless;
| import javax.persistence.EntityManager;
| import javax.persistence.EntityManagerFactory;
| import javax.persistence.Persistence;
| import javax.persistence.PersistenceContext;
| import org.apache.commons.logging.Log;
| import org.apache.commons.logging.LogFactory;
|
| @Stateless
| @Local(value=PrStaffInterface.class)
| public class PrStaffHome {
|
| private static final Log log = LogFactory.getLog(PrStaffHome.class);
|
| @PersistenceContext(unitName="time_report_persistence_context")
| private EntityManager entityManager;
|
| public PrStaff findById(Integer id) {
| log.debug("getting PrStaff instance with id: " + id);
| try {
| /*
| EntityManagerFactory emf = Persistence.createEntityManagerFactory("time_report_persistence_context");
| EntityManager em = emf.createEntityManager();
| PrStaff instance1 = em.find(PrStaff.class, id);
| ---this lines working without any error...---
| */
|
| PrStaff instance = entityManager.find(PrStaff.class, id);->I am taking null pointer exception here...
| System.out.println("instance:"+instance);
| log.debug("get successful");
| return instance;
| } catch (RuntimeException re) {
| log.error("get failed", re);
| throw re;
| }
| }
| }
|
I cant find reason, why container is not injecting the entity manager. Of course I am missing something but I cant find. Thanks for your helps...
--EXCEPTION STACKTRACE--
------------------------------------------------------------------------
2008-06-17 17:25:40,256 ERROR [com.ao.utils.pojo.PrStaffHome] get failed
java.lang.NullPointerException
at com.ao.utils.pojo.PrStaffHome.findById(PrStaffHome.java:74)
at com.ao.jdbc.DBSecurity.checkUserPassword(DBSecurity.java:104)
at com.ao.timereport.servlet.TIMEController.doLogin(TIMEController.java:550)
at com.ao.timereport.servlet.TIMEController.service(TIMEController.java:58)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
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:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:595)
2008-06-17 17:25:40,287 ERROR [STDERR] java.lang.NullPointerException
2008-06-17 17:25:40,303 ERROR [STDERR] at com.ao.utils.pojo.PrStaffHome.findById(PrStaffHome.java:74)
2008-06-17 17:25:40,303 ERROR [STDERR] at com.ao.jdbc.DBSecurity.checkUserPassword(DBSecurity.java:104)
2008-06-17 17:25:40,303 ERROR [STDERR] at com.ao.timereport.servlet.TIMEController.doLogin(TIMEController.java:550)
2008-06-17 17:25:40,303 ERROR [STDERR] at com.ao.timereport.servlet.TIMEController.service(TIMEController.java:58)
2008-06-17 17:25:40,303 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
2008-06-17 17:25:40,303 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
2008-06-17 17:25:40,303 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2008-06-17 17:25:40,303 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
2008-06-17 17:25:40,303 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
2008-06-17 17:25:40,303 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2008-06-17 17:25:40,318 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
2008-06-17 17:25:40,318 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
2008-06-17 17:25:40,318 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
2008-06-17 17:25:40,318 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
2008-06-17 17:25:40,318 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
2008-06-17 17:25:40,318 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
2008-06-17 17:25:40,318 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
2008-06-17 17:25:40,318 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
2008-06-17 17:25:40,318 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
2008-06-17 17:25:40,334 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
2008-06-17 17:25:40,334 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
2008-06-17 17:25:40,334 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
2008-06-17 17:25:40,334 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4158893#4158893
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4158893
17 years, 10 months
[Management, JMX/JBoss] - How can I receive notification when Servlet stats change ?
by francis1970
Hi all !
I'd need to add a notification listener that warns me when Servlet stats change. Until now I have been using successfully this code for my MBeans notifications
NotificationListener notificationListener = new NotificationListener() {
| public void handleNotification(Notification notification, Object handback) {
| System.out.println("Notification received!");
| System.out.println("UserObject: " + notification.getUserData());
| }
| };
| try {
|
| ArrayList servers = MBeanServerFactory.findMBeanServer(null);
| if (servers == null)
| throw new Exception("No MBeanServer found.");
| MBeanServer server = (MBeanServer)servers.get(0);
|
| // find the local MBeanServer
| ObjectName objectName = new ObjectName("jboss.management.local:J2EEApplication=null,J2EEServer=Local,WebModule=stats.war,j2eeType=Servlet,name=ControllerServlet");
| server.addNotificationListener(objectName, notificationListener, null, null);
|
| Thread.sleep(20000);
| } catch (MalformedObjectNameException ex) {
| // manage
| } catch (InstanceNotFoundException ex) {
| // manage
| }
Anyway once I have registered to my Servlet nothing happens, even if the stats change (because I invoke my Servlet).
How can I get notification when my Servlet "ControllerServlet" is invoked ?
Thanks a lot
Francesco
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4158892#4158892
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4158892
17 years, 10 months
[Beginners Corner] - Re: Does Jboss support PHP?
by vikramap
Hi Peter ,
Thanks for the reply.
I am explaining the steps that I tried, to make PHP script run on JBoss Application Server on WINDOWS XP Operating System.
1. Download & Extract Jboss Application server on to a local drive(say C:\ drive ).
2. Download & Extract php5servlet-windows-i586-SP1.zip(the PHP module) to C: drive.
3. Created a folder âphp5â under C:
4. copied c:\php5servlet-windows-i586-SP1\PHP\* to c:\php5.
(now âphp5â folder has a âbinâ folder inside it).
5. Made a copy of the C:\php5\bin\php.ini-recommended to %WINDIR%\php.ini. (%WINDIR% is nothing but C:\WINDOWS)
6. Opened %WINDIR%\php.ini and changed extension_dir value to c:/php5/bin/ext/.
7. Edited the server\default\deploy\jboss-web.deployer/server.xml
(Added the following lines in the server.xml)
8. Edited the server\default\deploy\jboss-web.deployer\conf/web.xml to work with the php servlet .
(Added the following lines in web.xml)
<servlet-name>php</servlet-name>
<servlet-class>org.jboss.web.php.Handler</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>6</load-on-startup>
<servlet-name>phps</servlet-name>
<servlet-class>org.jboss.web.php.Highlight</servlet-class>
<servlet-mapping>
<servlet-name>php</servlet-name>
<url-pattern>*.php</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>phps</servlet-name>
<url-pattern>*.phps</url-pattern>
</servlet-mapping>
10. Added one line in the <welcome-file-list> element:<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.php</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
11. I have set the environment variables:
JAVA_HOME=<PATH TO YOUR JDK INSTALLATION>
PHP_HOME=c:\php5 PATH=%PATH%;%JAVA_HOME%\bin;%PHP_HOME%\bin;%PHP_HOME%\bin\ext;
And .\server\default\deploy\jboss-web.deployer, has jbossweb-extras.jar
12. I have created a simple php script <?php phpinfo(); ?> in index.php file and have copied it under .\server\default\deploy\ROOT.war
I am getting the following error:
java.lang.UnsatisfiedLinkError: Can't find SAPI class, no libphp5servlet in java.library.path
please note:
I have installed Java Native. I have downloaded java Native âjboss-native-2.0.4-windows-x86-sslâ.(is that the correct native ??)I copied the contents of folder âbinâ to Jboss_home/bin.
Could you please guide me in running php script on Jboss Application Server?
Where is libphp5servlet? I dint find any libphp5servlet in PHP module or Java Native.
Thanks in advance.
vikram
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4158883#4158883
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4158883
17 years, 10 months