Topic
6 replies Latest Post - ‏2010-05-26T03:58:49Z by ishakteyran
ishakteyran
ishakteyran
4 Posts
ACCEPTED ANSWER

Pinned topic creating my SCA application fails :(

‏2010-05-17T11:13:40Z |
hello to all,

i am trying to understand SCA concepts and after reading and doing what the "SCA Java EE tutorial" that ships with Ratinal Application Developer 7.5.5 Help ->Tutorials, i decided to make a similar scenario of myself, in which the difference from the tutorial would be i would use only one EAR and and it would be SCA-enabled. so, here are the steps i followed to accomplish my goal :

1-) i created an SCA-enabled EAR application named "scaEAR".
2-) i created an SCA-enabled, JSF and JPA enabled web project named "web".
3-) i created my entities which are only Parent and Child entities.
here is my persistence.xml :

<?xml version=
"1.0" encoding=
"UTF-8"?> <persistence version=
"1.0" 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_1_0.xsd"> <persistence-unit name=
"web"> <jta-data-source>java:comp/env/PARENT</jta-data-source> <class>entities.Child</class> <class>entities.Parent</class> </persistence-unit> </persistence>


4-) then i created the service interface which is as follows :




package service.interfaces;     

import org.osoa.sca.annotations.Remotable; 

import entities.*;   @Remotable 

public 

interface AddParent 
{ 

public String addParenttoChild(Parent p, Child c); 
}


5-) and the service implementation :




package service.impl;   

import javax.persistence.EntityManagerFactory; 

import javax.persistence.Persistence;   

import org.osoa.sca.annotations.Service;   

import entities.*; 

import entities.controller.*;   

import service.interfaces.AddParent;   @Service(service.interfaces.AddParent.class) 

public 

class AddparentImpl 

implements AddParent 
{   @Override 

public String addParenttoChild(Parent p, Child c) 
{ 
// TODO Auto-generated method stub EntityManagerFactory emf=Persistence.createEntityManagerFactory(
"web"); ParentManager pm = 

new ParentManager(emf); ChildManager cm=

new ChildManager(emf); Parent par = pm.findParentById(p.getId()); Child ch=cm.findChildById(c.getId()); par.getChildCollection().add(ch); ch.setParentid(par); 

try 
{ cm.updateChild(ch); pm.updateParent(par); 
} 

catch (Exception e) 
{ 
// TODO Auto-generated catch block 

return 
"Mission FAILED"; 
} 

return 
"Mission ACCOMPLISHED"; 
}   
}


6-) i created index.jsp page in my web application :
with the following code :


<!DOCTYPE HTML PUBLIC 
"-//W3C//DTD HTML 4.01 Transitional//EN"> <%-- jsf:pagecode language=
"java" location=
"/src/pagecode/Index.java" --%><%-- /jsf:pagecode --%><%@page language=
"java" contentType=
"text/html; charset=ISO-8859-1" pageEncoding=
"ISO-8859-1"%> <%@taglib uri=
"http://java.sun.com/jsf/core" prefix=
"f"%> <%@taglib uri=
"http://www.ibm.com/jsf/html_extended" prefix=
"hx"%> <%@taglib uri=
"http://java.sun.com/jsf/html" prefix=
"h"%> <html> <head> <title>index</title> <meta http-equiv=
"Content-Type" content=
"text/html; charset=ISO-8859-1"> <meta name=
"GENERATOR" content=
"Rational Software Architect for WebSphere Software"> <link rel=
"stylesheet" type=
"text/css" title=
"Style" href=
"theme/stylesheet.css"> </head> <f:view> <body ><hx:scriptCollector id=
"scriptCollector1"> <h:form styleClass=
"form" id=
"form1"> <hx:commandExButton type=
"submit" value=
"Submit" styleClass=
"commandExButton" id=
"button1" action=
"#{pc_Index.doButton1Action}"></hx:commandExButton> </h:form> </hx:scriptCollector></body> </f:view> </html>


7-) then in the page code file index.java i added the service reference and and the implementation of the button action as follows :


/** * */ 

package pagecode;   

import com.ibm.faces.component.html.HtmlScriptCollector; 

import javax.faces.component.html.HtmlForm; 

import org.osoa.sca.annotations.Reference;   

import com.ibm.faces.component.html.HtmlCommandExButton;   

import entities.Child; 

import entities.Parent; 

import entities.controller.ChildManager; 

import entities.controller.ParentManager;   

import service.interfaces.*; 

import java.util.List; 

import com.ibm.jpa.web.JPA;   
/** * @author isaac * */ 

public 

class Index 

extends PageCodeBase 
{ @Reference AddParent addParentRef; 

protected HtmlScriptCollector scriptCollector1; 

protected HtmlForm form1; 

protected HtmlCommandExButton button1;   

private List<Child> childList;   

protected HtmlScriptCollector getScriptCollector1() 
{ 

if (scriptCollector1 == 

null) 
{ scriptCollector1 = (HtmlScriptCollector) findComponentInRoot(
"scriptCollector1"); 
} 

return scriptCollector1; 
}   

protected HtmlForm getForm1() 
{ 

if (form1 == 

null) 
{ form1 = (HtmlForm) findComponentInRoot(
"form1"); 
} 

return form1; 
}   

protected HtmlCommandExButton getButton1() 
{ 

if (button1 == 

null) 
{ button1 = (HtmlCommandExButton) findComponentInRoot(
"button1"); 
} 

return button1; 
}   

public String doButton1Action() 
{ 
// Type Java code that runs when the component is clicked 
// TODO: Return outcome that corresponds to a navigation rule System.out.println(
'A'); ParentManager pm = (ParentManager) getManagedBean(
"parentManager"); ChildManager cm = (ChildManager) getManagedBean(
"childManager"); Parent p=pm.findParentById(
"3"); Child c = cm.findChildById(
"18"); String s= addParentRef.addParenttoChild(p, c); System.out.println(s); 

return s; 
}   @JPA(targetEntityManager = entities.controller.ChildManager.class, targetNamedQuery = 
"getChild") 

public List<Child> getChildList() 
{ 

if (childList == 

null) 
{ ChildManager childManager = (ChildManager) getManagedBean(
"childManager"); childList = childManager.getChild(); 
} 

return childList; 
}   
}


after preparing all these

8-) i opened the scaEAR file and added a distuinguished application composite with target namespace http://temp and into it added a component named "component"
8-a) the component has only a reference named addParentRef, and it is promoted, the promoted reference also has the same name.
8-b) both the reference of the component and the promoted reference use the interface i created in web application named "web".
8-c) the implementation type of the component is web, and it uses as implementation my web application called "web".

9-) then i created an SCA project named "sca" and from project references i added scaEAR project to teh references of the "sca" project.

and i copied the interface package from web application to the src folder of my sca application.

and as the sca application couldnt resolve my Parent and Child entity classes defined in web application, i added the web application to the build path of the sca project.

10-) then i created a conventional composite with target namespace http://temp and into it i created two components.
11-) the first component is called Consumer and has a reference named addParentRef and it has interface i defined in my web application. and the implementation type for this component is JEE and the implementation is scaEAR project.
12-) the second component is called Provider and it has a service named addParentService and it has the same interface of the reference of the Consumer component. and wired the reference of the Consumer to the service of the Provider component. and the implmenetation type for this component is Java and the class is my AddparentImpl.java class. However i also tried with making the implementation of the component JEE and give scaEAR as the implementation, but it didnt work neither.
13-)then in sca project , i created a contribution and added the conventional composite into the contribution.
14-) finally i deployed the sca project into my webspshere test environment, however, it gave an error of something like, either a composition already exists or its depencies are missing, so i made a search on google, and i found the topic about removing the sca composites from WAS, and i removed the existing composites and try again, but again it didnt work, so it meant to me some of the dependencies are missing. however in SCA Java EE tutorial, everthing was made as i also did in my case, but it didnt work, then i tried to change the interface of the references and services in all components ( well, here i must confess that maybe i couldnt make all of them the same interface, i mean the interface in web application, or the interface in sca application, also i am not sure if it matters, because the interface is same in both situation, if not please let me know)to be the one in web application instead of the sca application, and also i changed the implementation of the Provider component from Java to JEE and back from JEE to Java, but it never worked. :(

now it doesnt even deploy by giving the error,

The contribution, sca, contains validation errors. Correct the errors in the Problems view before publishing the contribution on the server. If you want to allow contributions containing errors to be published on the server, enable the Allow applications containing errors to be published on a server check box (Windows > Preferences > Servers > WebSphere). *The 
"addParentService" service is not defined by the implementation.*


so , finally the help i need is to learn why these errors occur, and how i can fix them. and if i am doing any conventional mistake of SCA, please correct me and help me to accomplish my scenario of this SCA service implementation,

thank you all.
Updated on 2010-05-26T03:58:49Z at 2010-05-26T03:58:49Z by ishakteyran
  • SystemAdmin
    SystemAdmin
    126 Posts
    ACCEPTED ANSWER

    Re: creating my SCA application fails :(

    ‏2010-05-20T03:03:57Z  in response to ishakteyran
    Hi, could you try the following steps?

    1. Go to Export -> Service Component Architecture -> SCA Archive File, export project 'sca' as an SCA archive file, say 'sca.jar'

    2. Export project 'scaEAR' as an EAR, say 'scaEAR.ear'

    3. launch WAS 7.0 Adminconsole

    4. go to Applications -> Application types -> Assets, import both sca.jar and scaEAR.ear

    5. go to Applications -> Application types -> Business-level applications, new a BLA, say 'scaBLA'

    6. click on 'scaBLA', select Add -> Add Asset to create composition units for sca.jar and scaEAR.ear

    7. start 'scaBLA'

    Please let me know where 'scaBLA' is started successfully. If not, what is the error?
    • ishakteyran
      ishakteyran
      4 Posts
      ACCEPTED ANSWER

      Re: creating my SCA application fails :(

      ‏2010-05-20T15:42:16Z  in response to SystemAdmin
      hello zhousean,
      thank you for your reply, i will try it what you suggested now, but i want to ask why such steps were not necessary in the Java EE SCA tutorial of RAD, in that tutorial, when i do the steps i told in my post, everything was fine, could that be SCA currently supports only Stateless beans ?? i dont know if my question is nonsense or not, but the only difference i made was using only one EAR file from the tutorial. and as you can see from the image in the attachment, there is an error which says the service is not defined by the implementation. So i dont know if it will really work, but right now, i will try and let you know about the result.

      One who doesnot try to be better, cannot remain as good neither.
    • ishakteyran
      ishakteyran
      4 Posts
      ACCEPTED ANSWER

      Re: creating my SCA application fails :(

      ‏2010-05-20T16:10:30Z  in response to SystemAdmin
      hi zhousean ,

      i tried to add teh sca.jar to scaBLA but after i clicked finished when all settings are done, here is the error, i received which said operation failed. so i couldnt, even try starting scaBLA.

      *The error : *
      
      com.ibm.wsspi.management.bla.op.OpExecutionException: CWSAM0105E: The following Service Component Architecture (SCA) Validation errors caused the CreateScaCodeGen step to fail: 2 Service not found 
      
      for component service: Component = Provider Service = addParentService Service not found 
      
      for component service: Component = Provider Service = addParentService   5/20/10 7:08:08 PM GMT+03:00 Completed res=[]   Operation failed.
      


      One who doesnot try to be better, cannot remain as good neither.
  • SystemAdmin
    SystemAdmin
    126 Posts
    ACCEPTED ANSWER

    Re: creating my SCA application fails :(

    ‏2010-05-26T03:26:59Z  in response to ishakteyran
    Hi ishakteyran, there are two reasons I suggested you to try those step. First I would like to see how your contribution deploys to the WAS server outside of RAD, ruling out potential RAD tooling issues. Second I wanted to see what error adminconsole shows if the contribution fails to deploy. By looking at your results, your contribution fails to deploy outside of RAD as well and the error is the component service is not found in the implementation.

    I can your component service name is "addParentService" which doesnt match your service interface name "AddParent". This is probably causing the error. To resolve it, you may simply change the service name to "AddParent".

    In fact, I am curious whether you see any validation errors or warning in RAD. This is something that should be caused by RAD.
  • SystemAdmin
    SystemAdmin
    126 Posts
    ACCEPTED ANSWER

    Re: creating my SCA application fails :(

    ‏2010-05-26T03:29:54Z  in response to ishakteyran
    I meant "This is something that should be caught by RAD." in my above reply :-)
    • ishakteyran
      ishakteyran
      4 Posts
      ACCEPTED ANSWER

      Re: creating my SCA application fails :(

      ‏2010-05-26T03:58:49Z  in response to SystemAdmin
      hi zhousean, as you can see in the end part of my first post of this topic, i already tell that RAD gives in problems view an error that service is not defined by implementation. and also when trying to deploy it gives the same error and doesnot deploy to Websphere Test environment.

      i will rename the service and then will try to see , and will write back the result.
      One who doesnot try to be better, cannot remain as good neither.