Tnameserv via code in 1.5

In previous JDK version (1.4) we were able to start the tnameserv
via code. Works with both Sun and Ibm JDK, and then from the
same program the NameService could be accessed via CORBA API ORB.resolve_initial_references("NameService") or via JNDI using the
context factory com.sun.jndi.cosnaming.CNCtxFactory.
It used to be somehing like this (it has to be started on it's own thread)
args=new String[1];
args[0]="org.omg.CORBA.ORBInitialPort=900";
// Code for Sun JDK:
com.sun.corba.se.internal.CosNaming.TransientNameServer.main(args);
/* Code for IBM JDK:
com.ibm.corba.CosNaming.TransientNameServer.main(args);
This was very handy during development as it did not require managing the separate tnameserv/orbd proces and basically behaves as LocateRegistry.createRegistry() - basically the name server would be instantiated as a part of the program.
The new class in 1.5 com.sun.corba.se.impl.naming.cosnaming.TransientNameServer
does not work that way any more. The name servier could get started but as soon as the first client tries to access it from the same VM, there is an
exception (see below). It appears that the cause is an attempt to create another listener thread with the same port that was used in the server resulting in 'Address already in use: bind'. Since this is thrown when the InitialContext is attempted it is not clear why the listener socket gets created at that point.
Thanks,
emil
Sep 9, 2005 2:11:49 AM com.sun.corba.se.impl.transport.SocketOrChannelAcceptorImpl initialize
SEVERE: "IOP00410216: (COMM_FAILURE) Unable to create listener thread on the specified port: 900"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 216 completed: No
     at com.sun.corba.se.impl.logging.ORBUtilSystemException.createListenerFailed(ORBUtilSystemException.java:2604)
     at com.sun.corba.se.impl.logging.ORBUtilSystemException.createListenerFailed(ORBUtilSystemException.java:2623)
     at com.sun.corba.se.impl.transport.SocketOrChannelAcceptorImpl.initialize(SocketOrChannelAcceptorImpl.java:160)
     at com.sun.corba.se.impl.transport.CorbaTransportManagerImpl.getAcceptors(CorbaTransportManagerImpl.java:190)
     at com.sun.corba.se.impl.transport.CorbaTransportManagerImpl.addToIORTemplate(CorbaTransportManagerImpl.java:207)
     at com.sun.corba.se.spi.oa.ObjectAdapterBase.initializeTemplate(ObjectAdapterBase.java:104)
     at com.sun.corba.se.impl.oa.toa.TOAImpl.<init>(TOAImpl.java:78)
     at com.sun.corba.se.impl.oa.toa.TOAFactory.getTOA(TOAFactory.java:72)
     at com.sun.corba.se.impl.orb.ORBImpl.connect(ORBImpl.java:1472)
     at com.sun.corba.se.spi.presentation.rmi.StubAdapter.connect(StubAdapter.java:164)
     at com.sun.corba.se.impl.orbutil.ORBUtility.connectAndGetIOR(ORBUtility.java:777)
     at com.sun.corba.se.impl.orb.ORBImpl.getFVDCodeBaseIOR(ORBImpl.java:837)
     at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.addServiceContexts(CorbaClientRequestDispatcherImpl.java:726)
     at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:226)
     at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:118)
     at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.invoke(BootstrapResolverImpl.java:74)
     at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.resolve(BootstrapResolverImpl.java:107)
     at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(CompositeResolverImpl.java:22)
     at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(CompositeResolverImpl.java:22)
     at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(CompositeResolverImpl.java:22)
     at com.sun.corba.se.impl.orb.ORBImpl.resolve_initial_references(ORBImpl.java:1157)
     at com.sun.jndi.cosnaming.CNCtx.setOrbAndRootContext(CNCtx.java:340)
     at com.sun.jndi.cosnaming.CNCtx.initUsingIiopUrl(CNCtx.java:289)
     at com.sun.jndi.cosnaming.CNCtx.initUsingUrl(CNCtx.java:245)
     at com.sun.jndi.cosnaming.CNCtx.initOrbAndRootContext(CNCtx.java:209)
     at com.sun.jndi.cosnaming.CNCtx.<init>(CNCtx.java:69)
     at com.sun.jndi.cosnaming.CNCtxFactory.getInitialContext(CNCtxFactory.java:32)
     at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
     at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
     at javax.naming.InitialContext.init(InitialContext.java:223)
     at javax.naming.InitialContext.<init>(InitialContext.java:197)
     at CosNamingServer$PsvMainNamingServer.start(CosNamingServer.java:159)
     at CosNamingServer.startServer(CosNamingServer.java:84)
     at CosNamingServer.startServer(CosNamingServer.java:70)
     at StartServer.main(StartServer.java:4)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:585)
     at com.intellij.rt.execution.application.AppMain.main(AppMain.java:86)
Caused by: java.net.BindException: Address already in use: bind
     at sun.nio.ch.Net.bind(Native Method)
     at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:119)
     at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
     at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:52)
     at com.sun.corba.se.impl.transport.DefaultSocketFactoryImpl.createServerSocket(DefaultSocketFactoryImpl.java:48)
     at com.sun.corba.se.impl.transport.SocketOrChannelAcceptorImpl.initialize(SocketOrChannelAcceptorImpl.java:156)
     ... 37 more
Sep 9, 2005 2:11:49 AM com.sun.corba.se.impl.orb.ORBImpl connect
WARNING: "IOP02310202: (OBJ_ADAPTER) Error in connecting servant to ORB"
org.omg.CORBA.OBJ_ADAPTER: vmcid: SUN minor code: 202 completed: No
     at com.sun.corba.se.impl.logging.ORBUtilSystemException.orbConnectError(ORBUtilSystemException.java:8045)
     at com.sun.corba.se.impl.logging.ORBUtilSystemException.orbConnectError(ORBUtilSystemException.java:8063)
     at com.sun.corba.se.impl.orb.ORBImpl.connect(ORBImpl.java:1474)
     at com.sun.corba.se.spi.presentation.rmi.StubAdapter.connect(StubAdapter.java:164)
     at com.sun.corba.se.impl.orbutil.ORBUtility.connectAndGetIOR(ORBUtility.java:777)
     at com.sun.corba.se.impl.orb.ORBImpl.getFVDCodeBaseIOR(ORBImpl.java:837)
     at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.addServiceContexts(CorbaClientRequestDispatcherImpl.java:726)
     at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:226)
     at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:118)
     at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.invoke(BootstrapResolverImpl.java:74)
     at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.resolve(BootstrapResolverImpl.java:107)
     at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(CompositeResolverImpl.java:22)
     at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(CompositeResolverImpl.java:22)
     at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(CompositeResolverImpl.java:22)
     at com.sun.corba.se.impl.orb.ORBImpl.resolve_initial_references(ORBImpl.java:1157)
     at com.sun.jndi.cosnaming.CNCtx.setOrbAndRootContext(CNCtx.java:340)
     at com.sun.jndi.cosnaming.CNCtx.initUsingIiopUrl(CNCtx.java:289)
     at com.sun.jndi.cosnaming.CNCtx.initUsingUrl(CNCtx.java:245)
     at com.sun.jndi.cosnaming.CNCtx.initOrbAndRootContext(CNCtx.java:209)
     at com.sun.jndi.cosnaming.CNCtx.<init>(CNCtx.java:69)
     at com.sun.jndi.cosnaming.CNCtxFactory.getInitialContext(CNCtxFactory.java:32)
     at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
     at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
     at javax.naming.InitialContext.init(InitialContext.java:223)
     at javax.naming.InitialContext.<init>(InitialContext.java:197)
     at CosNamingServer$PsvMainNamingServer.start(CosNamingServer.java:159)
     at CosNamingServer.startServer(CosNamingServer.java:84)
     at CosNamingServer.startServer(CosNamingServer.java:70)
     at StartServer.main(StartServer.java:4)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:585)
     at com.intellij.rt.execution.application.AppMain.main(AppMain.java:86)
Caused by: org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 216 completed: No
     at com.sun.corba.se.impl.logging.ORBUtilSystemException.createListenerFailed(ORBUtilSystemException.java:2604)
     at com.sun.corba.se.impl.logging.ORBUtilSystemException.createListenerFailed(ORBUtilSystemException.java:2623)
     at com.sun.corba.se.impl.transport.SocketOrChannelAcceptorImpl.initialize(SocketOrChannelAcceptorImpl.java:160)
     at com.sun.corba.se.impl.transport.CorbaTransportManagerImpl.getAcceptors(CorbaTransportManagerImpl.java:190)
     at com.sun.corba.se.impl.transport.CorbaTransportManagerImpl.addToIORTemplate(CorbaTransportManagerImpl.java:207)
     at com.sun.corba.se.spi.oa.ObjectAdapterBase.initializeTemplate(ObjectAdapterBase.java:104)
     at com.sun.corba.se.impl.oa.toa.TOAImpl.<init>(TOAImpl.java:78)
     at com.sun.corba.se.impl.oa.toa.TOAFactory.getTOA(TOAFactory.java:72)
     at com.sun.corba.se.impl.orb.ORBImpl.connect(ORBImpl.java:1472)
     ... 31 more
Caused by: java.net.BindException: Address already in use: bind
     at sun.nio.ch.Net.bind(Native Method)
     at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:119)
     at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
     at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:52)
     at com.sun.corba.se.impl.transport.DefaultSocketFactoryImpl.createServerSocket(DefaultSocketFactoryImpl.java:48)
     at com.sun.corba.se.impl.transport.SocketOrChannelAcceptorImpl.initialize(SocketOrChannelAcceptorImpl.java:156)
     ... 37 more
Exception in thread "main" java.lang.NullPointerException
     at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.sentFullMessage(CorbaMessageMediatorImpl.java:399)
     at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.sendCancelRequestIfFinalFragmentNotSent(CorbaMessageMediatorImpl.java:364)
     at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.endRequest(CorbaClientRequestDispatcherImpl.java:823)
     at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.releaseReply(CorbaClientDelegateImpl.java:137)
     at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.resolve(BootstrapResolverImpl.java:114)
     at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(CompositeResolverImpl.java:22)
     at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(CompositeResolverImpl.java:22)
     at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(CompositeResolverImpl.java:22)
     at com.sun.corba.se.impl.orb.ORBImpl.resolve_initial_references(ORBImpl.java:1157)
     at com.sun.jndi.cosnaming.CNCtx.setOrbAndRootContext(CNCtx.java:340)
     at com.sun.jndi.cosnaming.CNCtx.initUsingIiopUrl(CNCtx.java:289)
     at com.sun.jndi.cosnaming.CNCtx.initUsingUrl(CNCtx.java:245)
     at com.sun.jndi.cosnaming.CNCtx.initOrbAndRootContext(CNCtx.java:209)
     at com.sun.jndi.cosnaming.CNCtx.<init>(CNCtx.java:69)
     at com.sun.jndi.cosnaming.CNCtxFactory.getInitialContext(CNCtxFactory.java:32)
     at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
     at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
     at javax.naming.InitialContext.init(InitialContext.java:223)
     at javax.naming.InitialContext.<init>(InitialContext.java:197)

Hi,
Have you been able to solve this as yet?
I am facing the same problem while deploying to the embedded Sun App Server from Studio Creator IDE - EA2 (which is bundled with jdk1.5). The same code however was deployable and running with the IDE's previous version that had jdk1.4. My code has a corba call.
Thanks for any help,
Rupa

Similar Messages

  • How do i start the tnameserv via code

    Hi,
    I am trying to start the tnameserv which is the server which holds references to objects.it starts fine when u give start tnameserv in command line. But when I try to give it in Runtime.exec() . It throw io exception.Do help me
    TIA,
    Anand Bose

    Try to use class TransientNameServer:
    args=new String[1];
    args[0]="org.omg.CORBA.ORBInitialPort=900";
    // Code for Sun JDK:
    com.sun.corba.se.internal.CosNaming.TransientNameServer.main(args);
    /* Code for IBM JDK:
    com.ibm.corba.CosNaming.TransientNameServer.main(args);
    */

  • Supplying username and password to repository via code

    Hi There,
    Is there a way to supply the username and password to the webdav repository via code or in the address line? We have an ActiveX object accessing files and would like to avoid the repository prompting.
    Thanks

    With Script I can do it as follows.. See VerifyConnection
    Option Explicit
    Const iTimeOutInSecs = 60
    Const ForWriting = 2
    Rem ************** MAIN *****************
    main
    Wscript.quit
    Sub Main
      Dim WShell, FileSystem
      Dim davControl
      Dim objArgs, targetPath, serverURL, username, password, rootFolder, filter
      Dim fileUploadList, result
      Dim folderList, filelist
      Dim status
      Dim spoolFile
      Set wShell     = WScript.CreateObject("WScript.Shell")
      Set fileSystem = WScript.CreateObject("Scripting.FileSystemObject")
      Set spoolFile = fileSystem.OpenTextFile("httpUploadLoad.log", ForWriting, True)
      Set objArgs = WScript.Arguments
      targetPath  = objArgs(0)
      serverUrl   = objArgs(1)
      username    = objArgs(2)
      password    = objArgs(3)
      rootFolder  = objArgs(4)
      If objArgs.length = 6 Then
        filter    = objArgs(5)
      Else
        filter = Empty
      End If
      Set fileUploadList = CreateObject("Msxml2.DOMDocument.4.0")
      fileUploadList.async = False
      result = fileUploadList.load(targetPath)
      If (result = False) Then
        MsgBox "Failure while loading or parsing file : " & targetPath,vbCritical
        Wscript.quit
      End If
      Set davControl = new DavControlClass
      davControl.setServer serverURL, username, password
      davControl.setSpoofile(spoolfile)
      status = verifyHttpConnection(davControl, username)
      Set folderList =  fileUploadList.documentElement.selectNodes("/Upload/directories/directory")
      createFolders davControl, rootFolder, folderList, username, password, filter
      Set fileList =  fileUploadList.documentElement.selectNodes("/Upload/files/file")
      uploadFiles davControl, rootFolder, fileList, username, password, filter
      spoolfile.close()
    End Sub
    Function verifyHttpConnection(davControl,username)
      Dim status, targetFolder
      targetFolder = "/home/" & username
      status = davControl.verifyConnection(targetFolder)
      verifyHttpConnection = status
    End Function
    Sub createFolders(davControl, rootFolder, folderList, username, password, filter)
      Dim i, targetFolder, targetFolderPath
      For i = 0 to folderList.length - 1
        Set targetFolder = folderList.item(i)
        targetFolderPath = rootFolder & targetFolder.text
        If IsNull(filter) or (InStr(targetFolder.text,filter) = 1) Then
          'wscript.echo "Making " & targetFolderPath
          davControl.makeDir targetFolderPath,true
        End If
      Next
    End Sub
    Sub uploadFiles(davControl, rootFolder, fileList, username, password, filter)
      Dim i, targetFile, targetFilename, localFilename
      For i = 0 to fileList.length - 1
        Set targetFile = fileList.item(i)
        targetFilename = rootFolder & targetFile.text
        localFilename = Right(replace(targetFile.text,"/","\"),Len(targetFile.text)-1)
        If IsNull(filter) or (InStr(targetFile.text,filter) = 1) Then
          'wscript.echo "Uploading " &localFilename & " as " & targetFilename
          davControl.uploadFile localFIlename, targetFileName, "FORCE"
        End If
      Next
    End Sub
    Class DavControlClass
      Private HTTPUser
      Private HTTPPassword
      Private HTTPServer
      Private installParameters
      Private windowsShell
      Private XMLHTTP_CLASS_ID
      Private HttpObject
      Private spoolFile
      Dim     folderStatusList
      Private Sub Class_Initialize()
        XMLHTTP_CLASS_ID = "Msxml2.XMLHTTP.6.0"
        Set HttpObject = CreateObject(XMLHTTP_CLASS_ID)
        folderStatusList = Empty
      End Sub  
      Public Sub setSpoofile(file)
        Set spoolFile = file
      End Sub
      Public Sub setParameters(wshell, params)
        Set installParameters = params
        Set windowsShell = wShell
        setServer params.getServerURL(), params.getUser(), params.getPassword()
      End Sub
      Public Sub setServer(serverURL,serverUser,serverPassword)
        HTTPServer   = serverURL
        HTTPUser     = serverUser
        HTTPPassword = serverPassword
      End Sub
      Public Function getServerURL
        getServerURL= HTTPServer
      End Function       
      Public Function verifyConnection(target)
        On Error Resume Next
        HttpObject.Open "HEAD", HTTPServer & target, false, HTTPUser, HTTPPassword
        If Err.Number <> 0 Then
          WScript.echo "verifyConnection() - Fatal Error encountered accessing : " & HTTPServer & target & ". Status (" & Hex(Err.number)  & ") " & Err.Description
          Wscript.quit         
        End If
        On Error GoTo 0 
        HttpObject.setRequestHeader "Content-type", "text/xml"
        HttpObject.setRequestHeader "Depth", "1"
        On Error Resume Next
        HttpObject.send ("")
        If Err.Number <> 0 Then
          WScript.echo "resetConnection() - Fatal Error encountered accessing : " & HTTPServer & target & ". Status (" & Hex(Err.number)  & ") " & Err.Description
          Wscript.quit         
        End If
        On Error GoTo 0 
        If HTTPObject.status <> 200 Then
          MsgBox "Unable to access " & getServerURL() & target & ". HTTP Status = " & HTTPObject.status & ". Please correct installParameters.xml and restart Installation",vbCritical
          Wscript.quit
        End If
        spoolfile.writeline "HTTP Successfully Connected to '" & getServerURL() & target
        verifyConnection = HTTPObject.status
      End Function
      Public Function uploadFile (local, remote, mode)
        Dim returnCode, rc
        returnCode = doHead(remote)
        If returnCode = 401 Then
          MsgBox "uploadFile() - Unauthorized (Status (" & returnCode & "). Unable to upload '" & local & "' into '" & remote & "'.  Please check installParameters.xml and log files.",vbCritical
          Wscript.quit         
        End If
        If returnCode = 200 Then
          If mode = "ERROR" Then
            MsgBox "uploadFile() - Installation Failed. Resource Exists : '" & remote & "'. Please check installParameters.xml and restart Installation",vbCritical
            Wscript.quit
          End If
          If mode = "SKIP" Then
            uploadFile = returnCode
            Exit Function
          End If
          If mode = "FORCE" Then
            rc = doDelete(remote)
          End If
        End If
        uploadFile = doPut (local, remote, null)
        If uploadFile = 500 Then
          MsgBox "UploadFile() - Upload Failed (Status (" & uploadFile & "). Unable to upload '" & local & "' into '" & remote & "'.  Retry in Progress.",vbCritical
          uploadFile = doPut (local, remote, null, user, password)
          If uploadFile = 500 Then
            MsgBox "UploadFile() -  Installation Failed (Status (" & uploadFile & "). Unable to upload '" & local & "' into '" & remote & "'.  Please check installParameters.xml and log files.",vbCritical
            Wscript.quit         
          End If
        End If
        If uploadFile = 401 Then
          MsgBox "UploadFile() - Unauthorized (Status (" & uploadFile & "). Unable to upload '" & local & "' into '" & remote & "'.  Please check installParameters.xml and log files.",vbCritical
          Wscript.quit         
        End If
      End Function
      Public Function makeDir(targetFolder,force)
        Dim Status, ParentFolder
        status = doHEAD(targetFolder)
        If not IsEmpty(folderStatusList) Then
          folderStatusList.add targetFolder, status
        End If
        If (status = 404 or status = 409) and force Then
          parentFolder = Mid(targetFolder,1,InStrRev(targetFolder,"/")-1)
          makeDir parentFolder,true
          status = doMKCOL(targetFolder)
        End If
        makeDir = status   
        If status = 401 Then
          MsgBox "doMKCOL() - Unauthorized (Status (" & status & "). Unable to create '" & targetFolder & "'.  Please check installParameters.xml and log files.",vbCritical
          Wscript.quit         
        End If
      End Function
      Public Function doHEAD(remote)
        ' Dim HttpObject
        ' Set HttpObject = CreateObject(XMLHTTP_CLASS_ID)
        ' HttpObject.Open "HEAD", HTTPServer & remote, false, user, password
        HttpObject.Open "HEAD", HTTPServer & remote, false
        HttpObject.setRequestHeader "Content-type", "text/xml"
        HttpObject.setRequestHeader "Depth", "1"
        On Error Resume Next
        HttpObject.send ("")
        If Err.Number <> 0 Then
          WScript.echo "doHEAD() - Fatal Error encountered accessing : " & HTTPServer & remote & ". Status (" & Hex(Err.number)  & ") " & Err.Description
          Wscript.quit         
        End If
        On Error GoTo 0 
        doHead = HttpObject.status
      End Function
      Public Function doPUT(local,remote,contentType)
        Dim tmStart
        Dim tmCurr
        Dim iTimeTaken
        Dim currentStatus
        Dim ado_stream
        Dim uploadCount, uploadStatus
        Set ado_stream = CreateObject("ADODB.Stream")
        ado_stream.Type = 1
        ado_stream.Open()
        On Error Resume Next
        ado_stream.LoadFromFile(local)
        If Err.Number <> 0 Then
          WScript.echo "doPUT() - Fatal Error encountered reading File : " & local & ". Status (" & Hex(Err.number)  & ") " & Err.Description
          Wscript.quit         
        End If
        On Error GoTo 0 
        HttpObject.Open "PUT", HTTPServer & remote, false
        If not IsNull(contentType) Then
          HttpObject.setRequestHeader "Content-type", contentType
        End If
        tmStart = Now
        On Error Resume Next
        HTTPObject.send(ado_stream.Read(-1))
        If Err.number <> 0 Then
          '  Unexpected errors can occur as a result of the HTTP request being passed to wrong database instance
          '  when multiple databases are using the same listener.
          WScript.echo "doPUT() - Fatal Error encountered uploading File : " & local & ". Status (" & Hex(Err.number)  & ") " & Err.Description
          WScript.quit
       Else
          currentStatus = HTTPObject.status
        End If
        On Error GoTo 0 
        uploadCount = 1
        uploadStatus = doHead(remote)
        Do While uploadStatus <> 200 and uploadCount < 6
          '  Unexpected errors can occur as a result of the HTTP request being passed to wrong database instance
          '  when multiple databases are using the same listener.
          spoolfile.writeline "Http Error encountered uploading " & local & " to " & HTTPServer & remote &". Status=" & currentStatus
          currentStatus = retryPUT(local,remote,contentType)
          uploadCount = uploadCount + 1
          uploadStatus = doHead(remote)
        Loop
        If uploadStatus = 200 Then
          tmCurr = Now
          spoolFile.writeLine "Uploaded File " & local & ". Elapsed Time = " & CInt(DateDiff("s", tmStart, tmCurr)) & " seconds."
        Else
          WScript.echo "doPUT - Fatal Error uploading file (" & HTTPServer & remote & ") : Status=" & HTTPObject.status
          WScript.quit
        End If
        doPut = currentStatus
        ado_stream.Close()
      End Function
      Public Function retryPUT(local,remote,contentType)
        Dim ado_stream
        Set ado_stream = CreateObject("ADODB.Stream")
        ado_stream.Type = 1
        ado_stream.Open()
        On Error Resume Next
        ado_stream.LoadFromFile(local)
        If Err.number <> 0 Then
          WScript.echo "doPUT() - Fatal Error encountered reading File : " & local & ". Status (" & Hex(Err.number)  & ") " & Err.Description
          Wscript.quit         
        End If
        On Error GoTo 0 
        HttpObject.Open "PUT", HTTPServer & remote, true
        If not IsNull(contentType) Then
          HttpObject.setRequestHeader "Content-type", contentType
        End If
        On Error Resume Next
        HTTPObject.send(ado_stream.Read(-1))
        If Err.Number <> 0 Then
          ado_stream.Close()
          WScript.echo "doPUT() - Fatal Error encountered sending File : " & local & " to " & HTTPServer & remote &". Status (" & Hex(Err.number)  & ") " & Err.Description & ". Retrying ...."
          Wscript.quit         
        Else   
          Do While HTTPObject.readyState <> 4
            WScript.Sleep(1000)
          Loop
        End If
        On Error GoTo 0 
        ado_stream.Close()
        retryPut =  HTTPObject.status         
      End Function
      Public Function doMKCOL(remote)
        ' wscript.echo "doMKCOL (" & HTTPServer & remote & ")"
        Dim currentStatus
        HttpObject.Open "MKCOL", HTTPServer & remote, false
        HttpObject.setRequestHeader "Content-type", "text/xml"
        On Error Resume Next
        HttpObject.send("")
        If Err.Number <> 0 Then
          WScript.echo "doMKCOL() - Fatal Error encountered making Folder : " & HTTPServer & remote &". Status (" & Hex(Err.number)  & ") " & Err.Description
          Wscript.quit         
        End If
        On Error GoTo 0 
        If  HTTPObject.status <> 201 Then
          WScript.echo "doMKCOL() - Fatal Error encountered making Folder : " & HTTPServer & remote &". Status (" & HTTPObject.status & ")."
          Wscript.quit         
        End If
        doMKCOL = HTTPObject.status
      End Function
      Public Function doDELETE(remote)
        HttpObject.Open "DELETE", HTTPServer & remote, false
        HttpObject.setRequestHeader "Content-type", "text/xml"
        On Error Resume Next
        HttpObject.send("")
        If Err.Number <> 0 Then
          WScript.echo "doMKCOL() - Fatal Error deleting : " & HTTPServer & remote &". Status (" & Hex(Err.number)  & ") " & Err.Description
          Wscript.quit         
        End If
        On Error GoTo 0 
        doDELETE = HTTPObject.status
        If HTTPObject.status <> 201  and HTTPObject.status <> 204 and HTTPObject.status <> 207 and HTTPObject.status <> 404 Then
          wscript.echo "doDELETE (" & HTTPServer & remote & ") : Status=" & HTTPObject.status
        End If
      End Function
    End Class

  • Open a draft report via Code

    How could I open an saved Draft report via API/UI.
    I have draft an report via API/UI and now I would show this report on Desktop/SAP
    I would open it via code
    z.B. application.forms.items("")
    because I get the Docnum of my before safed draft but It wouldn´t shown at the SAP now so I have to open it via code

    Sorry for my first Miss Understandable explanation.
    Ok let me explain the other times.
    I have a parked document, I want this now to open it via code (programming).
    I have this code today:
    programspeach: vb.net
    we assume we have a sales order and press now via code the menu option "Save as a parked document"
    ' to change the sales order in a parked document
    appl.ActivateMenuItem(("5907"))
    ' Information: MY_FormUID = the sales order before
    ' Change DocNum in DocEntry
    oRSTRDocData.DoQuery(("SELECT max(DocEntry) FROM ODRF WHERE DocNum=" & Value))
    appl.Forms.Item(MY_FormUID).Items.Item("txtDraft").Specific.Value = oRSTRDocData.Fields.Item(0).Value
    ' take the DocEntry
    Value = oRSTRDocData.Fields.Item(0).Value
    'open parked Document via DocEntry and let it show
    appl.Forms.Item(MY_FormUID).Items.Item("lnkDraft").Click(SAPbouiCOM.BoCellClickType.ct_Linked)
    ' Close the Sales Order before
    appl.Forms.Item(OLD_FormUID).Close()
    After this there is no Document opened, also not the parked Document
    So yet I have an parked Document but when I open the SBO again there is no Document Opened? When I do this prozedere via SBO there will be at least the parked Document opened.
    What do I wrong?

  • Stored Procedure parameter (@Carrier) used in report and can't be set via code

    I have a report that has regular Crystal parameters that I am setting correctly via code.  However, one report actually uses one of the database parameters from the stored procedure that the report was created from.  It is the only report like this and I'm using the same code in an attempt to set it's value.  Although no error is thown, if I look at the parameter value in the IDE it is set correctly, but the field on the report just shows up blank.  I have changed the way the report is created.  Previously, I used the report.export method to create the actual file via a stored procedure.  Now, I'm running the stored procedure first and creating a datatable.  This allows me to execute the SP only once to see if it has data, because only then do I want to create the actual report.  I'm using the SetDataSource method to pass the datatable into Crystal and then using the report.export method to create the report with data.  Everything seems to work, except this stored procedure parameter (@Carrier) is not actually being populated to display on the report.
    Not sure what to look at.  Any suggestions?
    Thanks.

    crpe32.dll is version 13.0.5.891.  This was developed in VS2012 and VB.NET.  I'm using ADO.Net to connect to a MS SQL Server database.
    MainReport.SetDataSource(DTbl)
    bRC = PopulateAllSubReports(MainReport)
    If Not bRC Then Throw New Exception("Received an error in PopulateAllSubReports.")
    bRC = PopulateCrystalParameters(MainReport, SP)
    If Not bRC Then Throw New Exception("Received an error in PopulateCrystalParameters.")
    'Actually create the output file.
    bRC = ExportData(MainReport)
    Private Function PopulateCrystalParameters(myReportDocument As ReportDocument, SP As ReportStoredProcedureCrystal) As Boolean
         Dim myParameterFieldDefinitions As ParameterFieldDefinitions = Nothing
         Dim myParameterFieldDefinition As ParameterFieldDefinition = Nothing, ParamValue As String = ""
         Dim bRC As Boolean, Param As SqlParameter = Nothing
         Try
         myParameterFieldDefinitions = myReportDocument.DataDefinition.ParameterFields
    '*********************Report Parameters***************************
         For Each myParameterFieldDefinition In myParameterFieldDefinitions
              myParameterFieldDefinition.CurrentValues.Clear()
              Select Case myParameterFieldDefinition.ParameterFieldName.Trim.ToUpper
              Case "@CARRIER"
                   If SP.DBParameters.ContainsKey("@CARRIER") Then
                        Param = SP.DBParameters("@CARRIER")
                        ParamValue = NullS(Param.Value).Trim
                        bRC = SetCurrentValueForParameterField(myParameterFieldDefinition, ParamValue)
                        If Not bRC Then Return False
                   End If                           
              End Select
         Next
         Return True
         Catch ex As Exception
         GmcLog.Error("ReportKey = " & Me.ReportKey.ToString & ", " & ex.Message, ex)
         Return False
         End Try
    End Function
    Private Function SetCurrentValueForParameterField(myParameterFieldDefinition As ParameterFieldDefinition, submittedValue As Object) As Boolean
         Dim currentParameterValues As ParameterValues = Nothing
         Dim myParameterDiscreteValue As ParameterDiscreteValue = Nothing
         Try
         myParameterDiscreteValue = New ParameterDiscreteValue
         myParameterDiscreteValue.Value = NullS(submittedValue).Trim
         currentParameterValues = New ParameterValues
         currentParameterValues.Add(myParameterDiscreteValue)
         myParameterFieldDefinition.ApplyCurrentValues(currentParameterValues)
         Return True
         Catch ex As Exception
         GmcLog.Error("ReportKey = " & Me.ReportKey.ToString & ", " & ex.Message, ex)
         Return False
         Finally
         myParameterDiscreteValue = Nothing
         currentParameterValues = Nothing
         End Try
    End Function
    Private Function SetDBSourceForSubReport(mySubReport As ReportDocument) As Boolean
         Dim myTables As Tables = Nothing, myTable As Table = Nothing, DTbl As DataTable, SP As StoredProcedure = Nothing
         Try
         myTables = mySubReport.Database.Tables
         For Each myTable In myTables
              Dim SPName As String = myTable.Location.Substring(0, myTable.Location.IndexOf(";"c))
              SP = New StoredProcedure(ConnectionString, SPName, CommandType.StoredProcedure)
              DTbl = SP.FillTable
              mySubReport.SetDataSource(DTbl)
              SP = Nothing
         Next
         Return True
         Catch ex As Exception
         GmcLog.Error("ReportKey = " & Me.ReportKey.ToString & ", " & ex.Message, ex)
         Return False
         Finally
         If Not SP Is Nothing Then SP = Nothing
         If Not myTable Is Nothing Then myTable = Nothing
         If Not myTables Is Nothing Then myTables = Nothing
         End Try
    End Function
    Private Function PopulateAllSubReports(myReportDocument As ReportDocument) As Boolean
         Try
         Dim mySections As Sections = myReportDocument.ReportDefinition.Sections
         For Each mySection As Section In mySections
              Dim myReportObjects As ReportObjects = mySection.ReportObjects
              For Each myReportObject As ReportObject In myReportObjects
                   If myReportObject.Kind = ReportObjectKind.SubreportObject Then
                        Dim mySubreportObject As SubreportObject = CType(myReportObject, SubreportObject)
                        Dim subReportDocument As ReportDocument = mySubreportObject.OpenSubreport(mySubreportObject.SubreportName)
                        Dim bRC = SetDBSourceForSubReport(subReportDocument)
                        If Not bRC Then Return False
                   End If
              Next
         Next
         Return True
         Catch ex As Exception
         GmcLog.Error("ReportKey = " & Me.ReportKey.ToString & ", " & ex.Message, ex)
         Return False
         End Try
    End Function

  • Generate Excel file via code

    Hi,
    I know the user can export an Excel file once the report viewer is loaded, but I was wondering if it's possible to generate an Excel file via code (no viewer loaded)?
    thanks,
    Ron

    Yup.
    You can find export samples in our [Crystal Reports .NET SDK samples|https://www.sdn.sap.com/irj/boc/sdklibrary?rid=/library/uuid/d0bf8496-2a81-2b10-95ac-b1f48d5b63f5]
    Jason

  • Via Code : Creating Org. Unit and Position and assignment of User ID to Position

    Hello,
    I am looking for code which will create Org. Unit and creates Position in it. Also the User IDs should be assigned to the Position via code.
    I do this via PPOC but would like to automate this process.
    Will appreciate your kind help.
    Thank you!
    Naina..

    Dear Naina,
    SAP has given the multiple option to create the units ( Org. Unit, Position, Job, cost center, etc). The best ways to use tcode-pp01 (Maintain object)
    Plan version- current Plan
    Object type-Org unit or Position or Job or other as per requirement
    infotype name- select object
    Time period :- 11.03.2014 to 31.12.9999
    then create- fill the required & save
    Example:- Creation of organisation unit
    Tcode-pp01
    Plan version- current Plan
    Object type-Org unit
    Time period :- 11.03.2014 to 31.12.9999
    infotype name-  Object (select)
    then create (F5)
    Object Abbration:- HR Department
    save
    After, system ask
    Relationship type -A002
    Type of related object- organisation unit (default)
    ID of related :- Give the eight digit number
    In the similar way, we can create other units.
    All the best!
    Regards,
    Rakesh

  • Set JCO CLient via code

    Hi All,
    I need to use the same WD for several R/3 clients.
    Is there a way that I could use several JCO reference and there for set the modeldata and the metadata reference that I need via code.
    Regards,
    Orlando Covault

    Hi,
    There are tow options for JCO creations:
    1: If you know at design time which JCO connections you want to use and that they are available on your system: create a Model for every connection.
    2: If you want to create these connections dynamically change the JCO connection everytime you call your model like this:
    IWDDynamicRFCModel model;
    model = (IWDDynamicRFCModel) WDModelFactory.getModelInstance(ModelName.class);
    model.setJcoClient(connection)
    --> continue calling code.
    or:
    model.setSystemName(<<JCO ClientName>>)
    see: http://help.sap.com/javadocs/NW04S/current/wd/com/sap/tc/webdynpro/modelimpl/dynamicrfc/IWDDynamicRFCModel.html
    Also you can refer the blog from Anilkumar Vippagunta at
    /people/anilkumar.vippagunta2/blog/2007/02/06/dynamic-jco-creation
    regards
    amit bagati

  • Lock particular warehouse for particular item via code

    hi all,
    i need particular warehouse locked for particular item via code.
    i designed one form   header have item code and warehouse.
    when i press the add button warehouse locked for that particular item.
    Thanks & Regards
    Sudhir.B

    The answer is:
    Using the Items Object of the DI, set yourself to the correct line and set the locked property.
    for(i=0;i<oItem.WhsInfo.Count;i++)
         oItem.WhsInfo.SetCurrentLine(i);
         if(oItem.WhsInfo.WarehouseCode == "CodeOnTheForm")
              oItem.WhsInfo.Locked = SAPbobsCOM.BoYesNoEnum.tYES;

  • Dropping down a drop-down list via code

    I wish to make drop-down list expand when you enter the field (or via code) in addition to the normal drop down action when clicking on the arrow.

    There is an openList() method that you can fire on the enter event, for example
    // form1.page1.dd::enter - (JavaScript, client)
    xfa.host.openList(form1.page1.dd);
    but the list does not remain open.
    I see a reference to a known problem, but not necessarily the same problem, at http://kb2.adobe.com/cps/405/kb405021.html . The solution does not have any effect in Acrobat/Reader 9.1.
    Steve

  • How to display a popup window (DialogMessage) via code behind c#?

    hi all,
    How to display a popup window (DialogMessage) via code behind c#?
    I use sp 2013, in else case I want show the DialogMessage:
    if(condition)
    else
      HttpContext.Current.Response.Redirect(SPContext.Current.Web.Url+"/_layouts/TestError/ErrorDueDate.aspx");
    the above Redirect work good but I want show the error in a DialogMessage its better because of Usability and not redirect the user to new page...
    if not via code behind is there a better way to do it?
    thanks in advance
    Ahmad
    SP 2013 & SPD 2013 & VS 2013 & MSSQL 2012

    thanks for you answer,
    And yes I includ them via CDN, like below:
    <script
    type="text/javascript"
    src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script
    src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js"
    type="text/javascript"></script>
    <link
    href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/start/jquery-ui.css"
    rel="stylesheet" type="text/css"
    />
    But I get still the above error in my previes post.
    SP 2013 & SPD 2013 & VS 2013 & MSSQL 2012

  • Ultiboard v5.72 via code default back to original values – help please!

    Hi
    I’m prototyping a fairly simple double sided board. I’m using the internal single pass auto router. I’m quite happy to have vias in the design but they need to be fairly large. Consequently before beginning the auto router I modified via size 0 to be :
    X1=40mil X2=40mil Y=80mil RAD=40mil Clear=40mil Drill=40mil      ‘apply’
    After entering the sizes I get a warning window “you have changed the via sizes – please verify your production class to achieve best (auto) routing
    I then click on ‘ok’ to acknowledge the warning. The values I have changed at this moment are still the ones I chose. I then click auto route../..production class 4M and it begins to route but does not use the dimensions of the via code I modified, if fact when I interrogate the via sizes after the route is complete, they have defaulted back to the original values !!
    Have I not set some parameter or sommat? Any help would be appreciated
    Regards ……. acekiddy

    I say this not to be a jerk, but I don't think your going to get any help on this. Even 3 years ago they were up to version 7..........as of todays date, its version 10.......and in a month or two it will be version 11.......I doubt there is any support for 5.72.
    What does the help file say about drill hole and via diameters? Those archaic bitmap autorouters sucked big then, and still do. Since version 8 its vector based and a lot more robust. I would suggest you download the eval 10 and give that a whirl.....just a thought. I haven't used 5.72 in over 9 years......sorry I can't be of more help.
    Message Edited by kittmaster on 01-10-2008 11:35 AM
    Signature: Looking for a footprint, component, model? Might be here > http://ni.kittmaster.com

  • Allow desktop interaction within Azure Cloud Service with third-party desktop app (automated via code)

    Hello,
    I am developing a wrapper service as Worker Role which will take request from Service Bus and automate a third-party desktop app to produce an output file and then upload result back to our web server.  The automation is accomplished with the app's
    built-in .Net remoting based API.  This all works on my local development machine.  I am using code as below to start the desktop app.  In Azure:
    If I am not logged on to RDP and run the app as SYSTEM (or whatever the default WorkerRole account is), it waits forever for the MainWindowHandle.
    if I start the app manually in the RDP and try to get a reference to the running process (again as SYSTEM), I get Access Denied from WaitForInputIdle.
    if I start the app from code as the RDP user (ProcessStartInfo assign user/pass), I get InvalidOperationException - the app might not have a graphical interface from the WaitForInputIdle.
    Could anyone suggest the proper strategy for starting processes in a Worker Role that must create a window?
    For reference, I only care about the window to the extent that I need to make sure it's there.  All other interaction with the process is via the .Net Remoting API.
    private void GetOrStartThirdPartApp()
    _process = Process.GetProcessesByName("ThirdPartApp").FirstOrDefault();
    if (_process == null)
    _process = new Process();
    _process.StartInfo.Arguments = string.Format(@"-I ""{0}""", config.GetSetting("RolePath"));
    _process.StartInfo.WorkingDirectory = config.GetSetting("WorkingFolder");
    _process.StartInfo.FileName = config.GetSetting("ExecutablePath");
    _process.StartInfo.LoadUserProfile = true;
    _process.StartInfo.UseShellExecute = false;
    if (config.GetSettingAsBoolean("StartThirdPartAppWithRunAs", false))
    _process.StartInfo.UserName = "user";
    var password = new SecureString();
    foreach (var c in "thepassword".ToCharArray())
    password.AppendChar(c);
    _process.StartInfo.Password = password;
    _process.Start();
    while (_process.MainWindowHandle == IntPtr.Zero) Thread.Sleep(50);
    _process.WaitForInputIdle();
    _process.Exited += _process_Exited;

    I'd keep the app with the UI and the queue reader in the same process and account - not a worker role.  On start up you launch the desktop application and the queue reader in the same account, one after another.
    From what I've experienced, two users don't have the same
    Window Stations, so you can't pass a window handle in a different logged-in account across that boundary.  Read the Window Station documentation - you may find something that helps.
    You could use other techniques like sockets to communicate cross-process and cross-window station, too.
    Darin R.

  • Attach BP Url via Code

    Hi experts!!
    I am using cl_crm_documents=>create_with_url to create attachments via URL, in BPs. The problem is that the attachments are uploaded as application/octet-stream, hence i cannot open . When i manually attach URLs to BP they are displayed fine.
    Any ideas?????
    Here's the code i've written.. Am i missing something??
      ls_url-line = 'http://www.google.com'.
      APPEND ls_url TO url.
      unpack businesspartner to ls_part.
      SELECT SINGLE * FROM but000 INTO ls_but000
                      WHERE partner = ls_part.
      BREAK-POINT.
      ls_bus_obj-instid = ls_but000-partner_guid.
      ls_bus_obj-typeid = 'BUS1006'. "(for business partner)
      ls_bus_obj-catid = 'BO'. "(for business object)
      pro_LS-NAME = 'CONTENT_URL'.
      PRO_LS-VALUE = 'http://www.google.com'.
      APPEND PRO_LS TO PRO.
      pro_LS-NAME = 'KW_RELATIVE_URL'.
      PRO_LS-VALUE = 'Application_form'.
      APPEND PRO_LS TO PRO.
      pro_LS-NAME = 'DESCRIPTION'.
      PRO_LS-VALUE = 'Description'.
      APPEND PRO_LS TO PRO.
      pro_LS-NAME = 'LOIO_CLASS'.
      PRO_LS-VALUE = 'CRM_L_URL'.
      APPEND PRO_LS TO PRO.
      pro_LS-NAME = 'PHIO_CLASS'.
      PRO_LS-VALUE = 'CRM_L_URL'.
      APPEND PRO_LS TO PRO.
      CALL METHOD cl_crm_documents=>create_with_url
        EXPORTING
          url             = url
       properties      =
        properties = pro
          business_object = ls_bus_obj
       parent_folder   =
        IMPORTING
          loio            = lt_loio
        phio            = lt_phio
        error           = lt_error

    Actually Problem is now Solved!!
    Insted of using method CREATE_WITH_URL i used CREATE_URL.
    Here's the code..
      ls_url-line = 'http://www.google.com'.
      APPEND ls_url TO url.
      unpack businesspartner to ls_part.
      SELECT SINGLE * FROM but000 INTO ls_but000
                      WHERE partner = ls_part.
      BREAK-POINT.
      ls_bus_obj-instid = ls_but000-partner_guid.
      ls_bus_obj-typeid = 'BUS1006'. "(for business partner)
      ls_bus_obj-catid = 'BO'. "(for business object)
      pro_LS-NAME = 'CONTENT_URL'.
      PRO_LS-VALUE = 'http://www.google.com'.
      APPEND PRO_LS TO PRO.
      pro_LS-NAME = 'DESCRIPTION'.
      PRO_LS-VALUE = 'Description'.
      APPEND PRO_LS TO PRO.
      CALL METHOD cl_crm_documents=>create_url
        EXPORTING
          url             = url
       properties      =
        properties = pro
          business_object = ls_bus_obj
       parent_folder   =
        IMPORTING
          loio            = lt_loio
        phio            = lt_phio
        error           = lt_error
    BREAK-POINT.
    CALL METHOD cl_crm_documents=>rename_object
      EXPORTING
        is_io             = lt_loio
        iv_name           = 'Application'
      IMPORTING
        es_error          = lt_error
      EXCEPTIONS
        io_not_renameable = 1
        name_error        = 2
        others            = 3
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  • Netbeans: adding to jPanel via code after init (jFreeChart)

    This will be my second post. Many thanks to those who replied to my first questions.
    I am using netbeans 5.5
    I am attempting to run the following jFreeChart demo but in netbeans.
    Original demo located here: http://www.java2s.com/Code/Java/Chart/JFreeChartPieChartDemo7.htm
    Instead of programically creating the jPanel like the demo does, i would like to do it using the netbeans GUI and then add the code to create the jFreeChart.
    In netbeans i create a new project, create a new jFrame and place a new jPanel on the form (keeping the variable name jPanel1) as illustrated below:
    * MainForm.java
    * Created on June 28, 2007, 1:48 PM
    package mypkg;
    import org.jfree.chart.ChartFactory;
    import org.jfree.chart.ChartPanel;
    import org.jfree.chart.JFreeChart;
    import org.jfree.chart.plot.PiePlot;
    import org.jfree.chart.plot.PiePlot3D;
    import org.jfree.data.general.DefaultPieDataset;
    import org.jfree.ui.ApplicationFrame;
    import org.jfree.ui.RefineryUtilities;
    * @author  me
    public class MainForm extends javax.swing.JFrame {
        /** Creates new form MainForm */
        public MainForm() {
            initComponents();
        /** Netbeans Auto-Generated Code goes here which I have omitted */                       
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new MainForm().setVisible(true);
        private void CreateChart() {
            DefaultPieDataset dataset = new DefaultPieDataset();
            dataset.setValue("Section 1", 23.3);
            dataset.setValue("Section 2", 56.5);
            dataset.setValue("Section 3", 43.3);
            dataset.setValue("Section 4", 11.1);
            JFreeChart chart3 = ChartFactory.createPieChart3D("Chart 3", dataset, false, false, false);
            PiePlot3D plot3 = (PiePlot3D) chart3.getPlot();
            plot3.setForegroundAlpha(0.6f);
            plot3.setCircular(true);
            jPanel1.add(new ChartPanel(chart3));
            jPanel1.validate();
        // Variables declaration - do not modify                    
        private javax.swing.JPanel jPanel1;
        // End of variables declaration                  
    }I then attempted to call the CreateChart() function in several places (in the MainForm() function, in the pre and post creation code properties of the jPanel's properties dialog in netbeans (as well as pre and post init in the same screen)) and nothing seems to work. the program compiles and the jFrame comes up but the chart does not show.
    If i run the example at the above noted link it runs fine in netbeans if i copy and paste the code directly, it just doesnt work when i try to get it to work through the netbeans GUI builder and the jPanel i create through it.
    Can any more advanced netbeans/java users lend me a hand or point me in the right direction?
    NOTE: in the code pasted above, i am only trying to run one of the four chart demo's listed in the original source in the link.
    NOTE2: in the code pasted above it doesnt show me calling CreateChart() from anywhere, im hoping to get some advice on how to proceed from here.
    Message was edited by:
    amadman

    Here is the netbeans generated code that i had omitted in the post above:
    private void initComponents() {
            jPanel1 = new javax.swing.JPanel();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            CreateChart(); //this is one of the many places i tried sticking the function
            javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 546, Short.MAX_VALUE)
            jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 398, Short.MAX_VALUE)
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap())
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap())
            pack();
        }// </editor-fold>   I believe this is what you mentioned looking for, or close to it:
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);any thoughts?

Maybe you are looking for