Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't call EJB from FLEX (BlazeDS)
    text
    copied!<p>Right now I'm playing with Flex and Java integration and trying to access EJB3 methods by clicking Flex button but it's giving me null pointer error.</p> <p>Here is what I have in my code:</p> <p>[Controller:] </p> <pre><code>public class homePageController { @EJB CategoryFacadeRemote categoryFacade; public String populateDBWithXMLData(){ ArrayList&lt;Category&gt; cats = new ArrayList&lt;Category&gt;(); cats = new QuestionsUtil().getCategories(); try{ categoryFacade.createMany(cats); } catch(EJBException ex){ ex.printStackTrace(); } System.out.println("SIZE: " + cats.size()); return "HIIIIII"; } } </code></pre> <p>[CategoryFacade]</p> <pre><code>@Stateless public class CategoryFacade implements CategoryFacadeLocal, CategoryFacadeRemote { @PersistenceContext private EntityManager em; public void create(Category category) { em.persist(category); } public void createMany(ArrayList&lt;Category&gt; categories){ for(int i = 0; i &lt; categories.size(); i++){ create(categories.get(i)); } } ... } </code></pre> <p>[Remote-config.xml]</p> <pre><code>... &lt;destination id="homePageController"&gt; &lt;properties&gt; &lt;source&gt;homePageController&lt;/source&gt; &lt;/properties&gt; &lt;/destination&gt; ... </code></pre> <p>[Flex App. File]</p> <pre><code>... &lt;mx:RemoteObject id="hcRO" destination="homePageController"&gt;&lt;/mx:RemoteObject&gt; &lt;mx:Script&gt; ... private function callHomePageController():void{ hcRO.addEventListener(ResultEvent.RESULT, hcROResultHandler); hcRO.addEventListener(FaultEvent.FAULT, hcROFaultHandler); hcRO.populateDBWithXMLData(); } private function hcROResultHandler(eve:ResultEvent):void{ Alert.show("RESULT:" + eve.message.body.toString()); } private function hcROFaultHandler(eve:FaultEvent):void{ Alert.show("FAULT:" + eve.message.toString()); } ]]&gt; &lt;/mx:Script&gt; &lt;mx:Button x="148" y="222" label="homePageController" click="callHomePageController()" width="262" height="43"/&gt; &lt;/mx:Application&gt; </code></pre> <p>The program works fine if I take out the call to EJB. I'm sure that the solution is easy but I can't figure it out.</p> <p>By the way, I'm using Glassfish as my app. server. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload