[EJB3] - Cant inject Bean class into Restfull WebService (JAX-RS)
by ha so
ha so [https://community.jboss.org/people/haso] created the discussion
"Cant inject Bean class into Restfull WebService (JAX-RS)"
To view the discussion, visit: https://community.jboss.org/message/821240#821240
--------------------------------------------------------------
I'm trying to save data acquired by Rest web service to database using hibernate/persistence.
In one of my web modules i implemented that service. Database ejb connector is placed in EJB module. They are parts of EAR application.
Every time when i call pb.addDevice() im getting java.lang.NullPointerException when puting proper url with params in browser(worked till i wanted to save it to Database). Can't find what is wrong with it. I'm using jboss 6.1.0 Final.
PS. when i changed from
@EJB
PersistenceBean pb;
to
PersistenceBean pb = new PersistenceBean();
i got null pointer on EntityManager em = emf.createEntityManager();
code:
@Stateless
@Path("/RestService")
public class RestPush {
@EJB
PersistenceBean pb;
@GET
@Path("/RegisterDevice")
public void registerDevice(
@QueryParam("deviceId") String deviceId){
Device d = new Device(true);
d.setId = deviceId;
pb.addDevice(d);
}
}
and EJB class:
@Stateless(mappedName = "PersistenceBean")
public class PersistenceBean {
@PersistenceUnit(unitName = "PersistentUnitName")
EntityManagerFactory emf;
private void persist(Object o, EntityManager entityManager) {
try {
entityManager.persist(o);
} catch (Exception e) {
logger.severe("Error writing to DB: " + e);
logger.severe("" + e.fillInStackTrace());
}
}
public void addDevice(Device d) {
try {
EntityManager em = emf.createEntityManager();
if (persist(device, em)) {
logger.info("Device with id : " + device.getId()
+ " has been added ");
} else {
logger.info("Failed to add device with id: " + device.getId());
} catch (Exception e) {
logger.severe("PersistenceBean: Could not save device.");
e.printStackTrace();
}
}
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/821240#821240]
Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
11 years, 7 months
[IronJacamar] - Is this the right project for a simple socket usecase?
by kaffeetrinker
kaffeetrinker [https://community.jboss.org/people/kaffeetrinker] created the discussion
"Is this the right project for a simple socket usecase?"
To view the discussion, visit: https://community.jboss.org/message/821211#821211
--------------------------------------------------------------
Hi there,
i stumbled over iron jacamar while searching for jca, but I'm not very familiar with jcaeither. I have a simple usecase:
The j2ee web project I'm working on needs to connect to a tcp socket, send/receive data and then close it. I could have done this within a singleton bean, but because I have to watch the socket inputstream, I have the need to create a thread for that. That said, I think it is not allowed to create threads within a j2ee container on my own. I also tried to use @Asynchronous for the socket function, but that resulted in multiple concurrence exceptions.
Now that i've read a little bit about jca and iron jacamar, I think maybe this is the right way to implement the socket connection. But for example, I could not find a sample with a while loop over the socket, that would notify my web project in case of an event.
Could you give me some hints what to use? So far I thought of creating an outbound jca (with the help of the eclipse plugin) and send event notifications to the web app via jms queue (because I could not find a sample of how to notify the resource client in case of an event).
Thank you!
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/821211#821211]
Start a new discussion in IronJacamar at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
11 years, 7 months
[JBoss Tools] - JBosstoolsVisualEditorFAQ
by Yahor Radtsevich
Yahor Radtsevich [https://community.jboss.org/people/yradtsevich] modified the document:
"JBosstoolsVisualEditorFAQ"
To view the document, visit: https://community.jboss.org/docs/DOC-10862
--------------------------------------------------------------
*Q: Which platforms are supported by* *Visual Editor?*
*A:* The list of supported platforms (and their IDs):
* Windows with Java 32-bit (win32.win32.x86)
* Windows with Java 64-bit (win32.win32.x86_64) - Experimental support is available in JBoss Tools 4.1.0.Beta1 and JBoss Developer Studio 7.0.0.Beta1.
To enable it, you need to install XULRunner from this update site: http://download.jboss.org/jbosstools/builds/staging/xulrunner-1.9.2_win64... http://download.jboss.org/jbosstools/builds/staging/xulrunner-1.9.2_win64....
Please comment https://issues.jboss.org/browse/JBIDE-2720 this JIRA if something went wrong.
* Linux x86 (gtk.linux.x86)
* Linux x86-64 (gtk.linux.x86_64)
* Mac OS X Cocoa with Java 32-bit (cocoa.macosx.x86)
* Mac OS X Carbon with Java 32-bit (carbon.macosx.x86) [not supported by JBoss Tools 3.3.0 and later, JBDS 5.0 and later]
In brief, Java 64-bit is supported on Linux only, on all other systems Visual Editor requires Java 32-bit.
*Q: Eclipse crashes when I use Visual Editor, what can I do?*
*A:* This may happen in JBoss Tools 3.3.0.M2 and above with Eclipse 3.7.0 due to https://issues.jboss.org/browse/JBIDE-9144 the WebKit and XULRunner conflict. You can disable Visual Editor by adding the option –Dorg.jboss.tools.vpe.loadxulrunner=false to the eclipse.ini (or jbdevstudio.ini if you use JBoss Developer Studio).
*Q: Visual Editor does not start under Linux*
*A:* Linux users may need to do the following to get the visual editor to work correctly on their machines.
* The Visual Page Editor (before JBoss Tools 3.1.0.M4) requires the library libstdc++.so.5. This library is contained in the compat-libstdc++-33.i386 package.
* To install this package on Fedora Core or Red Hat Enterprise Linux run the following command:
yum install compat-libstdc++-33.i386
** On any other rpm based distributions download libstdc++.so.5 and run the following command:
rpm -Uvh compat-libstdc++-33.i386
** On Debian and Debian based distributions (e.g. Ubuntu) run the following command:
apt-get install libstdc++5
* In case you have the library installed and you still have issue with starting the visual page editor then close all browser views/editors and leave one visual page editor open and restart eclipse. This should force a load of the right XULRunner viewer.
*Q: Visual Editor doesn't start at any platform and shows message 'The VPE editor can't be run because your system environment needs to be changed slightly'*
*A:* Check if you version of JBoss Developer Studio/JBoss Tools is compatible with you version of Eclipse, see the compatibility matrix https://community.jboss.org/docs/DOC-14297 http://www.jboss.org/community/wiki/Matrixofsupportedplatformsruntimesand...
*Q: Visual Editor starts OK, but the following message dialog appears:*
https://community.jboss.org/servlet/JiveServlet/showImage/102-10862-49-19... https://community.jboss.org/servlet/JiveServlet/downloadImage/102-10862-4...
*A:* Some functionality of Visual Editor may not work if a project doesn't have org.jboss.tools.jsf.jsfnature or org.jboss.tools.jst.web.kb.kbnature in .project configuration. To fix this problem and turn off the message box execute next steps:
* Right mouse button click on a project in Package Explorer.
* Select +Configure -> Add JSF Capabilities+ from the context menu.
* Configure your project using +Add JSF Capabilities+ wizard and press Finish.
*P.S.* If you are sure that your project does not need JSF capabilities, just disable this message box by checking "+Do not show this dialog again!+" checkbox.
*Q: Visual Part doesn't start and "XPCOM error -2147467259" is shown*
*A:* Something bad happened with buildin xulrunner. To check it you should:
* Go to Eclipse -> Help -> About -> Installation Details... -> Configuration
* find +org.eclipse.swt.browser.XULRunnerPath+ and open this path in terminal
* try xulrunner.exe -version or ./xulrunner -version and it should show what is needed for XR to work
--------------------------------------------------------------
Comment by going to Community
[https://community.jboss.org/docs/DOC-10862]
Create a new document in JBoss Tools at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=102&c...]
11 years, 7 months