Chris Wang

Ranch Hand
+ Follow
since Jan 13, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chris Wang

Hi,

I have set up two WAS servers -- WAS6.1 and WAS7.0 in my RAD7.5.4. The name server URLs are corbaloc:iiop:localhost:2810 and corbaloc:iiop:localhost:2812 respectively. I deployed a web project to WAS6.1 and an EJB project to WAS7.0. In the web application I have a CartServlet to access the remote EJB session bean which is in the EJB application. The code segment is as follows:

try {
Properties env1 = new Properties();
env1.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
env1.put(Context.PROVIDER_URL,"corbaloc:iiop:localhost:2812");//lookup in the WAS7.0 context
Context initial = new InitialContext(env1);
Object objref = initial.lookup("ejb/com/ibm/msp/ejbs/session/stateful/CartHome");
CartHome home = (CartHome) PortableRemoteObject.narrow(objref, CartHome.class);

Cart cart0 = home.create();
.................................

} catch (Exception ex) {
System.err.println("Caught an unexpected exception!");
ex.printStackTrace();
}

When I ran this servlet I got the following exception:
[12/15/09 23:57:38:488 EST] 0000003f SystemErr Caught an unexpected exception!
[12/15/09 23:57:38:518 EST] 0000003f SystemErr javax.naming.NameNotFoundException: Context: IBM-DA4BE9B66BCNode02Cell/nodes/IBM-DA4BE9B66BCNode02/servers/server1, name: ejb/com/ibm/msp/ejbs/session/stateful/CartHome: First component in name com/ibm/msp/ejbs/session/stateful/CartHome not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]

It seems to me that the lookup operation tried to lookup the session bean in the WAS6.1 context instead of WAS7.0 context.
Any idea? Many thanks!

BTW, if the same code running as a java application (not in the servlet) it works fine.

Chris
9 years ago
Hi All,

Thank you very much, guys.
Now the problem has been clear -- Cross-Compilation!!!

Chris
10 years ago
Hi Martijn,

I did the exactly same steps as you provided, but there was no difference.
Could you please do me a favour? Please download a windows version jdk 1.4.2 if you don't have one and try it out on your machine, see what happens.

Thank you very much!

Chris
10 years ago
Hi Martijn,

Remember I set my PATH empty before I ran javac and java command under C:\Program Files\Java\jdk1.4.2_15\bin

But anyways here is my PATH:
PATH=C:\Program Files\Windows Resource Kits\Tools\;C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\PROGRA~1\IBM\Rati
onal\SDP\6.0\VoiceToolkit\WVS\ViaVoice\bin;C:\PROGRA~1\IBM\Rational\SDP\6.0\VoiceToolkit\engines\ViaVoice\bin;C:\PROGRA~
1\IBM\Rational\SDP\6.0\VOICET~1\engines\IBM\ibmtts\bin;C:\PROGRA~1\IBM\Rational\SDP\6.0\VOICET~1\engines\IBM\ibmtts\lib;
c:\Program Files\IBM\WebSphere MQ\Java\lib;C:\Program Files\ThinkPad\Utilities;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS
\System32\Wbem;C:\Program Files\IBM\Infoprint Select;C:\Notes;C:\Program Files\XLView;C:\lotus\compnent;C:\Utilities;C:\
Program Files\ThinkPad\ConnectUtilities;C:\WINDOWS\Downloaded Program Files;C:\Program Files\IBM\Personal Communications
\;C:\Program Files\IBM\Trace Facility\;C:\Program Files\Hummingbird\Connectivity\10.00\Accessories\;;C:\PROGRA~1\IBM\SQL
LIB\BIN;C:\PROGRA~1\IBM\SQLLIB\FUNCTION;C:\PROGRA~1\IBM\SQLLIB\SAMPLES\REPL;C:\Program Files\IBM\WebSphere MQ\bin;C:\Pro
gram Files\IBM\WebSphere MQ\Java\bin;C:\Program Files\IBM\WebSphere MQ\WEMPS\bin;C:\Program Files\IBM\Rational\SDP\6.0\r
untimes\base_v51\bin;C:\Program Files\Java\jdk1.5.0_12\bin;C:\Program Files\Java\jdk1.5.0_12\jre\lib\ext;C:\MinGW\bin;C:
\usr\was6nd\wasapps\lib\remedy_native\api700p002win\lib;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Q
uickTime\QTSystem\;C:\downloads\ant\apache-ant-1.7.0\bin;;C:\FPC\2.2.0\bin\i386-Win32;C:\Program Files\UWIN\usr\bin\

Thanks,
Chris
10 years ago
Sorry Rene, I misspelled your name.

Chris
10 years ago
Hi Lane,

There was no difference when I put "C:\Program Files\Java\jdk1.4.2_15\bin" and "C:\Program Files\Java\jdk1.4.2_15\jre\bin" at the first position of my PATH because I just need javac command which sits in "C:\Program Files\Java\jdk1.4.2_15\bin". It doesn't make sense to me putting "C:\Program Files\Java\jdk1.4.2_15\jre\bin" into my PATH.

Thanks,
Chris
10 years ago
Hi Martijn,

If I open a command console and run java -version I get this:
java version "1.6.0_06"

--I checked I don't have JDK1.6 installed; it's just jre1.6 there, which means that I don't have version 1.6 java compiler.

If I go to C:\Program Files\Java\jdk1.4.2_15\bin and run java -version I get
java version "1.4.2_15"

You might be right! It seems that jdk1.4 compiler is still using class compatibility 1.2 instead of 1.4. I just don't understand why is that.
Can you confirm that?

Chris
10 years ago
Hi Martijn,

Thank you for your quick reply!

Yes I did run the javac command under C:\Program Files\Java\jdk1.4.2_15\bin directory, I even made the path empty and my JAVA_HOME is pointing to jdk1.5 actually.

Any idea?

Chris
10 years ago
Hi All,

Here is what I did:
1. On my windows XP machine I went to dir--> C:\Program Files\Java\jdk1.4.2_15\bin
2. The java version is 1.4 when I ran java -version. -- correct!
3. I compiled a java file using javac testjava.java without any error.
4. I checked the class file and found the major version number is 2E(46) which is jdk 1.2. -- unexpected!!!

My question is why the major version number inside the class file is NOT 30(48) while using jdk1.4 compiler. Is there anyone can explain why?

Thanks in advance!

Chris
10 years ago
I have a web application deployed in WAS Server 6.1 which sitting on AIX. The web application is using a native (c++) library. I setup the native library as a shared libary. Every time when I reinstalled the application or restarted the application, I got the following exception:
java.lang.UnsatisfiedLinkError: arjni70 (Library is already loaded in another ClassLoader)
at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:953)
at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:922)
at java.lang.System.loadLibrary(System.java:451)
at com.remedy.arsys.api.Proxy.<clinit>(Proxy.java:51)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
at com.remedy.arsys.api.DefaultProxyManager.getProxy(DefaultProxyManager.java:60)
at com.remedy.arsys.api.Util.ARSetServerPort(Util.java:1461)
at com.ibm.msp.sym_smartcall.Focus.FocusAPI.focusTx(FocusAPI.java:118)
at com.ibm.msp.sym_smartcall.command.FocusTask.run(CMDReceiver_Submit.java:495)

To avoid the exception I have to restart the WAS server. Could anyone please explain why?

Thanks in advance!

Chris
11 years ago
Hi,

I was using dom4j. Here is an example how i created Document:
public Document createTestCaseDocument() {
Map symbol_values = AIMT_DB.loadSymbols(planInfo.getCategory());
Document testCaseDocument = DocumentHelper.createDocument();
Element testCaseEle = testCaseDocument.addElement(TEST_CASE_ELE)
.addAttribute(CUSTOMER_ID_ATTR, ""+planInfo.getCustomerID())
.addAttribute(CUSTOMER_NAME_ATTR, planInfo.getCustomerName())
.addAttribute(IVR_ID_ATTR, ""+planInfo.getCategory())
.addAttribute(IVR_NAME_ATTR, planInfo.getCategoryName())
.addAttribute(ID_ATTR, ""+planInfo.getPlanId())
.addAttribute(NAME_ATTR, planInfo.getName())
.addAttribute(AUTHOR_ATTR, planInfo.getAuthor())
.addAttribute(LAST_MODIFIED_ATTR, ""+planInfo.getLastModified())
.addAttribute(IVR_NUMBER_PREFIX_ATTR, planInfo.getIVRNumberPrefix())
.addAttribute(IVR_NUMBER_ATTR, planInfo.getIVRNumber())
.addAttribute(INSTANCES_ATTR, ""+planInfo.getInstances())
.addAttribute(SENSITIVITY_ATTR, ""+planInfo.getSensitivity())
.addAttribute(ALLOWBARGEIN_ATTR, planInfo.isAllowBargein() ? "true" : "false")
.addAttribute(CALLERID_ATTR, planInfo.getCallerID());
//other code here
return testCaseDocument;
}

Use the following functions and xsl file to create my presentation data:
public String outputXML(Document document) {
return document.asXML();
}
public Document styleDocument(
Document document,
String stylesheet)
throws Exception {

// load the transformer using JAXP
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(
new StreamSource( stylesheet )
);

// now lets style the given document
DocumentSource source = new DocumentSource( document );
DocumentResult result = new DocumentResult();
transformer.transform( source, result );

// return the transformed document
Document transformedDoc = result.getDocument();
return transformedDoc;
}

Cheers

Chris
12 years ago
Hi Adeel,

Thank you for your reply.

Actually I was improperly using a memory stream -- ByteArrayOutputStream as the actual stream for the ZipOutputStream, thus all the files will write to memory, for sure causing out-of-memory exception is just a matter of time.

To fix this I change the code as follows:
String fileName = "TestCase_Results_"+planId;
httpServletResponse.setContentType("application/zip");
httpServletResponse.setHeader("Content-Disposition","attachment; filename=TestCase_"+planId+"_Results.zip;");
ServletOutputStream out = httpServletResponse.getOutputStream();
ZipOutputStream zout=new ZipOutputStream(out);//use ServletOutputStream as actual OutputStream for zip file instead of ByteArrayOutputStream.
...

Cheers

Chris
12 years ago
Basically you can fllow the steps to do so:
1, Create xml format data you want to export;
2, Create a xsl file(XSLT) to handle the output format, for example html format;
3, Transform the xml data using xsl file to dynamically output the presentation data.

Hope this helps!

Chris
12 years ago
Hi All,

I am creating a web application in which users can download multiple audio files from database as a zip file.

Here is the code segment:

try{
String fileName = "TestCase_Results_"+planId;
ByteArrayOutputStream bout=new ByteArrayOutputStream();
ZipOutputStream zout=new ZipOutputStream(bout);
ServletOutputStream out = httpServletResponse.getOutputStream();
zout.putNextEntry(new ZipEntry(fileName+".xml"));
zout.write(exportedTestCaseResults2XML.getBytes());
zout.closeEntry();
zout.putNextEntry(new ZipEntry(fileName+".html"));
zout.write(exportedTestCaseResults2HTML.getBytes());
zout.closeEntry();
List<String> recordings = documentAndRecordings.getRecordings();
for(String recording : recordings) {
if(recording != null && !recording.equals("")) {
final Blob blob = AIMT_DB.getRecoridngBlob(recording);
try {
Long.parseLong(recording);//make sure the name is a number.
zout.putNextEntry(new ZipEntry(recording+".wav"));
zout.write(blob.getBytes(1, (int)blob.length()));
zout.closeEntry();
} catch(Exception e) {
logger.error(e.getMessage());
}
}
}
zout.finish();

httpServletResponse.setContentType("application/zip");
httpServletResponse.setHeader("Content-Disposition","attachment; filename="+fileName+".zip;");
httpServletResponse.setContentLength(bout.size());

out.write(bout.toByteArray());
out.flush();

When I was testing this download feature, if the audio files are more or the size of a individual audio is bigger, I got an exception:
java.lang.OutOfMemoryError: Java heap space

How to fix this?

Any help is greatly appreciated!

Chris
12 years ago