Just for future reference Edgar, the stack trace printed in the
browser represents the call stack of functions that led to the
exception. In this case, the last item that fired off was publish() in
AddBusiness.java line 76. You can use this technique to track down
most problems in java. good luck

On Thu, Apr 18, 2013 at 4:20 PM, Edgar Orduña <[email protected]> wrote:
> Hi
> Good news, my servlet is running perfectly, you were right Kurt when I added
> the uddi.xml in the WEB-INF/classes/META-INF directory my servlet ran.
> Thanks for your help
>
>
> 2013/4/18 Kurt T Stam <[email protected]>
>>
>> Edgar, try adding the uddi.xml in the WEB-INF/classes/META-INF directory
>>
>>
>> On 4/18/13 2:03 PM, Kurt T Stam wrote:
>>
>> Edgar,
>>
>> Code doesn't "skip", unless there is an exception thrown, and only if you
>> have an exception the catch block is run. So you clearly have an exception!
>>
>> So you need to figure what kind off exception it is; printing the stack
>> trace would be a good start: add something like e.printStrackTrace() in the
>> catch block, the error message should tell you what's going wrong, but if
>> you can't figure it our just send us the output of the stack trace; without
>> that we cannot help you.
>>
>> Good luck,
>>
>> --Kurt
>>
>> 2. If you do not have an exception you are stepp
>>
>> On 4/18/13 1:34 PM, Edgar Orduña wrote:
>>
>> I have this error, but i dont understand why, because i have the uddi.xml
>> file in the META-INF and when I run the example on console I dont have
>> problem but when I run like a servlet I have the problem
>>
>>
>> 2013/4/18 Edgar Orduña <[email protected]>
>>>
>>>  I already know what is the problem, the problem is the try block in the
>>> constructor, when i run the source code from servlet  the block of the
>>> constructor  doesn't run the try block  only the catch block and this is the
>>> root cause of my problem, because the variables are not initialized.
>>>
>>> do you have any suggestion?
>>> what do you think about this problem?
>>>
>>> this is the block source code
>>>
>>>
>>>  public ServletPublish() {
>>>         try {
>>>             String clazz = UDDIClientContainer.getUDDIClerkManager(null).
>>>
>>> getClientConfig().getUDDINode("default").getProxyTransport();
>>>             Class<?> transportClass = ClassUtil.forName(clazz,
>>> Transport.class);
>>> if (transportClass!=null) {
>>> Transport transport = (Transport) transportClass.
>>> getConstructor(String.class).newInstance("default");
>>>
>>> security = transport.getUDDISecurityService();
>>> juddiApi = transport.getJUDDIApiService();
>>> publish = transport.getUDDIPublishService();
>>> }
>>> }
>>>
>>>                catch (Exception e) {
>>>
>>> e.printStackTrace();
>>> }
>>> }
>>>
>>>
>>>
>>> Thanks
>>>
>>>
>>> 2013/4/16 Alex O'Ree <[email protected]>
>>>>
>>>> Can you try putting e.printStackTrace() within the catch block? or
>>>> logging it somehow. Obviously there is an error somewhere that's not being
>>>> recorded. You can also try adding some stub statements throughout the
>>>> function, such as out.write("1"); periodically until you narrow down which
>>>> line bombed.
>>>>
>>>> or, remove the try/catch within the function and change the function to
>>>> 'throws Exception'
>>>>
>>>> or attach the debugger and step through it.
>>>>
>>>> You're probably missing the uddi.xml file within META-INF of your source
>>>> packages. It defines the location of the uddi services, username, password,
>>>> etc
>>>>
>>>>
>>>>
>>>> On Apr 16, 2013 12:11 PM, "Edgar Orduña" <[email protected]> wrote:
>>>>>
>>>>> the browser prints the part of "catch", it doesn´t print the part of
>>>>> "try".
>>>>> It prints "error":
>>>>>
>>>>> catch (Exception e) {
>>>>>
>>>>>                     out.println("<div id=\"cuerpo2\">"
>>>>>                             +"error"
>>>>>                             +"<br>"+ nom +""
>>>>>                     +"</div>");
>>>>>
>>>>>
>>>>>                 e.printStackTrace();
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>> 2013/4/16 Alex O'Ree <[email protected]>
>>>>>>
>>>>>> what is printed to the browser?
>>>>>>
>>>>>> On Mon, Apr 15, 2013 at 11:05 PM, Edgar Orduña <[email protected]>
>>>>>> wrote:
>>>>>> > i have the jars and i dont have idea what happen, this is the code
>>>>>> > of my
>>>>>> > example and when i run my example only the source code from "catch"
>>>>>> > runs.
>>>>>> >
>>>>>> > Thanks
>>>>>> >
>>>>>> > import java.io.IOException;
>>>>>> > import java.io.PrintWriter;
>>>>>> > import javax.servlet.ServletException;
>>>>>> > import javax.servlet.http.HttpServlet;
>>>>>> > import javax.servlet.http.HttpServletRequest;
>>>>>> > import javax.servlet.http.HttpServletResponse;
>>>>>> > import org.uddi.api_v3.*;
>>>>>> > import org.apache.juddi.ClassUtil;
>>>>>> > import org.apache.juddi.api_v3.*;
>>>>>> > import org.apache.juddi.v3.client.config.UDDIClientContainer;
>>>>>> > import org.apache.juddi.v3.client.i18n.EntityForLang;
>>>>>> > import org.apache.juddi.v3.client.transport.Transport;
>>>>>> > import org.uddi.v3_service.UDDISecurityPortType;
>>>>>> > import org.uddi.v3_service.UDDIPublicationPortType;
>>>>>> > import org.apache.juddi.v3_service.JUDDIApiPortType;
>>>>>> >
>>>>>> >
>>>>>> > public class ServletPublish extends HttpServlet {
>>>>>> >
>>>>>> >     private static UDDISecurityPortType security = null;
>>>>>> >     private static JUDDIApiPortType juddiApi = null;
>>>>>> >     private static UDDIPublicationPortType publish = null;
>>>>>> >     String Name;
>>>>>> >
>>>>>> >   public ServletPublish() {
>>>>>> >         try {
>>>>>> >             String clazz =
>>>>>> > UDDIClientContainer.getUDDIClerkManager(null).
>>>>>> >
>>>>>> > getClientConfig().getUDDINode("default").getProxyTransport();
>>>>>> >             Class<?> transportClass = ClassUtil.forName(clazz,
>>>>>> > Transport.class);
>>>>>> > if (transportClass!=null) {
>>>>>> > Transport transport = (Transport) transportClass.
>>>>>> > getConstructor(String.class).newInstance("default");
>>>>>> >
>>>>>> > security = transport.getUDDISecurityService();
>>>>>> > juddiApi = transport.getJUDDIApiService();
>>>>>> > publish = transport.getUDDIPublishService();
>>>>>> > }
>>>>>> > } catch (Exception e) {
>>>>>> >
>>>>>> > e.printStackTrace();
>>>>>> > }
>>>>>> > }
>>>>>> >
>>>>>> >         @Override
>>>>>> >     protected void doGet(HttpServletRequest request,
>>>>>> > HttpServletResponse
>>>>>> > response) throws ServletException, IOException
>>>>>> >     {
>>>>>> >
>>>>>> >             Name = request.getParameter("nombre");
>>>>>> >             ServletPublish sp = new ServletPublish();
>>>>>> >             sp.publish(Name, response);
>>>>>> >
>>>>>> >
>>>>>> >     }
>>>>>> >
>>>>>> >      @Override
>>>>>> >     protected void doPost(HttpServletRequest request,
>>>>>> > HttpServletResponse
>>>>>> > response) throws ServletException, IOException
>>>>>> >     {
>>>>>> >         // TODO Auto-generated method stub
>>>>>> >         doGet(request,response);
>>>>>> >
>>>>>> >
>>>>>> >     }
>>>>>> >
>>>>>> >      public void publish(String nom, HttpServletResponse
>>>>>> > response)throws
>>>>>> > ServletException, IOException {
>>>>>> >          response.setContentType("text/html;charset=UTF-8");
>>>>>> >          PrintWriter out = response.getWriter();
>>>>>> >
>>>>>> >          try{
>>>>>> >          // Setting up the values to get an authentication token for
>>>>>> > the
>>>>>> > 'root' user ('root' user has admin privileges
>>>>>> > // and can save other publishers).
>>>>>> >
>>>>>> >                 GetAuthToken getAuthTokenRoot = new GetAuthToken();
>>>>>> >                 getAuthTokenRoot.setUserID("root");
>>>>>> >                 getAuthTokenRoot.setCred("root");
>>>>>> >
>>>>>> >                 // Making API call that retrieves the authentication
>>>>>> > token
>>>>>> > for the 'root' user.
>>>>>> >                 AuthToken rootAuthToken =
>>>>>> > security.getAuthToken(getAuthTokenRoot);
>>>>>> >                 //System.out.println ("root AUTHTOKEN = " +
>>>>>> > rootAuthToken.getAuthInfo());
>>>>>> >
>>>>>> >                 // Creating a new publisher that we will use to
>>>>>> > publish our
>>>>>> > entities to.
>>>>>> >                 Publisher p = new Publisher();
>>>>>> >                 p.setAuthorizedName("my-publisher");
>>>>>> >                 p.setPublisherName("My Publisher");
>>>>>> >
>>>>>> >                 // Adding the publisher to the "save" structure,
>>>>>> > using the
>>>>>> > 'root' user authentication info and saving away.
>>>>>> >                 SavePublisher sp = new SavePublisher();
>>>>>> >                 sp.getPublisher().add(p);
>>>>>> >                 sp.setAuthInfo(rootAuthToken.getAuthInfo());
>>>>>> >                 juddiApi.savePublisher(sp);
>>>>>> >
>>>>>> >                 // Our publisher is now saved, so now we want to
>>>>>> > retrieve
>>>>>> > its authentication token
>>>>>> >                 GetAuthToken getAuthTokenMyPub = new GetAuthToken();
>>>>>> >                 getAuthTokenMyPub.setUserID("my-publisher");
>>>>>> >                 getAuthTokenMyPub.setCred("root");
>>>>>> >                 AuthToken myPubAuthToken =
>>>>>> > security.getAuthToken(getAuthTokenMyPub);
>>>>>> >                 //System.out.println ("myPub AUTHTOKEN = " +
>>>>>> > myPubAuthToken.getAuthInfo());
>>>>>> >
>>>>>> >                 // Creating the parent business entity that will
>>>>>> > contain our
>>>>>> > service.
>>>>>> >                 BusinessEntity myBusEntity = new BusinessEntity();
>>>>>> >                 Name myBusName = new Name();
>>>>>> >                 myBusName.setValue(nom);
>>>>>> >                 myBusEntity.getName().add(myBusName);
>>>>>> >
>>>>>> >                 // Adding the business entity to the "save"
>>>>>> > structure, using
>>>>>> > our publisher's authentication info and saving away.
>>>>>> >                 SaveBusiness sb = new SaveBusiness();
>>>>>> >                 sb.getBusinessEntity().add(myBusEntity);
>>>>>> >                 sb.setAuthInfo(myPubAuthToken.getAuthInfo());
>>>>>> >                 BusinessDetail bd = publish.saveBusiness(sb);
>>>>>> >                 String myBusKey =
>>>>>> > bd.getBusinessEntity().get(0).getBusinessKey();
>>>>>> >
>>>>>> >                 out.println("<div id='cuerpo2'>);"
>>>>>> >                    +"<table>");
>>>>>> >                    out.println("<tr>"
>>>>>> >                             + "<td><b>root AUTHTOKEN:</b> " +
>>>>>> > rootAuthToken.getAuthInfo() + "</td></tr>");
>>>>>> >                     out.println("<tr><td><b>myPub AUTHTOKEN: </b>" +
>>>>>> > myPubAuthToken.getAuthInfo() + "</td></tr>");
>>>>>> >                     out.println("<tr>"
>>>>>> >                             + "<td><b>Name:</b> " + nom +
>>>>>> > "</td></tr>");
>>>>>> >                     out.println("<tr><td><b>BusinessKey: </b>" +
>>>>>> > myBusKey +
>>>>>> > "</td></tr>"
>>>>>> >                             + "</table>"
>>>>>> >                 +"</div>");
>>>>>> >
>>>>>> >                 }
>>>>>> >             catch (Exception e) {
>>>>>> >
>>>>>> >                     out.println("<div id=\"cuerpo2\">"
>>>>>> >                             +"error"
>>>>>> >                             +"<br>"+ nom +""
>>>>>> >                     +"</div>");
>>>>>> >
>>>>>> >
>>>>>> >                 e.printStackTrace();
>>>>>> > }
>>>>>> >      }
>>>>>> >
>>>>>> > }
>>>>>> >
>>>>>> >
>>>>>> > 2013/4/15 Alex O'Ree <[email protected]>
>>>>>> >>
>>>>>> >> No idea what the root cause is, but it sounds like the code you're
>>>>>> >> stepping though, when compiled, does not match what is in the
>>>>>> >> servlet
>>>>>> >> container. Try to delete all temp/work folders and clean, build and
>>>>>> >> redeploy. There's no reason why it wouldn't work as a servlet, so
>>>>>> >> long
>>>>>> >> as you have all the required jar's within the classpath
>>>>>> >>
>>>>>> >> On Mon, Apr 15, 2013 at 4:58 PM, Edgar Orduña <[email protected]>
>>>>>> >> wrote:
>>>>>> >> > Hi
>>>>>> >> > I have a question, can i use the SimplePublish.java example  like
>>>>>> >> > a
>>>>>> >> > Servlet
>>>>>> >> > from Java?
>>>>>> >> > or the example runs only on console.
>>>>>> >> >
>>>>>> >> > I'm Trying to use the SimplePublish.java like a servlet but in
>>>>>> >> > the
>>>>>> >> > example
>>>>>> >> > the source code from "try" doesn't run only the source code from
>>>>>> >> > "catch"
>>>>>> >> > runs.
>>>>>> >> >
>>>>>> >> > Thanks
>>>>>> >
>>>>>> >
>>>>>
>>>>>
>>>
>>
>>
>>
>

Reply via email to