Class.forName() throws null exception in servlet
Hi, just wondering if anyone having this similar problem:
when i try to load a class using Class.forName() method inside a servlet, it throws null exception.
1) The exception thrown is neither ClassNotFoundException nor any other Error, it's "null" exception.
2) There's nothing wrong with the code, in fact, the same code has been testing in swing before, works perfectly.
3) I have include all necessary jars/classes into the path, even if i haven't, it should throw ClassNotFoundException instead, not "null" exception.
I have tried to detect any possible nullable variable, and it is able to run until line 15. The exception thrown is actually null only... not NullPointerException... which is why i have confused...
the message i received is "PlugInException: null".
The code is at follow:
* Load plugin
* @return ArrayList of plugins
* @exception PlugInException PlugInException
01 public ArrayList loadPlugin()
02 throws PlugInException
03 {
04 PlugIn plugin;
05 ArrayList plugins = new ArrayList();
06
07 for (int i = 0; i < configLoader.getPluginTotal(); i++)
08 {
09 try
10 {
11 if (debugger > 0)
12 {
13 System.out.print("Loading " configLoader.getPluginClass(i) "...");
14 }
15 if (Class.forName(configLoader.getPluginClass(i)) == null)
16 {
17 if (debugger > 0)
18 {
19 System.out.print(" not found");
20 }
21 }
22 else
23 {
24 if (debugger > 0)
25 {
26 System.out.println(" done");
27 }
28 plugin = (PlugIn)(Class.forName(configLoader.getPluginClass(i)).newInstance());
29 plugin.setContainer(container);
30 plugins.add(plugin);
31 }
32 }
33 catch (Exception e)
34 {
35 throw new PlugInException("PlugIn Exception: " + e.toString());
36 }
37 }
38
39 return plugins;
40 }
Similar Messages
-
Here's one for the strange folder...
I have my Flex app. I build the project and copy the resulting swf to my development (192.168.100.110:511/devportal/) server for testing....this works perfectly fine.
However, some of my testers see an error (including myself) that is odd. When I run the swf on the server, for one specific function, I get a null exception error. What's interesting about it is that the stack trace indicates that the error occurred in my local working copy of code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at apps::AsrUtilization/togglePanel()[C:\Users\eloy91100636\Desktop\Portal\UserInterface\htd ocs\LABPortal\src\apps\AsrUtilization.mxml:722]
at apps::AsrUtilization/__callPanel_click()[C:\Users\eloy91100636\Desktop\Portal\UserInterfa ce\htdocs\LABPortal\src\apps\AsrUtilization.mxml:933]
How is it that a swf running on a separate machine blows up trying to reference a function in the working code on my pc?
And, what's more, is that some people run the swf just fine with no error and it works clean while others encounter this error. I've cleaned and recompiled the project and it doesn't fix the problem.
HELP!!!
AdrianGood call on the player types...yes, the one's who don't see the error are running release version, the rest are running debug version.
Thanks!!!!!
Adrian -
SwingUtilities throwing Null Exception
I created the following class to report a bug and came across something interesting:
// Instructions to view bug
// 1) On your favorite windows operated machine (xp in my case) unlock and move your taskbar
// so that it is along the left pane of your screen.
// 2) Run the following java program
// 3) Maximize the BugCheck window
// 4) Click on the down arrow of the combobox
// 5) You will see the combobox is not dropping to where it should and the dropdown selection text is cutoff.
package com.BugCheck;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
* This simple class will demonstrate a jcombobox being misaligned
* when selected and the user's Windows taskbar is along the LEFT
* side of the screen.
public class BugCheck extends JFrame
public BugCheck()
try
jbInit();
} catch (Exception ex)
ex.printStackTrace();
public static void main(String args[])
BugCheck f = new BugCheck();
f.setSize(new Dimension(100, 100));
f.setVisible(true);
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
SwingUtilities.updateComponentTreeUI(f);
} catch (Exception e ) {
e.printStackTrace();
private void jbInit() throws Exception
jComboBox1.addItem("Selection 1");
jComboBox1.addItem("Selection 2");
jComboBox1.addItem("Can't");
jComboBox1.addItem("see");
jComboBox1.addItem("this.");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("BugCheck");
this.getContentPane().add(jComboBox1, java.awt.BorderLayout.NORTH);
JComboBox jComboBox1 = new JComboBox();
}I got the exceptions listed below, and after some fiddling it turns out the culprit is the following line of code. When commented out, the exceptions do not happen.
this.getContentPane().add(jComboBox1, java.awt.BorderLayout.NORTH);is causing these exceptions to be thrown:
"C:\Program Files\Java\j2re1.4.2_07\bin\javaw" -classpath "H:\BugCheck\classes;C:\Program Files\Java\j2re1.4.2_07\javaws\javaws.jar;C:\Program Files\Java\j2re1.4.2_07\lib\charsets.jar;C:\Program Files\Java\j2re1.4.2_07\lib\ext\dnsns.jar;C:\Program Files\Java\j2re1.4.2_07\lib\ext\ldapsec.jar;C:\Program Files\Java\j2re1.4.2_07\lib\ext\localedata.jar;C:\Program Files\Java\j2re1.4.2_07\lib\ext\sunjce_provider.jar;C:\Program Files\Java\j2re1.4.2_07\lib\im\indicim.jar;C:\Program Files\Java\j2re1.4.2_07\lib\im\thaiim.jar;C:\Program Files\Java\j2re1.4.2_07\lib\jce.jar;C:\Program Files\Java\j2re1.4.2_07\lib\jsse.jar;C:\Program Files\Java\j2re1.4.2_07\lib\plugin.jar;C:\Program Files\Java\j2re1.4.2_07\lib\rt.jar;C:\Program Files\Java\j2re1.4.2_07\lib\sunrsasign.jar" com.BugCheck.BugCheck
java.lang.NullPointerException
at javax.swing.DefaultListCellRenderer.getListCellRendererComponent(Unknown Source)
at javax.swing.plaf.basic.BasicComboBoxUI.getDisplaySize(Unknown Source)
at javax.swing.plaf.basic.BasicComboBoxUI.getMinimumSize(Unknown Source)
at javax.swing.plaf.basic.BasicComboBoxUI.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.BorderLayout.layoutContainer(Unknown Source)
at java.awt.Container.layout(Unknown Source)
at java.awt.Container.doLayout(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validate(Unknown Source)
at javax.swing.RepaintManager.validateInvalidComponents(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
java.lang.NullPointerException
at javax.swing.plaf.basic.BasicComboBoxUI.isPopupVisible(Unknown Source)
at javax.swing.plaf.basic.BasicComboBoxUI.paintCurrentValue(Unknown Source)
at javax.swing.plaf.basic.BasicComboBoxUI.paint(Unknown Source)
at javax.swing.plaf.ComponentUI.update(Unknown Source)
at javax.swing.JComponent.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown Source)
at javax.swing.JComponent.paintDoubleBuffered(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)Any comments?Some thoughts, 1) eliminate all those unnecessary jar
files from your classpath 2) add the bin directory of
the jdk to your PATH variable and call the java
command directly for simplicity ... 3) Only include
on your classpath any jar files that you have created
for your application or 3rd party jar files. In your
example it doesn't look like you need to include any
jar files. 4) I also notice that your package name
and class name are the same. Generally package names
are lower case and Class names are upper case.
java com.bugcheck.BugCheck
None of these address the issue at hand. Although I do commend you for being nitpicky!
Suprisingly, running the same program with Java 1.4.2 b5 (the OP was done with 1.4.2 b7) gives more informaton:
[code
java.lang.NullPointerException
at javax.swing.DefaultListCellRenderer.getListCellRendererComponent(DefaultListCellRenderer.java:80)
at javax.swing.plaf.basic.BasicComboBoxUI.getDisplaySize(BasicComboBoxUI.java:1275)
at javax.swing.plaf.basic.BasicComboBoxUI.getMinimumSize(BasicComboBoxUI.java:969)
at javax.swing.plaf.basic.BasicComboBoxUI.getPreferredSize(BasicComboBoxUI.java:959)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1275)
at java.awt.BorderLayout.layoutContainer(BorderLayout.java:668)
at java.awt.Container.layout(Container.java:1020)
at java.awt.Container.doLayout(Container.java:1010)
at java.awt.Container.validateTree(Container.java:1092)
at java.awt.Container.validateTree(Container.java:1099)
at java.awt.Container.validateTree(Container.java:1099)
at java.awt.Container.validate(Container.java:1067)
at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:353)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:116)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
java.lang.NullPointerException
at javax.swing.plaf.basic.BasicComboBoxUI.isPopupVisible(BasicComboBoxUI.java:919)
at javax.swing.plaf.basic.BasicComboBoxUI.paintCurrentValue(BasicComboBoxUI.java:1148)
at javax.swing.plaf.basic.BasicComboBoxUI.paint(BasicComboBoxUI.java:954)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:541)
at javax.swing.JComponent.paint(JComponent.java:808)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4787)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740)
at javax.swing.JComponent._paintImmediately(JComponent.java:4685)
at javax.swing.JComponent.paintImmediately(JComponent.java:4488)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) -
Servlet outputstream doesn't work after class.forname
hi there,
i'm beginner to servlets and jdbc i was trying a code
the servlet outputstream doesn't work after registerting the mysql driver
here is the code:
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class JDBCServo extends HttpServlet
private Connection con;
private Statement stmt;
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
// TODO Auto-generated method stub
try
ServletOutputStream out = res.getOutputStream();
out.println("WELCOME");
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/books" , "root" , null);
stmt = con.createStatement();
ResultSet result = stmt.executeQuery("select * from book");
result.next();
con.close();
out.println(result.getObject(1)+" "+result.getObject(2));
out.close();
}catch(SQLException e){}
catch(ClassNotFoundException e){e.printStackTrace();}
}That would almost certainly be because you didn't put that class in the classpath, and therefore Class.forName() throws an exception.
-
Class.forName("AClassName") always yields in an exception
Dear Experts
I am trying to get a classname at runtime and Class c = Class.forName always returns an exception
I will appreciate your help in this regard. Anyways the full code is as follows:
interface MyInter
void accept();
void display();
class IntegerSorter implements MyInter {
public void accept()
System.out.println("IntegerSorter....................");
public void display()
System.out.println("Displays IntegerSorter...........");
class StringSorter implements MyInter {
public void accept()
System.out.println("StringSorter....................");
public void display()
System.out.println("Displays StringSorter.............");
public class Main {
public static void main(String[] args) {
Class c=null;
MyInter m=null;
String s="IntegerSorter";
try
c = Class.forName(s);
} catch (Exception e1) {
System.err.println(e1.getMessage());
try {
m = (MyInter) c.newInstance();
} catch (Exception e) {
System.err.println(e.getMessage());
m.accept();
m.display();
}Edited by: standman on Mar 18, 2011 1:41 PMstandman wrote:
I am trying to get a classname at runtime and Class c = Class.forName always returns an exceptionThat's not enough information; which Exception?
Plus, I ran your exact code o my machine, and got absolutely no exception. Are you posting the exact code that demonstrates the problem?
try
c = Class.forName(s);
} catch (Exception e1) {
System.err.println(e1.getMessage());
}As an aside, don't log exceptions like that. Although it looks fine on so small a code, it's way not enough information if you have to debug such a "trace" in a non-trivial program.
Instead log the exception's stack trace ( e1.printStackTrace() ), or use a logging library (for bigger programs).
Regards,
J. -
Can't load class with Class.forName()
Hi, can somebody help me with this problem. I have clas copiled with jdk 1.3.1 (I also test it with jdk 1.4.1). If I try to load a Class instance with Class.forName("package.app.MyClass)") I have a runtime exception:
java.lang.ClassNotFoundException: com.unisys.ebs.all.ispecs.GD130IspecModel
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:183)
at java.lang.ClassLoader.loadClass(ClassLoader.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:310)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:115)
at com.unisys.util.ObjectLoader.load(ObjectLoader.java:60)
at com.unisys.jellybeans.IspecFactory.getIspec(IspecFactory.java:74)
at com.unisys.jellybeans.LINCEnvironment.getIspec(LINCEnvironment.java:1012)
at com.unisys.ebs.middleware.TestLinc.initConnection(TestLinc.java:52)
at com.unisys.ebs.middleware.TestLinc.main(TestLinc.java:106)
but if instead of this I instantiate the class calling the constructor and writing an import sentence, it works fine. I really need to instantiate this class via Class.forName because it extends a superclass and know the class to instantiate only at runtime. I will appreciate any help. Thanks.
Pablo AntoniolettiI removed the import in the file header and wrote this code:
try{
ispecModel = new com.unisys.ebs.all.ispecs.GD130IspecModel();
Class ispecClass = Class.forName("com.unisys.ebs.all.ispecs.GD130IspecModel.class");
catch(Exception e)
e.printStackTrace();
the new sentence work fine, if write mor code I can access methods and members. When the runtime execute the Class.forName sentence the exception is thrown. I put all in the same file and class to avoid mistakes typing class path.
This is very rare I never seen it before and I developed java application since five years ago. -
Constrctor.newInstance() throwing null pointer exception
hi,
I have the following code:
public class Class_B{
void method1(){
Class clazz = Class.forName("ClassA");
Method method = _clazz.getMethod("notify", new Class[] { this.getClass() });
Constructor constructor = _clazz.getConstructor(); // here am getting InvocationTargetException (exception.getCause() ---> null pointer exception).
Object obj = constructor.newInstance();
public class Class_A{
public Class_A(){}
public void notify(Class_B b){
// do some stuff
Can anybody tell me what makes it to throw a null pointer exception.paul.miner wrote:
georgemc wrote:
I notice you're obtaining a constructor that takes one argument, but don't pass any such argument into the newInstance invocationActually, OP is obtaining a one-argument method; the constructor requested has no arguments.Yep, I misread his code. Cheers Paul
Anyways, chances are there's an NPE being thrown from the constructor. What happens if you just instantiate it the old-fashioned, non-reflective way? -
JAX-WS Client throws NULL Pointer Exception in NW 7.1 SP3 and higher
All,
My JAX-WS client is throwing an exception when attempting to create a client to connect to the calculation service. The exception is coming out of the core JAX-WS classes that are part of NetWeaver. (see exception below)
Caused by: java.lang.NullPointerException
at com.sap.engine.services.webservices.espbase.client.jaxws.core.SAPServiceDelegate.createDispatchContextExistingPort(SAPServiceDelegate.java:440)
at com.sap.engine.services.webservices.espbase.client.jaxws.core.SAPServiceDelegate.createDispatchContext(SAPServiceDelegate.java:475)
at com.sap.engine.services.webservices.espbase.client.jaxws.core.SAPServiceDelegate.createDispatch(SAPServiceDelegate.java:492)
at com.sap.engine.services.webservices.espbase.client.jaxws.core.SAPServiceDelegate.createDispatch(SAPServiceDelegate.java:484)
at javax.xml.ws.Service.createDispatch(Service.java:166)
I have done some research and it appears that as of NetWeaver 7.1 SP3 SAP stopped using the SUN JAX-WS runtime and implemented their own SAP JAX-WS runtime. I also took the time to decompile the jar file that contained the SAPServiceDelegate class which is throwing the null pointer exception. (see method from SAPServiceDelegate below)
private ClientConfigurationContext createDispatchContextExistingPort(QName portName, JAXBContext jaxbContext)
BindingData bindingData;
InterfaceMapping interfaceMap;
InterfaceData interfaceData;
bindingData = clientServiceCtx.getServiceData().getBindingData(portName);
if(bindingData == null)
throw new WebServiceException((new StringBuilder()).append("Binding data '").append(portName.toString()).append("' is missing!").toString());
QName bindingQName = new QName(bindingData.getBindingNamespace(), bindingData.getBindingName());
interfaceMap = getInterfaceMapping(bindingQName, clientServiceCtx);
interfaceData = getInterfaceData(interfaceMap.getPortType());
ClientConfigurationContext result = DynamicServiceImpl.createClientConfiguration(bindingData, interfaceData, interfaceMap, null, jaxbContext, getClass().getClassLoader(), clientServiceCtx, new SOAPTransportBinding(), false, 1);
return result;
WebserviceClientException x;
x;
throw new WebServiceException(x);
The exception is being throw on the line where the interfaceMap.getPortType() is being passed into the getInterfaceData method. I checked the getInterfaceMapping method which returns the interfaceMap (line above the line throwing the exception). This method returns NULL if an interface cannot be found. (see getInterfaceMapping method below)
public static InterfaceMapping getInterfaceMapping(QName bindingQName, ClientServiceContext context)
InterfaceMapping interfaces[] = context.getMappingRules().getInterface();
for(int i = 0; i < interfaces.length; i++)
if(bindingQName.equals(interfaces<i>.getBindingQName()))
return interfaces<i>;
return null;
What appears to be happening is that the getInterfaceMapping method returns NULL then the next line in the createDispatchContextExistingPort method attempts to call the getPortType() method on a NULL and throws the Null Pointer Exception.
I have included the code we use to create a client below. It works fine on all the platforms we support with the exception of NetWeaver 7.1 SP3 and higher (I already checked SP5 as well)
//Create URL for service WSDL
URL serviceURL = new URL(null, wsEndpointWSDL);
//create service qname
QName serviceQName = new QName(targetNamespace, "WSService");
//create port qname
QName portQName = new QName(targetNamespace, "WSPortName");
//create service
Service service = Service.create(serviceURL, serviceQName);
//create dispatch on port
serviceDispatch = service.createDispatch(portQName, Source.class, Service.Mode.PAYLOAD);
What do I need to change in order to create a JAX-WS dispatch client on top of the SAP JAX-WS runtime?Hi Guys,
I am getting the same error. Any resolution or updates on this.
Were you able to fix this error.
Thanks,
Yomesh -
Vector.clear() throws null pointer exception
is there anything wrong in my code. when i try to clear the vector irrespective of whether i add elements to it or not, if there are no elements added to the vector v1.clear() it throws null pointer exception
Vector v1 = new Vector(1,1);
v1.clear()And the guessing game continues... anyone for a shortctu to duplicate this problem?
public class NullVectorCreator
private Vector v1;//just love the name, so clear and unambiguous... :)
public NullVectorCreator
Vector v1 = new Vector();//well done - a local variable masquerading as
// a class member
public Vector getVector()
return v1;
public static void main(String[] args)
NullVectorCreator nvc = new NullVectorCreator();
nvc.getVector().clear();//Why does this throw an NPE? why? java is bugged!
} -
Java function with Dynamic config throws null pointer exception
hi Experts,
I am using dynamic config using java function in my message mapping.
The source message has a field called "fname".
The value of "fname" is the input to my java UDF.
The java UDF code is:
public String getDynamicFile(String fname, Container container) throws StreamTransformationException{
String str = fname + ".xml";
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey FileName = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");
conf.put(FileName, str);
return str;
When I test this message mapping I get the following exception:
Runtime Exception:[java.lang.NullPointerException: while trying to invoke the method com.sap.aii.mapping.api.DynamicConfiguration.put(com.sap.aii.mapping.api.DynamicConfigurationKey, java.lang.String) of an object loaded from local variable '<4>'] in class com.sap.xi.tf._<message mapping>_ method getDynamicFile[test, com.sap.aii.mappingtool.tf7.rt.Context@2e52cb31]
What am I doing wrong in this UDF?
Thanks
GopalHi,
Your UDF will run fine in an end to end execution,i.e, during runtime. However, if you want to test your message mapping test tab without the dynamic config UDF throwing an exception, encpasulate the code in a try catch block
public String getDynamicFile(String fname, Container container) throws StreamTransformationException{
String str = fname + ".xml";
try{
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey FileName = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");
conf.put(FileName, str);
}catch(Exception ex){}
return str;
The above code should run fine when you test in the message mapping test tab.
Regards -
WPUMFactory.getUserFactory() throws null pointer exception
Hi,
I am trying to use KM API's to read files from KM repository. I am using the below code as mentioned in the blog: How to download KM documents using Web Dynpro Java
Below is my code:
IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
IUser epUser = WPUMFactory.getUserFactory().getEP5User(sapUser);
However the line WPUMFactory.getUserFactory() throws null pointer exception. Can some one please help on why these happens as these seems to be the standard code to read a file from KM.
Thanks.
Regards,
Ponraj MHi Ponraj ,
Instead of fetching the current logged on user , use the below line to set the resource context and see if it helps .
com.sapportals.wcm.repository.IResourceContext resourceContext = ResourceFactory.getInstance().getServiceContext("cmadmin_service");
cmadmin_service is a existing user that can be used to access KM resources .
Regards
Mayank -
Weblogic throwing "null SOAP element Exception" in multi-part SOAP response
Hi All,
I'm using weblogic 10. My application is a webservice client generated using '*clientgen*', which is running on weblogic, and
is invoking a remotely hosted webservice ( Remotely hoseted webservice may not be running on weblogic).
I've the wsdl file of remotely hosted webservice.
Now the problem is with WSDL file (I suppose), have a look at this.
*<message name="m1">*
*<part name="body" element="tns:GetCompanyInfo"/>*
*</message>*
*<message name="m2">*
*<part name="body" element="tns:GetCompanyInfoResult"/>*
*<part name="docs" type="xsd:AnyComplexType"/> ------> assume all elements inside this complex type can be nil or minOccurs set to '0'*
*<part name="logo" type="xsd:AnyOtherComplexType"/> ------> assume all elements inside this complex type can be nil or minOccurs set to '0'*
*</message>*
<portType name="pt1">
<operation name="GetCompanyInfo">
<input message="m1"/>
*<output message="m2"/> -----> multi part message.*
</operation>
</portType>
Now here is sample message for the request(I've composed this message for this question):
<soap:Envelope> MESSAGE1
<soap:header/>
<soap:body>
<tns:m2>
<tns:GetCompanyInfoResult>
Blah Blah....
</tns:GetCompanyInfoResult>
<tns:docs>
Blah Blah....
</tns:docs> Assume no data for 'logo', so it's not returned. Since all its elements can be nillable.
<tns:m2>
</soap:body>
</soap:Envelope>
First of all, is this SOAP response is valid? I'm not sure about *'message' and 'parts' in SOAP*, but according to XML schema standards it's invalid.
Because, according to *'message' m2, 'logo' is missing*, eventhough all it's elements are nillable in such case there should be *<logo/>* at the end.
I mean valid message should be like below
<soap:Envelope> '*MESSAGE2*'
<soap:header/>
<soap:body>
<tns:m2>
<tns:GetCompanyInfoResult>
Blah Blah....
</tns:GetCompanyInfoResult>
<tns:docs>
Blah Blah....
</tns:docs>
*<tns:logo/> ------------------> here is the change compared to above message. empty element.*
<tns:m2>
</soap:body>
</soap:Envelope>
Now the concerns are :
(1) Which is a valid response? Message1 or Message2
(2) If message1 is valid then why is weblogic throwing an exception 'null SOAP element', I suppose this is due to missing 'logo' element.
(To confirm this I've used tcpmonitor and found message1 as response but weblogic is still throwing 'null SOAP Element' exception,
which confirms it needs 'logo' as well, I suppose <logo/> at least). Is there any workaround for this in weblogic for multi-part messages?
(3) If message1 is invalid according to SOAP standards then You've answered my question. ---> I need to talk to the webservice provider in this case.....
Thanks in advance...Message 1 is not Basic Profile 1.1 compliant. It is specified by BP1.1 in section 4.4.1(http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html#Bindings_and_Parts) that when a wsdl:part element is defined using the type attribute, the serialization of that part in a message is equivalent to an implicit (XML Schema) qualification of a minOccurs attribute with the value "1", a maxOccurs attribute with the value "1" and a nillable attribute with the value "false".
-
Revision: 3540
Author: [email protected]
Date: 2008-10-09 11:20:44 -0700 (Thu, 09 Oct 2008)
Log Message:
Fix for missing name of the exception class, when @throw is used.
Also fixes for:
SDK-17212 - Add a line feed between messages in the ASDoc validation_errors.log file.
SDK-17242 - The Constants.as and GlobalFunctions.as classes from system classes need to have their content added to __Global__.xml
SDK-17256 - For methods of the mx.components.Group class, args or return values of type Object do not appear in the ASDoc output.
QA: Yes
Doc:
Tests: checkintests
Ticket Links:
http://bugs.adobe.com/jira/browse/SDK-17212
http://bugs.adobe.com/jira/browse/SDK-17242
http://bugs.adobe.com/jira/browse/SDK-17256
Modified Paths:
flex/sdk/trunk/asdoc/templates/class-files.xslt
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/AsDocUtil.java
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/ClassTable.java
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/TopLevelClassesGenerator.ja vaRevision: 3540
Author: [email protected]
Date: 2008-10-09 11:20:44 -0700 (Thu, 09 Oct 2008)
Log Message:
Fix for missing name of the exception class, when @throw is used.
Also fixes for:
SDK-17212 - Add a line feed between messages in the ASDoc validation_errors.log file.
SDK-17242 - The Constants.as and GlobalFunctions.as classes from system classes need to have their content added to __Global__.xml
SDK-17256 - For methods of the mx.components.Group class, args or return values of type Object do not appear in the ASDoc output.
QA: Yes
Doc:
Tests: checkintests
Ticket Links:
http://bugs.adobe.com/jira/browse/SDK-17212
http://bugs.adobe.com/jira/browse/SDK-17242
http://bugs.adobe.com/jira/browse/SDK-17256
Modified Paths:
flex/sdk/trunk/asdoc/templates/class-files.xslt
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/AsDocUtil.java
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/ClassTable.java
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/TopLevelClassesGenerator.ja va -
Throw an exception from one class to another?
I have an applet that analyzes different sorting algorithms. Each sorting algorithm is a seperate class. The applet passes the sorting algorithm class an unsorted array, the sorting algorithm sorts the array, and returns the sorted array to the applet. Sometimes the sorting class will generate a stack overflow exception. How do i catch the exception in the sorting class and throw it to the applet, which can then display a dialog box. In the sorting class I have setup a try/catch block that throws the exception and in the class decleration it says "throws Exception". The code in the applet that executes the sort class is inside of at try block as well. When the prog generates an exception in the sorting class it wont throw and be caught by my applet. How can this be done?
Thanks,
DaveStackOverflowException is not descendand of Exception class:
java.lang.Object
|
+--java.lang.Throwable
|
+--java.lang.Error
|
+--java.lang.VirtualMachineError
|
+--java.lang.StackOverflowErrorSo if you like to catch it dont declare method to throw Exception (Error class is unchecked exception so it doesn't need to be declared to be thrown). Just try to catch StackOverflow or Throwable. Good luck ! -
Send Method of Class Cl_BCS throwing exception
Hi Expert,
In a background job program ,we are triggering e-mail by using method SEND of Class CL_BCS.
It is working perfectly fine in quality system, but it is throwing an exception in production system and as result our background job is getting cancelled.
Could you please tell me what could be possible reason for this?
Code:
---------- send document ---------------------------------------
sent_to_all = send_request->send(
i_with_error_screen = 'X' ).
IF sent_to_all = 'X'.
message i022(so).
ENDIF.
* ---------- explicit 'commit work' is mandatory! ----------------
COMMIT WORK.
Thanks,
GirdhariHi,
I'd code that as follows:
data: lx_bcs type ref to cl_bcx .
try .
catch cx_bcs into lx_bcs.
cl_message_helper=>set_msg_vars_for_if_msg( lx_bcs ) .
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endtry .
However, the text would reveal more info only if the IDs are OTHERS or OS_ERROR, I believe... (at least on 702)
cheers,
Janis
Message was edited by: Jānis B
Or simply what Matthew wrote, of course.
Maybe you are looking for
-
I am trying to download a book on my ipad. It says I need to install itunes. I have itunes already. I frequently get a message to re-install itunes. I do, but I still get the message, and I still can't get the book on my ipad.
-
Hi All, I have an ESS Portal, Earlier I had it connected to Dev Systema and was working pefectly fine. Now we have tried mapping it to IDES. For this I have created one system for which connection Test are working fine and Made changes in JCO(change
-
How to use BOLD Fonts/text in Oracle?
Hi guys, Im doing a package and part of this package has an email to a client. I just want some details of that email should be BOLD fonts/text like the Name or Title. Can anyone help me solve this problem? Im using Oracle Forms6i and Oracle9i for ou
-
Help installing flash detection express
I need some help installing the flash express detection script. Can anyone advise me on this? 1) This tutorial assumes that you have already added the Flash 8 detection scripts to a web page (as explained in the synopsis of the implementation process
-
Moving to new country, wrong current position on maps
Hello expert, I have been moving from switzerland to brazil a month ago. Everything went fine (thanks for asking), and a week ago I have received some of my furnitures including my airport extreme. I plug my airport extreme on my network, close the w