Problems Creating a Java Class using a webservice with certificate

hi,
i'm developing a java class that call's a webservice that needs a certificate, i'm not used to work with java, last time was 10 years ago, so i'm having some troubles because of the certificate.
I already add the certificate using java control panel > Security > Certificates. When testing i get the following error: IOException (java.io.IOException: subject key, Unknown key spec)
I think I need to define the certificate in my class, but i'm having a lots of trouble with the samples that i found over the internet, nothing works and i'm running out of time.
This is my Class
create or replace and compile java source named "FishInfoAt" as
import java.net.*;
import java.io.*;
import java.security.*;
public class FishInfoAt
     public FishInfoAt()
     public static String send(String urlfishinfoat, String mensagem, String mensagem1, String mensagem2, String mensagem3)
          // Init
          String response = "";
          String msgtotal = mensagem+mensagem1+mensagem2+mensagem3;
          String a = "";
          HttpURLConnection conn = null;
          try{
               URL url = new URL(urlfishinfoat);
               conn = (HttpURLConnection) url.openConnection();
               conn.setRequestMethod("POST");
               conn.setRequestProperty("Content-type", "text/xml; charset=utf-8");
               conn.setRequestProperty("SOAPAction", "https://servicos.portaldasfinancas.gov.pt:401/sgdtws/documentosTransporte/");
               conn.setRequestProperty("Content-Length","" + msgtotal.length());
               conn.setDoOutput(true);
               conn.setDoInput(true);
               conn.connect();
               OutputStream out = conn.getOutputStream();
               out.write(msgtotal.getBytes());
               out.flush();
               InputStream in = conn.getInputStream();
               int value;
               while( (value = in.read()) != -1)
                    response+=(char)value;
          catch(Exception e)
response = ("*** ERROR - IOException (" + e.getMessage() + a + ")");
return response;
/

Hi Deepak,
Could you please let us know upto which line your code is going safe. Try printing the value in the structure before you send that to the method GetUGEntity().
I am not too sure that would be a problem. But I have faced a problem like this, wherein I tried to access a structure for which I have not allocated memory and hence got exception because of that.
Since your JNI code seems to be error free, I got doubt on your C part. Sorry.
Dhamo.

Similar Messages

  • Problems creating a Java Array using JNI-HELP!

    Hi,
    I am trying to create a Java Array using JNI.I have posted the code below. The problem is that the oth element is added correctly to the Array but when the JVM gets to the next element...it goes for a toss. It is not able to create a new instance of the object in GetUGEntity() function...there seems to be some problem in creating a new instance of the object!
    Can somebody help me with this?
    jobject GetUGEntity(JNIEnv *env, UF_DISP_j3d_entity_t* entity_list)
         int numVerts=0, numStrips=0;
         jfieldID fid;
         jdoubleArray jTransform=NULL;
         jstring jstrName=NULL;
         jdoubleArray jNormals=NULL;
         //Init an Entity object
         cout<< "**Getting New Class Reference...";
         jclass jEntity = env->FindClass("Lcom/wipro/java3d/rmi/Entity;");
         cout << "**got Class reference..."<<endl;
         if (jEntity == NULL)
              return NULL;
         cout<<"Creating new object instance...";
         jmethodID mIDInit = env->GetMethodID(jEntity, "<init>", "()V");
         cout<<"Got java method id...";
         jobject javaObj = env->NewObject(jEntity, mIDInit);
         if (javaObj==NULL)
              return NULL;
         cout << "Created!" << endl;
         //Entity ID
         cout<< "**Setting eid...";
         fid=env->GetFieldID(jEntity,"eid","I");
         jint eid = (jint)(entity_list)->eid;
         env->SetIntField(javaObj, fid, eid);
         //env->DeleteLocalRef(eid);
         cout << "Done!" << endl;
         cout << "Done!" << endl;
         cout<< "**Returning jobject...";
         return javaObj;
    jobjectArray createJArray(JNIEnv* env, UF_DISP_j3d_entity_t** entity_list, int noOfEntities )
         UF_DISP_j3d_entity_t* tempVar=NULL;
         cout<<"*Creating Jobjectarray...";
         jobjectArray jEntityArray = (jobjectArray) env->NewObjectArray(noOfEntities,
              env->FindClass("Lcom/wipro/java3d/rmi/Entity;"),NULL);
         cout<<"Created!"<<endl;
         for(int i=0; i<noOfEntities;++i)
              tempVar = &(*entity_list);
              if (tempVar !=NULL)
                   cout<<"*Trying to get Entity...."<<endl;
                   jobject jEntity = GetUGEntity(env, tempVar);
                   if (jEntity!= NULL)
                        cout<<"Got Entity!" <<endl;
                        cout <<"*Setting Array Element....";
                        env->SetObjectArrayElement(jEntityArray, i, jEntity);
                        cout << "Done!" << endl;
                   else
                        printf("ERROR: Did not get Entity Reference");
              else
                   printf("ERROR: Got a NULL Reference!");
         return jEntityArray;

    Hi Deepak,
    Could you please let us know upto which line your code is going safe. Try printing the value in the structure before you send that to the method GetUGEntity().
    I am not too sure that would be a problem. But I have faced a problem like this, wherein I tried to access a structure for which I have not allocated memory and hence got exception because of that.
    Since your JNI code seems to be error free, I got doubt on your C part. Sorry.
    Dhamo.

  • Urgent !!!!!!!!!!!! regarding CREATE JAVA CLASS USING BFILE

    We have Oracle 8.1.7 spatial database. We got to load some java classes into the database. We would like to make it as the java programs to be loaded from a client system into the oracle server. I am using CREATE DIRECTORY command to create a directory object (say suppose \\prav\loadjavaclasses\. Then using the CREATE OR REPLACE JAVA CLASS USING BFILE (object_name, 'CLASSNAME.CLASS'). This .class file is in the network identified by prav which in turn has a shared directory (full privileges) loadjavaclasses folder. Can you please help in this regard.
    Please mail me to [email protected]
    thanks in advance
    SudhaSrikanthan
    null

    use loadjava

  • Can not locate Java class using JNI within C++ DLL

    I am using trying to use JNI to call a Java class from C++. The Java class uses JMS to send messages to a JMS message queue. At first I coded the C++ in a console application that created the JavaVM and used JNI to access the Java class. All worked fine. Then I called the Java class using JNI from threads and ran into the problem of the Java class not able to locate the JMS related classes. This was solved by placing the following line in the constructor of the Java class.
    Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
    Then I moved the JNI code from a console application to a DLL in specific an extension DLL that is called by SQL Server or Oracle server. The DLL will use JNI to call the Java class and send messages to a JMS message queue.
    The problem I am having now when the DLL code is called by SQL Server the call to
    JNI_CreateJavaVM
    appears to work correctly but the call to find the Java class using
    jvmEnv->FindClass(pName)
    fails. It appears the is a class loading problem which occurs due to the fact JNI is called from a DLL. When the VM is created I pass the class path information using the statement
    -Djava.class.path=
    And as I stated before it all works when running from a console application. I am new to JNI and really need help in the form of some sample code that will solve this problem. I believe I need to somehow load the classpath information from the DLL but I can not find examples on how to do this using JNI. I have tried several ways using URLClassLoader and getSystemClassLoader from JNI and either it does not work or it crashes very badly.
    I used the following code to determine what the existing class path is and the string returns empty.
    jcls = jvmEnv->FindClass("java/lang/System");
    jmid = jvmEnv->GetStaticMethodID(jcls, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;");
    jstrClassPath = jvmEnv->NewStringUTF("java.class.path");
    jstr = (jstring)jvmEnv->CallStaticObjectMethod(jcls, jmid, jstrClassPath);
    m_jstr = (jstring)jvmEnv->NewGlobalRef(jstr);
    pstr = jvmEnv->GetStringUTFChars(m_jstr, 0);
    Can anyone please help with example code that will solve this problem. Thanks in advance for any help.
    Charles�

    I have determined the problem occurs when the application/component is compiled using VC 6.0. The test application was compiled using VC 7.1 and works correctly by locating the class path information. If the test application is compiled using VC 6.0 it has the same problem.
    The jvm.dll I am using is version 1.4.2.80. Currently this is not an option to compile all the applications that use JNI using VC 7.1 so can someone please tell me how to solve this problem.

  • To create a java class in Web dynpro

    Hi,
    I want to create a java class which can be used in multiple views. Where will i create it and how will i access it?
    Can i create the class in Comp controller's imeplementation between "begin others"----
    "end"?
    Any help?
    regards,
    Sujesh

    Hi,
      If you create the class within the begin others"----
    "end" section, this class will not be accessible by any other class.
      You can create a class in
    Project/src/packages/<namespace>/<your component>/<create a new subdirectory>/Test.java.
    This will be accessible to all other classes. Just make sure the first line of your java file is the proper package declaration. So in this case the 1st line dhould be:
    package <namespace>.<your component>.<subdirectory name>;
    Regards,
    Satyajit.

  • Create Standalone JAVA ClASS

    HI All,
    Can anyone help me out to create a stand-alone java classs??
    (It will call EJB Method).
    more Insight:
    We have developed one service. It is working fine in RAD 7.0. No issues in that. But as per requirements, We have to check that application as stand-alone class. we are trying to call stand alone Java class using command prompt and see if EJB gets invoked which is running on the WAS server?
    Is there any way ?

    Can anybody relook on my issue?
    HI All,
    Can anyone help me out to create a stand-alone java classs??
    (It will call EJB Method).
    more Insight:
    We have developed one service. It is working fine in RAD 7.0. No issues in that. But as per requirements, We have to check that application as stand-alone class. we are trying to call stand alone Java class using command prompt and see if EJB gets invoked which is running on the WAS server?
    Is there any way ?

  • Can anyone help i want to call java class using visual basic

    I want to call java class using visual basic and send some arguments to the main class

    Hi,
    I don't know VB, but you can surely launch a command line like :
    javaw.exe mypackage.MyMainClass myArgument1
    Regards

  • How to create users and groups using WLST Offline with Weblogic 8.1.4

    How to create users and groups using WLST Offline with Weblogic 8.1.4?
    Any ideas?

    Hi this is how i created a user using WLST Offline?
    cd('/Security/' + domainName)
    # Delete the default user name weblogic
    # incase you want to remove the defualt user weblogic
    delete('weblogic','User')
    # Creating a new user defined
    create(userName, 'User')
    # Setting the password of the user you created.
    cd ('/Security/' + domainName + '/User/' + userName)
    cmo.setPassword(password)
    Regards
    Makenzo

  • Do I need to Create Primary Key Class for Entity beans with Local interface

    Do I need to Create Primary Key Class for Entity beans with Local interface?
    I have created my entity bean with the wizard in Sun One Studio and it does not create a primary key class for you.
    I thought that the primary key class was required. My key is made up of only one field.
    Anyone know the answer.
    Jim

    u dont need to create a primary key class for a entity bean.if ur table's primary key feild(int ,float) is a built in or primitive data type,then u dont need one.But if ur table has a primary key field which is non primitive (for example StudentID,ItemID etc)then u have to create a primary key class.
    hope this helps :-)

  • Problems calling java classe using WSIF in BPEL 10.1.3.3

    Hi,
    I am working on a POC for a telecom gaint in Sweden. One of their requirement is to invoke java library.
    Inorder to do it, I have followed the below steps:
    1. Wrote a wrapper java code to a class in this library.(Attached with this mail)
    2. Using JDEV 10.1.3.3 created a wsdl file of WSIF binding type for invoking this wrapper class.(Attached with this mail.)
    3. Created the required fascade classes using the SCHEMAC option in command prompt.
    4. Placed all the class files including the wrapper class file in %BPELHOME%\bpel\system\classes
    5. Created a BPEL process to invoke the wsif wsdl.
    However while Invoking the BPEL process I am getting the error"com.collaxa.cube.ws.wsif.providers.java.WSIFOperation_Java@9ecad : Could not invoke 'authenticate'; nested exception is:
         org.collaxa.thirdparty.apache.wsif.WSIFException: No method named 'authenticate' found that match the parts specified"
    Can someone tell me how to resolve this issue.
    I have to do a presentation on this in 2 days.
    Thanks for the help.
    Regards,
    Gautham

    Hi in BPEL XML,
    Enter the credientials,
    I have pasted the Sample BPEL file.
    <?xml version="1.0"?>
    <BPELSuitcase>
         <BPELProcess id="BankTransferFlow" src="BankTransferFlow.bpel">
              <partnerLinkBindings>
                   <partnerLinkBinding name="client">
                        <property name="wsdlLocation">BankTransferFlow.wsdl</property>
                   </partnerLinkBinding>
                   <partnerLinkBinding name="bankTransfer">
                        <property name="wsdlLocation">BankTransferServiceDesign.wsdl</property>
                        <property name="wsdlRuntimeLocation">BankTransferService.wsdl</property>
                        <property name="java.naming.security.principal">oc4jadmin</property>
                        <property name="java.naming.security.credentials">welcome1</property>     
                        <property name="dedicated.connection">true</property>          
                   </partnerLinkBinding>
              </partnerLinkBindings>
    <configurations>
    <property name="testIntroduction"><![CDATA[
         This demo showcases the integration of session beans into
         an end-to-end business process. The database has 2 accounts 11111 and 22222 and both of them have initial balance 1000.
         ]]></property>
    <property name="defaultInput"><![CDATA[<BankTransferFlowRequest xmlns="http://samples.otn.com">
    <fromAccount>11111</fromAccount>
    <toAccount>22222</toAccount>
    <amount>10</amount>
    </BankTransferFlowRequest>
    ]]></property>
    <property name="transaction">participate</property>
    <property name="inMemoryOptimization">true</property>
    </configurations>          
         </BPELProcess>
    </BPELSuitcase>
    Thank you,
    [email protected]

  • How to create custom java class in Content Server

    Hi All,
    I want to develop a custom java class (.class) file and upload in the UCM(Stellent Content Server). The problem is that I have to use some objects like DataResultSet, SharedObjects etc in my java class file. Since these class files resides in the Content Server I am not able to create a custom java class with these objects.
    Can any one help me to solve the above issue
    With thanks and regards
    Mohan

    Hey there,
    All of the core content server class files are included in a single jar file. This jar is in one of 2 places in the 10gr3 version of UCM:
    1. If you have an unpatched content server include $IntradocDir/shared/classes/server.zip in your classpath
    2. If you have a patched content server include $IntradocDir/custom/CS10gR35CoreUpdate/classes.jar in your classpath.
    In UCM 11g the jar file is located in %MIDDLEWARE_HOME%/Oracle_ECM1/ucm/idc/jlib/idcserver.jar
    P.S. Venkat is correct, post UCM specific questions in the ECM forum.
    Hope that helps,
    Andy Weaver - Senior Software Consultant
    Fishbowl Solutions < http://www.fishbowlsolutions.com?WT.mc_id=L_Oracle_Consulting_amw_OTN_WCS >

  • Problem Web Dynpro Java applications using JasperReports

    Hello all,
    We have followed the footsteps of these blogs but we can not make it work.
    Part I --> Part-I: Print Web Dynpro Java applications using JasperReports
    Part II --> Part-II: Print Web Dynpro Java applications using JasperReports
    Part III --> Part-III: Print Web Dynpro Java applications using JasperReports
    Details system: 7.02 SP3
    We believe that the problem is in the library, because it finds them.
    1) We created project as a DC external library with *.jars
    2) Public part DC external library.
    3) Add public part of DC Library into new project DC WebDynpro Java.
    4) Development Component -> Build is OK
    5) Development Component -> Deploy is OK
    6) Test app ERROR.
    When we run the application shows the error:
    The initial exception that caused the request to fail, was:
       java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRDataSource
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:141)
        at com.unisys.tmb.View01.onActiongenerarPDF(View01.java:161)
        at com.unisys.tmb.wdp.InternalView01.wdInvokeEventHandler(InternalView01.java:140)
        at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
        ... 28 more
    See full exception chain for details.
    Regards,
    Luis.

    Hello John,
    Thanks for the link. We have performed the steps in this blog:
    1) Create DC Project "External Library" with name js/jars:
    - Add *.jars in folder Libraries.[Screenshot Libraries|http://img846.imageshack.us/img846/8395/jsjars.jpg]
    - Add archives (*.jar) to public part with name ExternalLib. Which option to choose?
    a- Provides an API for developing/compiling other DCs (Option chosen)
    b- Can be packaged into other build results (eg SDAs)
    - Development Component -&gt; Build
    Step 1 is OK.
    2) Create "J2EE Server Component / Library" DC with name js/lib:
    - Add Used DC -> public part project ExternalLibrary -> "ExternalLib"
    - Specify both build time and run-time dependency here and strong.
    - Generated SDA file in <var>gen/default/deploy</var> How do we check that it contains <var>js.jar</var>?
    - folder gen/default/plublic/defLib/lib/java then you meet *.jars files again. is OK.
    - Development Component -> Deploy.
    - Go to Visual Administrator. We found the library js/lib, but has no associated *. jar. It is the problem.[Screenshot Visual Administrator|http://img542.imageshack.us/img542/5537/visualadminlib.jpg]
    3) Create "WebDynpro" DC with name pdf_jasper
    - Add used DC (defLib) to WebDynpro DC with option "Build time".
    - WebDynpro References -> Library references --> add <var>jslib
    - Deploy
    - Run error: java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRDataSource
    Regards,
    Luis.

  • Help in creating a Java class to convert Html source to XML

    He Everyone!
    I am using selenium as my automation tool
    I got the htmlsource of the page using selenium.
    Now i have to write a Java class which will convert the data (html source)
    (and output a data structure in standard XML format
    Can anyone give me an example codejava class) in how to acheive this please?
    Please mail to
    [email protected]
    Many thanks

    getafix14 wrote:
    Can anyone give me an example codejava class) in how to acheive this please?
    Please mail to
    [email protected]
    Sorry Charlie, but this isn't a "mail me the codez" forum. Either use Google, or try to share your problem and their solutions in the forum. Besides, a little Googling will find you a solution.

  • Creating a new class using a template class

    I am very new to Java.
    I need to make a new class by using a template class that was given to us.
    I go to File / New / Class but cannot find how to select a template class to create a new class.
    Thanks,
    gs

    gs2010 wrote:
    I am very new to Java.
    I need to make a new class by using a template class that was given to us.
    I go to File / New / Class but cannot find how to select a template class to create a new class.
    Thanks,
    gsYou need to be much more specific as to what you are trying to do.
    What is a "template class"?
    How are you trying to "go to" and "select" the template?
    Etc.

  • Problem during call java class (model layer) from jsp page (view layer)

    I created new Fusion web application so I have now to parts in the application navigator (model, viewcontroller)
    I want to write java class in the Model part as following:
    package persistence;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class DBManager {
    Connection connection = null;
    public DBManager() {
    super();
    public void init() {
    try {
    // Load the JDBC driver
    String driverName = "oracle.jdbc.driver.OracleDriver";
    Class.forName(driverName);
    // Create a connection to the database
    String serverName = Constant.DB_SERVER_NAME;
    String portNumber = Constant.DB_PORT_NUMBER;
    String sid = Constant.DB_SID;
    String url =
    "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" +
    sid;
    String username = Constant.DB_USER_NAME;
    String password = Constant.DB_PASSWORD;
    connection = DriverManager.getConnection(url, username, password);
    System.out.println("*");
    System.out.println(connection.getCatalog());
    } catch (ClassNotFoundException e) {
    System.out.println("Could not find the database driver");
    } catch (SQLException e) {
    System.out.println("Could not connect to the database");
    e.printStackTrace();
    and wrote JSP page in the view controller part as following :
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%@page import="persistance.*"%>
    <% persistance.DBManager manager = new DBManager(); %>
    <%@ page contentType="text/html;charset=windows-1252"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
    <title>Browse</title>
    </head>
    <body>
    <table>
    </table>
    </body>
    </html>
    but this I have the following error in the jsp page :type persistance.DBManager not found
    my job is to build simple ADF application using JSF and java without any ADF faces or JPA or any another technology
    thanks

    Duplicate message.
    type persistance.DBManager not found
    Add a Dependency on the Model project in the View project. In Project Properties select the Dependencies node to add dependencies.
    Edited by: dvohra16 on Jun 19, 2011 8:37 AM

Maybe you are looking for

  • I want to always be able to page down using space bar, but some web pages seem to disable this.

    I often use the space bar to page down in web pages rather than scrolling with the mouse or arrow keys, but in the last few months I've encountered a number of pages that don't seem to allow this browser feature to work. For instance, space bar doesn

  • Row count in Pivotal View (10 rows per page)

    Hi I tried following options to restrict row count in Pivotal view of a report, however the out put is inconsistent in pivotal view. 1. CEILING((RCOUNT(1))/10.0) 2. TRUNCATE((RCOUNT(1)-1)/10, 0) +1 3. Even Case statement also Appreciate the help exte

  • FCP X not reading camera archives (Unsupported Media, Invalid Directory)

    I shot a documentary in May of 2012 and imported the media everytime a card would fill up or at the end of the shoot day. I also created a Camera Archive for each card (we shot Sony PMW-F3 and PMW-EX1). A few clips have gone missing and when I plug i

  • How can I check what the processor speed is

    We have an old white dome base iMac, running OSX 10.1  How can I check the processor speed - it is not available to choose in the 'about this Mac' dropdown?

  • FCP project creation date

    Hi all, 1 have an installation with three MDC Xserves (10.6.2) ,8 Mac Pro clients ( 10.5.8 ) with XSAN 2.2.1 and Open Directory . The MAC pro clients have Final Cut Pro 6.0.6 installed. When we modify a project in FCP and save it then the creation da