Could Constructor return null?
Hi everybody,
Could we let a constructor return null?
I think this is an easy way to let caller know we
can't create such an object.
Thanks in advance.
as cited before, you should prefer the exception handling .. but, just for your curiousity:
public class NullDemo
static public void main(String[] args)
System.out.println(Example.createAnExample(new String[]{"all ", "right"}));
System.out.println(Example.createAnExample(null));
class Example
final String text;
private Example(String[] args)
String temp = "";
for(int i=0; i<args.length; i++)
temp += args;
text = temp;
//i = i/0;
static public Example createAnExample(String[] args)
try
Example e = new Example(args);
return e;
catch(Exception error)
return null;
public String toString()
return text;
Similar Messages
-
Can a constructor return 'null'?
Consider the following code snippit.
MyClass myObj = new MyClass();Is it safe to say that myObj IS NOT NULL?
Of course the constructor may have created a useless object, but the object reference itself (myObj) shouldn't be null. Correct?
Also, I realize that the constructor might throw an exception or something like that, but that's a different issue.Of course the constructor may have created auseless
object, but the object reference itself (myObj)
shouldn't be null. Correct?Right, new will return a non-null object.<pb>
new returns a non-null reference to an object.
</pb>
Also, I realize that the constructor might throwan
exception or something like that, but that's a
different issue.I'm not sure what happens when the constructor throws
an exception, I've never written a constructor to
throw one. Write a simple program to test it. Create
a class that does nothing but throw an exception in
the constructor, then in main, try to instantiate it.
In the catch block, access the reference to see if
it's null.
try {
Foo foo = new foo(); // ctor throws exception
catch (Exception exc) {
System.out.println(foo); // won't compile, foo is not in scope
Foo foo;
try {
foo = new foo(); // ctor throws exception
catch (Exception exc) {
System.out.println(foo); // won't compile, foo might not have been set.
}If the c'tor throws an exception, it doesn't return a value, the assignment statement completes abrubtly, and nothing is assigned to the variable. -
Query returns null pointer as result
Hi,
I have a problem retrieving objects with Query. Wenn I lookup an object
with the following method:
Query q = pm.newQuery(classObj);
q.declareParameters("String param");
q.setFilter(fieldName + " == param");
ans = (Collection)q.execute(searchValue);
if (ans.isEmpty())
return null;
Iterator i = ans.iterator();
if (i.hasNext())
Object obj = i.next();
q.close(ans);
return obj;
throw new IllegalArgumentException("No object with code: '" +
searchValue + "'");
catch (Exception e)
if (ans != null)
q.close(ans);
throw e;Hi Martin,
before this problem started to, I have changed the MappingFactory from
"db" to "file" and then back. I also deleted the jdo_mapping table
inbetween and reconsturcted it with the mapping tool. From then on, it
would not find the object anymore. The object that I wanted to get at is
in the database and an empty object is constructed, which I knew from
putting a breakpoint in the constructor.
Because I am not in production yet, I could just delete the database and
start from scratch. Which cured the problem, but as soon as we will be
online, that is not an option anymore, I guess.
Let me know, if you need more help to reproduce this problem.
Best regards
Wolfgang -
Hello,
I'm currently using Java 5.0 (especially for the Generics part) on a new Java/J2EE project, but having a strange issue with code working previously in a Java 1.4 project.
Below is an overriding of the toString() method provided by the Object class which allow me to view nicely in debug (dev. mode) the contents of my Transfer Objects (all the TO's must extend this ATO abstract class).
Previously this code displayed me something like:
[field1 => value1, field2 => value2] ... for a TO (sort of "Javabean") having e.g. two String fields with values initialized to "value1" (resp. "value2").
But unfortunately, this does (or seems) not to work anymore, having such display :
[field1 => null, field2 => null]I tried to debug, and the problem is that the call fieldValue = field.get(this); returns null while it should returns the actual value of the field.
I thing it it strongly related to Generics, but could not at the moment found how/why it does not work.
May someone help...? Thanks.
public abstract class ATO {
// Reflection for field value display
public String toString() {
StringBuffer sb = new StringBuffer("[");
MessageFormat mf = new MessageFormat("{0} => {1}, ");
Field[] fields = this.getClass().getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
Field field = (Field) fields;
String fieldName = field.getName();
Object fieldValue = null;
try {
fieldValue = field.get(this);
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
mf.format(new Object[] { fieldName, fieldValue }, sb, null);
if (sb.length() > 1) {
sb.setLength(sb.length() - 2);
sb.append("]");
return sb.toString();ejp wrote:
Field field = (Field) fields;
This cast is unnecessary.
Effectively, I haven't noticed it yet. Fixed.
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
}Either the field value really is null or you are getting one of these exceptions which you are ignoring. Never write empty catch blocks.That's true, I missed something. Fixed with some code to log the eventual exceptions.
Thanks for you answer. -
FrameGrabbingControl returns null
In my code i want to grab a frame from a video and displey it in another window.But the problem is that " FrameGrabbingControl fgc =(FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");" returns null.Please help me by pionting out the error. Thanks in advance.
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.lang.Thread;
import java.util.*;
import java.lang.*;
import java.lang.String;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.IOException;
import java.util.Properties;
import javax.media.*;
import java.applet.*;
import javax.swing. *;
import javax.swing.border. *;
import javax.media.datasink. *;
import javax.media.format. *;
import javax.media.protocol. *;
import javax.media.util. *;
import javax.media.control. *;
import java.awt.image. *;
import com.sun.image.codec.jpeg. *;
import com.sun.media.protocol.vfw.VFWCapture;
import java.io.*;
import javax.media.control.FrameGrabbingControl;
//import com.sun.media.util.JMFSecurity;
* This is a Java Applet that demonstrates how to create a simple
* media player with a media event listener. It will play the
* media clip right away and continuously loop.
* <!-- Sample HTML
* <applet code=SimplePlayerApplet width=320 height=300>
* <param name=file value="sun.avi">
* </applet>
* -->
public class grabframe extends Applet implements ControllerListener,ActionListener
static int shotCounter = 1;
Button button;
// media Player
Player player = null;
// component in which video is playing
Component visualComponent = null;
// controls gain, position, start, stop
Component controlComponent = null;
// displays progress during download
Component progressBar = null;
boolean firstTime = true;
long CachingSize = 0L;
Panel panel = null;
int controlPanelHeight = 0;
int videoWidth = 0;
int videoHeight = 0;
* Read the applet file parameter and create the media
* player.
public void init()
setLayout(new BorderLayout());
setBackground(Color.white);
panel = new Panel();
//panel.setLayout( null );
add(panel,BorderLayout.SOUTH);
panel.setBounds(0, 0, 320, 240);
button=new Button("GRAB FRAME");
panel.add(button);
button.addActionListener(this);
// input file name from html param
String mediaFile = null;
// URL for our media file
MediaLocator mrl = null;//MediaLocator describes the location of the media content while
URL url = null;//URL specify the location of the media
// Get the media filename info.
// The applet tag should contain the path to the
// source media file, relative to the html page.
if ((mediaFile = getParameter("file")) == null)
Fatal("Invalid media file parameter");
//System.out.println("mediafile :"+mediaFile);
try
url = new URL(getDocumentBase(), mediaFile);//return a new URL using an existing URL as reference
// System.out.println("url :"+url);
mediaFile = url.toExternalForm();//return a string representation of the URL
// System.out.println("mediafile :"+mediaFile);
catch (MalformedURLException mue)
try
// Create a media locator from the file name
if ((mrl = new MediaLocator(mediaFile)) == null)
Fatal("Can't build URL for " + mediaFile);
// Create an instance of a player for this media
try
player = Manager.createPlayer(mrl);
catch (NoPlayerException e)
System.out.println(e);
Fatal("Could not create player for " + mrl);
/* catch (CannotRealizeException e)
System.out.println(e);
Fatal("Could not create player for " + mrl);
// Add ourselves as a listener for a player's events
player.addControllerListener(this);
catch (MalformedURLException e)
Fatal("Invalid media file URL!");
catch (IOException e)
Fatal("IO exception creating player for " + mrl);
// This applet assumes that its start() calls
// player.start(). This causes the player to become
// realized. Once realized, the applet will get
// the visual and control panel components and add
// them to the Applet. These components are not added
// during init() because they are long operations that
// would make us appear unresposive to the user.
}//end of init
* Start media file playback. This function is called the
* first time that the Applet runs and every
* time the user re-enters the page.
public void start()
//$ System.out.println("Applet.start() is called");
// Call start() to prefetch and start the player.
if (player != null)
player.start();
* Stop media file playback and release resource before
* leaving the page.
public void stop()
//$ System.out.println("Applet.stop() is called");
if (player != null)
player.stop();
player.deallocate();
public void destroy()
//$ System.out.println("Applet.destroy() is called");
player.close();
* This controllerUpdate function must be defined in order to
* implement a ControllerListener interface. This
* function will be called whenever there is a media event
public synchronized void controllerUpdate(ControllerEvent event)
// If we're getting messages from a dead player,
// just leave
if (player == null)
return;
// When the player is Realized, get the visual
// and control components and add them to the Applet
if (event instanceof RealizeCompleteEvent)
if (progressBar != null)
panel.remove(progressBar);
progressBar = null;
int width = 320;
int height = 0;
if (controlComponent == null)
if (( controlComponent = player.getControlPanelComponent()) != null)
//controlPanelComponent provides the default user interface for controlling the player
controlPanelHeight = controlComponent.getPreferredSize().height;
panel.add(controlComponent);
height += controlPanelHeight;
if (visualComponent == null)
if (( visualComponent = player.getVisualComponent())!= null)
//visualComponent provides display component(where the visual media is recorded) of the player
panel.add(visualComponent,BorderLayout.CENTER);
Dimension videoSize = visualComponent.getPreferredSize();
videoWidth = videoSize.width;
videoHeight = videoSize.height;
width = videoWidth;
height += videoHeight;
visualComponent.setBounds(0, 0, videoWidth, videoHeight);
panel.setBounds(0, 0, width, height);
if (controlComponent != null)
controlComponent.setBounds(0, videoHeight,width, controlPanelHeight);
controlComponent.invalidate();
} //end of RearizedCompleteEvent
else if (event instanceof CachingControlEvent)
if (player.getState() > Controller.Realizing)
return;
// Put a progress bar up when downloading starts,
// take it down when downloading ends.
CachingControlEvent e = (CachingControlEvent) event;
CachingControl cc = e.getCachingControl();
// Add the bar if not already there ...
if (progressBar == null)
if ((progressBar = cc.getControlComponent()) != null)
panel.add(progressBar);
panel.setSize(progressBar.getPreferredSize());
validate();
} //end of CashingControlEvent
else if (event instanceof EndOfMediaEvent)
// We've reached the end of the media; rewind and
// start over
player.setMediaTime(new Time(0));
player.start();
} //end of EndOfMediaEvent
else if (event instanceof ControllerErrorEvent)
// Tell TypicalPlayerApplet.start() to call it a day
player = null;
Fatal(((ControllerErrorEvent)event).getMessage());
}//end of ControllerErrorEvent
else if (event instanceof ControllerClosedEvent)
panel.removeAll();
}//end of ControllerClosedEnent
}//end of controller update
void Fatal (String s)
// Applications will make various choices about what
// to do here. We print a message
System.err.println("FATAL ERROR: " + s);
throw new Error(s); // Invoke the uncaught exception
// handler System.exit() is another
// choice.
public void actionPerformed(ActionEvent ae)
Dimension imageSize = null;
String str=ae.getActionCommand();
if(str.equals ("GRAB FRAME"))
Image photo = grabFrameImage();
if (photo != null)
MySnapshot snapshot = new MySnapshot(photo, new Dimension(imageSize));
else
System.err.println("Errore : Impossibile grabbare il frame");
repaint();
* Grabba un frame dalla webcam @restituisce il frame in un buffer
public Buffer grabFrameBuffer()
if (player != null)
FrameGrabbingControl fgc =(FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");
System.out.println(fgc );
if (fgc != null)
return (fgc.grabFrame());
else
System.err.println("Errore : FrameGrabbingControl non disponibile");
return (null);
else
System.err.println("Errore nel Player");
return (null);
* Converte il buffer frame in un'immagine
public Image grabFrameImage()
Buffer buffer = grabFrameBuffer();
if (buffer != null)
BufferToImage btoi = new BufferToImage((VideoFormat) buffer.getFormat());
if (btoi != null)
Image image = btoi.createImage(buffer);
if (image != null)
return (image);
else
System.err.println("Errore di conversione Buffer - BufferToImage");
return (null);
else
System.err.println("Errore nella creazione di BufferToImage");
return (null);
else
System.out.println("Errore: buffer vuoto");
return (null);
class MySnapshot extends JFrame
protected Image photo = null;
protected int shotNumber;
public MySnapshot(Image grabbedFrame, Dimension imageSize)
super();
shotNumber = shotCounter++;
setTitle("Immagine" + shotNumber);
photo = grabbedFrame;
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
int imageHeight = photo.getWidth(this);
int imageWidth = photo.getHeight(this);
setSize(imageSize.width, imageSize.height);
final FileDialog saveDialog = new FileDialog(this,"Salva immagine", FileDialog.SAVE);
final JFrame thisCopy = this;
saveDialog.setFile("Immagine" + shotNumber);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
saveDialog.show();
String filename = saveDialog.getFile();
if (filename != null)
if (saveJPEG(filename))
JOptionPane.showMessageDialog(thisCopy,"Salvata immagine " + filename);
setVisible(false);
dispose();
else
JOptionPane.showMessageDialog(thisCopy,"Errore nel salvataggio di " + filename);
else
setVisible(false);
dispose();
setVisible(true);
public void paint(Graphics g)
g.drawImage(photo, 0, 0, getWidth(), getHeight(), this);
public boolean saveJPEG(String filename)
boolean saved = false;
BufferedImage bi = new BufferedImage(photo.getWidth(null), photo.getHeight(null), BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = bi.createGraphics();
g2.drawImage(photo, null, null);
FileOutputStream out = null;
try
out = new FileOutputStream(filename);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
param.setQuality(1.0f, false);
encoder.setJPEGEncodeParam(param);
encoder.encode(bi);
out.close();
saved = true;
catch (Exception ex)
System.out.println("Errore salvataggio JPEG: "+ ex.getMessage());
return (saved);
}//end of class SimplePlayerAppletHmm....
some of that looks very familiar to me :-)
http://forum.java.sun.com/thread.jspa?forumID=28&threadID=570463
1. post your code wrapped in code tags and it'll display it nicely.
2. post to the Java Media Framework topic,
I haven't tried JMF within an applet.
Have you tried getting it working in an application first ?
That should simplify your debugging to start with.
I suspect the Player hasn't started yet, or isn't in a realised state.
regards,
Owen -
I am trying to raise a event in one of classes of userControl, and Fire it in the Main class. I tried two different ways to fire this event, one of them works, But I still want to know why other way cannot work, and how to fix it.
My userContol class:
public partial class UserControl1 : UserControl
public UserControl1()
InitializeComponent();
if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
return;
Class1 c = new Class1();
Thread accept = new Thread(
() =>
c.connection();
accept.Start();
And the Class1:
public class Class1
public delegate void myhandler(object sender, EventArgs e);
public event myhandler test;
public Class1()
public void connection()
test(this, new EventArgs());
In the Main, I just simply add into referent, and add
xmlns:my="clr-namespace:WpfControlLibrary1;assembly=WpfControlLibrary1"
then I try to subscribe this event in the main
public partial class SurfaceWindow1 : SurfaceWindow
/// <summary>
/// Default constructor.
/// </summary>
public SurfaceWindow1()
InitializeComponent();
Class1 c = new Class1();
c.test+=new Class1.myhandler(c_test);
// Add handlers for window availability events
AddWindowAvailabilityHandlers();
public void c_test(object sender, EventArgs e)
MessageBox.Show("fire");
If I only raise this event not into thread, it works fine, but If I try to let it raise in this thread, this test event only return null, and shows:
Object reference not set to an instance of an object.
looks like I did not subscribe it ever. So How to fix it if I must use it in thread.Subscribing to events window to class is not a great approach.
You have to then go un subscribe those handlers in order to allow your instance to be disposed.
Forget that and you'll eventually notice you have memory leaks.
The way I do this sort of thing is using mvvm light messenger.
You can keep everything decoupled then.
http://social.technet.microsoft.com/wiki/contents/articles/26070.aspx
I just did a bit of code for someone else which shows how to do cross thread stuff with this approach.
public partial class MainWindow : Window
public MainWindow()
InitializeComponent();
Messenger.Default.Register<String>(this, (action) => ReceiveString(action));
private void ReceiveString(string msg)
MessageBox.Show(msg);
Dispatcher.BeginInvoke((Action)delegate()
tb.Text = msg;
private void Button_Click(object sender, RoutedEventArgs e)
Task.Factory.StartNew(() => {
Messenger.Default.Send<String>("Hello World");
Note that the message arrives on the thread it was sent from. That's not the ui thread because it was sent from that task.factory.startnew to deliberately put it on a different thread.
In order to change UI controls, it uses dispatcher.begininvoke to run code on the UI thread.
Although this is in one piece of code behind publisher and subscriber can be in two totally different classes which have no reference of knowledge of each other.
Meaning you can send a message<t> from any class1 or whatever you like and your mainwindow can subscribe and act of receipt of a message<t>.
It is the type which defines which message one is. You put data you want to send in t and use it in the subscriber.
Hope that helps.
Technet articles: Uneventful MVVM;
All my Technet Articles -
Call thirty party java web service but always return null
hi
I call a java web service in my application visual studio 2008 c#, but always return NULL.
I used Tool Fiddler to monitor the traffic between my client and the web service server, it showed the return is not Null.
Here is my code, please see if anything I do wrong.
namespace CanOfficer_THQ_vs_IHQ.TestWebReferenceAppointment {
using System.Diagnostics;
using System.Web.Services;
using System.ComponentModel;
using System.Web.Services.Protocols;
using System;
using System.Xml.Serialization;
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="AppointmentServiceSoapBinding", Namespace="http://service.ips.salvationarmy.org/")]
public partial class AppointmentService : Microsoft.Web.Services3.WebServicesClientProtocol {
private System.Threading.SendOrPostCallback deleteAppOperationCompleted;
private System.Threading.SendOrPostCallback importAppOperationCompleted;
private System.Threading.SendOrPostCallback editAppOperationCompleted;
private bool useDefaultCredentialsSetExplicitly;
/// <remarks/>
public AppointmentService() {
this.Url = global::CanOfficer_THQ_vs_IHQ.Properties.Settings.Default.CanOfficer_THQ_vs_IHQ_TestWebReferenceAppointment_AppointmentService;
if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
this.UseDefaultCredentials = true;
this.useDefaultCredentialsSetExplicitly = false;
else {
this.useDefaultCredentialsSetExplicitly = true;
public new string Url {
get {
return base.Url;
set {
if ((((this.IsLocalFileSystemWebService(base.Url) == true)
&& (this.useDefaultCredentialsSetExplicitly == false))
&& (this.IsLocalFileSystemWebService(value) == false))) {
base.UseDefaultCredentials = false;
base.Url = value;
public new bool UseDefaultCredentials {
get {
return base.UseDefaultCredentials;
set {
base.UseDefaultCredentials = value;
this.useDefaultCredentialsSetExplicitly = true;
/// <remarks/>
public event deleteAppCompletedEventHandler deleteAppCompleted;
/// <remarks/>
public event importAppCompletedEventHandler importAppCompleted;
/// <remarks/>
public event editAppCompletedEventHandler editAppCompleted;
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute(
RequestNamespace="http://service.ips.salvationarmy.org/",
ResponseNamespace="http://service.ips.salvationarmy.org/",
Use=System.Web.Services.Description.SoapBindingUse.Encoded,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("return", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string deleteApp([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] int id) {
object[] results = this.Invoke("deleteApp", new object[] {
id});
return ((string)(results[0]));
/// <remarks/>
public void deleteAppAsync(int id) {
this.deleteAppAsync(id, null);
/// <remarks/>
public void deleteAppAsync(int id, object userState) {
if ((this.deleteAppOperationCompleted == null)) {
this.deleteAppOperationCompleted = new System.Threading.SendOrPostCallback(this.OndeleteAppOperationCompleted);
this.InvokeAsync("deleteApp", new object[] {
id}, this.deleteAppOperationCompleted, userState);
private void OndeleteAppOperationCompleted(object arg) {
if ((this.deleteAppCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.deleteAppCompleted(this, new deleteAppCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute(
RequestNamespace="http://service.ips.salvationarmy.org/",
ResponseNamespace="http://service.ips.salvationarmy.org/",
Use=System.Web.Services.Description.SoapBindingUse.Encoded,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("return", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string importApp(
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] int person,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string name,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string territory,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string location,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] bool primary,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] Nullable<System.DateTime> start,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] Nullable<System.DateTime> end,
[System.Xml.Serialization.XmlElementAttribute("categories", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string[] categories) {
object[] results = this.Invoke("importApp", new object[] {
person,
name,
territory,
location,
primary,
start,
end,
categories});
return ((string)(results[0]));
/// <remarks/>
public void importAppAsync(int person, string name, string territory, string location, bool primary, Nullable<System.DateTime> start, Nullable<System.DateTime> end, string[] categories) {
this.importAppAsync(person, name, territory, location, primary, start, end, categories, null);
/// <remarks/>
public void importAppAsync(int person, string name, string territory, string location, bool primary, Nullable<System.DateTime> start, Nullable<System.DateTime> end, string[] categories, object userState) {
if ((this.importAppOperationCompleted == null)) {
this.importAppOperationCompleted = new System.Threading.SendOrPostCallback(this.OnimportAppOperationCompleted);
this.InvokeAsync("importApp", new object[] {
person,
name,
territory,
location,
primary,
start,
end,
categories}, this.importAppOperationCompleted, userState);
private void OnimportAppOperationCompleted(object arg) {
if ((this.importAppCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.importAppCompleted(this, new importAppCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute(
RequestNamespace="http://service.ips.salvationarmy.org/",
ResponseNamespace="http://service.ips.salvationarmy.org/",
Use=System.Web.Services.Description.SoapBindingUse.Encoded,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("return", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string editApp(
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] int id,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string name,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string territory,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string location,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] bool primary,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] Nullable<System.DateTime> start,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] Nullable<System.DateTime> end,
[System.Xml.Serialization.XmlElementAttribute("categories", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string[] categories) {
object[] results = this.Invoke("editApp", new object[] {
id,
name,
territory,
location,
primary,
start,
end,
categories});
return ((string)(results[0]));
/// <remarks/>
public void editAppAsync(int id, string name, string territory, string location, bool primary, Nullable<System.DateTime> start, Nullable<System.DateTime> end, string[] categories) {
this.editAppAsync(id, name, territory, location, primary, start, end, categories, null);
/// <remarks/>
public void editAppAsync(int id, string name, string territory, string location, bool primary, Nullable<System.DateTime> start, Nullable<System.DateTime> end, string[] categories, object userState) {
if ((this.editAppOperationCompleted == null)) {
this.editAppOperationCompleted = new System.Threading.SendOrPostCallback(this.OneditAppOperationCompleted);
this.InvokeAsync("editApp", new object[] {
id,
name,
territory,
location,
primary,
start,
end,
categories}, this.editAppOperationCompleted, userState);
private void OneditAppOperationCompleted(object arg) {
if ((this.editAppCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.editAppCompleted(this, new editAppCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
/// <remarks/>
public new void CancelAsync(object userState) {
base.CancelAsync(userState);
private bool IsLocalFileSystemWebService(string url) {
if (((url == null)
|| (url == string.Empty))) {
return false;
System.Uri wsUri = new System.Uri(url);
if (((wsUri.Port >= 1024)
&& (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) {
return true;
return false;
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
public delegate void deleteAppCompletedEventHandler(object sender, deleteAppCompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class deleteAppCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal deleteAppCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
/// <remarks/>
public string Result {
get {
this.RaiseExceptionIfNecessary();
return ((string)(this.results[0]));
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
public delegate void importAppCompletedEventHandler(object sender, importAppCompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class importAppCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal importAppCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
/// <remarks/>
public string Result {
get {
this.RaiseExceptionIfNecessary();
return ((string)(this.results[0]));
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
public delegate void editAppCompletedEventHandler(object sender, editAppCompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.5483")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class editAppCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal editAppCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
/// <remarks/>
public string Result {
get {
this.RaiseExceptionIfNecessary();
return ((string)(this.results[0]));Hi;
I used Fiddler to monitor the process, and it showed the request sent thru web service worked and returned a value, but in my .Net application the return captured as NULL. Could you please look into the code above and the result from Filddler and see if
you can help.
thank you.
REQUEST:
POST https://159.253.140.178/services/AppointmentService HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.4252)
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Host: 159.253.140.178
Content-Length: 1589
Expect: 100-continue
Connection: Keep-Alive
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://service.ips.salvationarmy.org/" xmlns:types="http://service.ips.salvationarmy.org/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
<soap:Header>
<wsse:Security mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>
[email protected]
</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
tpi4IPSws!
</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<tns:importApp>
<person xsi:type="xsd:int">
169275
</person>
<name xsi:type="xsd:string">
Corps Officer (Cahul-Russia) Test12
</name>
<territory xsi:type="xsd:string">
CAN
</territory>
<location xsi:type="xsd:string">
TEST LOCATION 12
</location>
<primary xsi:type="xsd:boolean">
true
</primary>
<start xsi:type="xsd:dateTime">
2013-05-30T00:00:00
</start>
<end xsi:type="xsd:dateTime">
2014-06-04T00:00:00
</end>
<categories href="#id1" />
</tns:importApp>
<soapenc:Array id="id1" soapenc:arrayType="xsd:string[1]">
<Item>
vpsCat1
</Item>
</soapenc:Array>
</soap:Body>
</soap:Envelope>
RESPONSE:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=UTF-8
Content-Length: 232
Date: Fri, 05 Sep 2014 19:45:22 GMT
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:importAppResponse xmlns:ns2="http://service.ips.salvationarmy.org/">
<return>
OK_572463
</return>
</ns2:importAppResponse>
</soap:Body>
</soap:Envelope> -
Awt.toolkit returns null
Hi all, I've discovered that the awt.toolkit system property returns null on the linux server hosting a java web application am working on. I've listed some of the AWT system properties on the system but the awt.toolkit returns null.
java.awt.graphicsenv: = sun.awt.X11GraphicsEnvironment
java.awt.headless: = ture
awt.toolkit: = null
I really dont know what could be causing this.
This affects all image related proceses (dynamic image creation) that the application does. It outputs the following error message:
java.lang.NoClassDefFoundError
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:141)
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)I dont think it has anything to do with X11, XServer or Headless.
Any thoughts ?
CheersIt hs something to do with a missing X11 server/the machine being headless. I faced a similar problem recently.
-
What's the meaning of "SID to Group returns null"
hi, I configure a ATN in WLS, and the ATN log shows:
<2005-10-2 ????01??28??05?? CST> <Debug> <SecurityDebug> <000000>
<returnConnection conn:LDAPConnection {ldap://localhost:389 ldapVersion:3
bindDN:"CN=weblogic,CN=Users,DC=mydavid,DC=org"}>
<2005-10-2 ????01??28??05?? CST> <Debug> <SecurityDebug> <000000> <LDAP Atn
Authenticated User weblogic>
<2005-10-2 ????01??28??05?? CST> <Debug> <SecurityDebug> <000000>
<oneShotGroupMembershipLookup called for weblogic>
<2005-10-2 ????01??28??05?? CST> <Debug> <SecurityDebug> <000000>
<activeDirectoryLookupTokenGroups called for weblogic>
<2005-10-2 ????01??28??05?? CST> <Debug> <SecurityDebug> <000000>
<getConnection return conn:LDAPConnection {ldap://localhost:389
ldapVersion:3 bindDN:"CN=weblogic,CN=Users,DC=mydavid,DC=org"}>
<2005-10-2 ????01??28??05?? CST> <Debug> <SecurityDebug> <000000>
<getDNForUser search("cn=Users,dc=mydavid,dc=org",
"(&(cn=weblogic)(objectclass=user))", base DN & below)>
<2005-10-2 ????01??28??05?? CST> <Debug> <SecurityDebug> <000000> <DN for
user weblogic: CN=weblogic,CN=Users,DC=mydavid,DC=org>
<2005-10-2 ????01??28??05?? CST> <Debug> <SecurityDebug> <000000> <No
groupname found for SID \01\02\00\00\00\00\00\05\20\00\00\00\21\02\00\00>
<2005-10-2 ????01??28??05?? CST> <Debug> <SecurityDebug> <000000> <SID to
Group returns null>
<2005-10-2 ????01??28??05?? CST> <Debug> <SecurityDebug> <000000> <No
groupname found for SID \01\02\00\00\00\00\00\05\20\00\00\00\20\02\00\00>
<2005-10-2 ????01??28??05?? CST> <Debug> <SecurityDebug> <000000> <SID to
Group returns null>
<2005-10-2 ????01??28??05?? CST> <Debug> <SecurityDebug> <000000> <Group
mapping found is Domain Users>
<2005-10-2 ????01??28??05?? CST> <Debug> <SecurityDebug> <000000> <SID to
Group returns Domain Users>
<2005-10-2 ????01??28??05?? CST> <Debug> <SecurityDebug> <000000>
<returnConnection conn:LDAPConnection {ldap://localhost:389 ldapVersion:3
bindDN:"CN=weblogic,CN=Users,DC=mydavid,DC=org"}>
<2005-10-2 ????01??28??05?? CST> <Debug> <SecurityDebug> <000000>
<oneShotGroupMembershipLookup returns with 1 groups>
<2005-10-2 ????01??28??05?? CST> <Debug> <SecurityDebug> <000000> <login
succeeded for username weblogic>
what's the meaning of "SID to Group returns null"?
\01\02\00\00\00\00\00\05\20\00\00\00\21\02\00\00 resprent for what?
Any one could tell me?
thanks.
david.turingHi
In AR, you will give cash discount to customer and not the other way round as you mentioned.
For eg if AR value is 100 and customer pays you 90, there is a difference of 10. Assume you have cash discount % of say 6%, you expect the customer to pay 94 (100- 6% of 100) and not 90. There is still a gap of 4. This can be added to cash discount account if you enter 4 in this field. Hence the A/c entry will be:
Dr Bank 90
Dr cash discount (expense/loss) 10
Cr Customer 100
However this field is interlinked with some other fields like "Cash discount per line item", etc
Jayaram -
Task.getProcessInfo().getProcessName Returns null -Oracle SOA 11g Worklist
Hi,
Im working on building custom worklist application using oracle SOA 11g Java API .I 'm able to query a list of tasks from the BPM server. But, When I try to find process name by invoking task.getProcessInfo().getProcessName() it returns null even I specify PROCESSNAME in my column list.Do i have to specify anywhere else except query columns ? What could be the reason?
Thanks,
GovindhIf BPEL don't timed out, you can have Human task in Synchronous BPEL process.
For this, you can have your synchronous reply before any Human task call back receive activities (this causes the timeout) or you can just create human task and no other call back receive activities.
Thanks
--Sreeny -
Hi All-
In my BPM server, I am seeing lot of warning message like below one. Could you please help me understand whats causing these errors and how I can fix this.
Warning message :-
<Oct 15, 2013 4:33:25 PM IST> <Warning> <oracle.soa.services.workflow.runtimeconfig> <BEA-000000> <<TaskDisplayUtil.getFusionAppsFrontendHostUrlFromHwfConfig> Bad frontendHostUrl in WorkflowConfig, will return null: no protocol: >Please carefully read Lion Setup Assistant tips, this will show you how to move your files. It's extremely simple to do, also please book mark and begin using:
Mac 101
Switch 101
Find Out How Video tutorials
List of Useful URLs for switchers
To be honest I think you're over thinking the matter and making your transition more difficult than need be. IMHO this is natural coming from the Windows world where managing your system is difficult, not so with OS X. Take some look over the URL's and study them and begin playing with the system and you'll see how easy it really is. -
Select query having count function is returning null
Hi Everyone,
Please see the query and help me to get this solved.
DB version
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
"CORE 10.2.0.1.0 Production"
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - ProductionQUERY
SELECT COUNT(*) as V_COUNT
FROM LAB_ORDER_TMPLT_TEST
WHERE TEST_ID IN
(SELECT WEST_TEST_ID
FROM TEST_CODE_CONVERSION TCC
WHERE TCC.EAST_TEST_ID = 2769)
GROUP BY LAB_ORDER_TMPLT_ID
HAVING COUNT(*) > 1;
It's returning null. Is there any way I can get the value as zero instead of null? Please help.Regards,
BS2012.Hi,
BS2012 wrote:
Hi Everyone,
Please see the query and help me to get this solved.
DB version
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
"CORE 10.2.0.1.0 Production"
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - ProductionQUERY
SELECT COUNT(*) as V_COUNT
FROM LAB_ORDER_TMPLT_TEST
WHERE TEST_ID IN
(SELECT WEST_TEST_ID
FROM TEST_CODE_CONVERSION TCC
WHERE TCC.EAST_TEST_ID = 2769)
GROUP BY LAB_ORDER_TMPLT_ID
HAVING COUNT(*) > 1;
It's returning null.
Really? COUNT never returns NULL; it always returns 0 or a positive integer.
Do you mean the query results in "no rows selected"?
Is there any way I can get the value as zero instead of null? Please help.Do you want a query that will produce the same output as the query above, but will produce a single row containing 0 when the query above does not produce anything? That sounds like a job for an outer join:
WITH original_query AS
SELECT COUNT(*) AS v_count
FROM lab_order_tmplt_test
WHERE test_id IN
( SELECT west_test_id
FROM test_code_conversion tcc
WHERE tcc.east_test_id = 2769
GROUP BY lab_order_tmplt_id
SELECT NVL (o.v_count, 0) AS v_count
FROM dual
LEFT OUTER JOIN original_query o ON o.v_count > 0
;If you'd care to post CREATE TABLE and INSERT statements for the sample data, then I could test this. -
Transient vo attribute binding returning null
i have a editable form with multiple input text components which i created by dropping a collection on page.
now i want to add more fields which are transient and read only.
i added two transient attributes in VO with Updatable to Never and queryable to true, i dont have the logic yet so the expression is blank. i created a label using control hint.
now i created two attribute value bindings for these new fields.
i created two input text fields and used these bindings for their label , value properties. i set readonly and disabled both true for these input text fields.
if i hard code the label and value properties of input text it works, if i use binding expressions for them, it throws some error saying could not find binding for transient fileds or thery returned null.
what stpes should i use to add a transient field to a editable form.
jdev 11.1.1.5.0Put the transient attributes into the underlying eo, refresh the vo and add the attributes from the eo to the vo. Now they should work just as any other attribute.
Timo -
The result of a direct action returned NULL/nil.
I'm new to Macs so please bear with me. I've been tasked with setting up a new iMac (20 inch display - totally stock - bought on Saturday.) After plugging it in and started running through the registration, setting up the wireless access then it looked like the setup was doing something with the camera suddenly it flashed to the following message:
"the result of a direct action returned NULL/nil." the Continue and Back buttons at the bottom of the page were dimmed out. The only thing I could do was reboot the computer.
Is there any way to restart the "setup sequence" - as if I just plugged it in and turned it on for the first time? Have I missed anything in the setup because of this error? Anyone know why this happened? I've tried to search on this topic but couldn't find anything. If I've missed something please direct me to the appropriate link.
Thanks.
20 inch iMac 2.16GHz Intel Core 2 Duo Mac OS X (10.4.6)Go to ~user/Library/Assistants and double click the file Send Registration.setup and it should relaunch the Mac OS X Setup Assistant.
-
Web Service Operation returns null values
I got a Flash program that uses a Web Service. I linked the actionscript to the Flex Files to get my connection to work. I got it to work fine, but the problem is with sending it parameters. This only works on functions without parameters. But when I try to pass parameters, it returns null. I also tried using the argruments function, but that caused it to return error. What do I do to make it work? Here is my code below:
stop();
import flash.display.MovieClip;
import flash.events.MouseEvent;
import mx.rpc.soap.*;
import mx.rpc.events.*;
import mx.rpc.AbstractOperation;
import flash.events.Event;
import flash.utils.Timer;
var webService:WebService = new WebService();
webService.wsdl = "http://www.askent.com/ttcs.asmx?WSDL";
webService.loadWSDL();
var serviceOperation:AbstractOperation;
/*var loginTimer: Timer = new Timer(1000, 1);
loginTimer.start();*/
var loginOperation: AbstractOperation;
var nickname:String;
var token:String = "token";
var gameName:String = "CRAZ";
//loginTimer.addEventListener(TimerEvent.TIMER, SetupWebService);
signin_btn.addEventListener(MouseEvent.CLICK, login);
/*function SetupWebService(event: TimerEvent):void{
webService.loadWSDL("http://www.askent.com/ttcs.asmx?WSDL");
webService.addEventListener(LoadEvent.LOAD, BuildServiceRequest);
function BuildServiceRequest(evt:LoadEvent){
/*loginOperation = webService.getOperation("GuestLogin");
loginOperation.send(nickname, token, gameName);
//nickname = name_input.text;
loginOperation.addEventListener(FaultEvent.FAULT, DisplayError);
loginOperation.addEventListener(ResultEvent.RESULT, DisplayResult);*/
trace("connected");
function login(event: MouseEvent): void{
loginOperation = webService.getOperation("GuestLogin");
//nickname = name_input.text;
loginOperation.addEventListener(FaultEvent.FAULT, DisplayError);
loginOperation.addEventListener(ResultEvent.RESULT, DisplayResult);
//loginOperation({Nickname: nickname, Token: token, GameName: gameName});
//loginOperation.arguments = {nickname: "GGG", Token: "token", GameName: "gameName"};
loginOperation.send([nickname, token, gameName]);
function DisplayError(evt:FaultEvent){
trace("error");
function DisplayResult(evt:ResultEvent)
var wsdlResponse:String = evt.result as String;
trace(wsdlResponse);
function sendLogin(nickname: String, token: String, gameName: String): String{
return nickname + token + gameName;Shay,
The link worked. I generated Java Web Service from my WSDL, and tested using the HTTP analyzer
But for get Operation method on the WSDL, I could not see anything in the response object, but the same operation i could see the output in soapUIPro.
Can you give me some more guildelines to debug...
Thanks,
Sri
Maybe you are looking for
-
Is it possiblle to integrate non-sap to non-sap using XI?
hi, is it possible to integrate non-sap to non-sap system using SAP XI? ex. File to JDBC scenario regards Ruban
-
Hi, Just inherited a Fujitsu PIII 500 PC and it is a bit old and weary. Want to freshen it up with new memory, hard disk etc. Before I start, just want to check that if I flash with v2.9 that I will be able to install a 120Gb hard drive in it to repl
-
how do I convert my address book from explorer to Safari? I am unable to download Explore anymore because it has been discontinued for the Mac.
-
Rotate screen - help!! N95 not 8gb
When i play my music (and slide my phone down to do it), my nokia automatically rotates to landscape which is cool, but then when i close it it doesn't rotate back unless i slide up to reveal the keypad and then back down again. Now i have tried to d
-
Can't open the Skype app on my N8. Please help.
i can't open skype in my n8 device. Moderator's Note: Post was moved and changed the title into a subject-related title. This is to keep the forum organized and let other forum users easily see and respond to this post.