James Leith

Greenhorn
+ Follow
since Feb 27, 2006
Merit badge: grant badges
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 James Leith

Hi folks,
I am trying to create a piece of JNI code( as a dll ) where the
native function invokes JVM_DumpAllStacks which exists
in jvm.lib distributes in Weblogic 8.1. The code works
fine with the call to JVM_DumpAllStacks commented out
and a simple printf() call, but when I try to compile
with JVM_DumpAllStacks uncommented I get a linkage
problem as follows:

C:\AAA\JamesTDU>cl -I. -Ic:\bea\jdk142_05\include -Ic:\bea\jdk142_05\include\win32
-I . /Zd /MD /LD ThreadDumpUtility.c -FeThreadDumpUtility.dll
-link c:\bea\jdk142_05\lib\jvm.lib
ThreadDumpUtility.c
Microsoft (R) Incremental Linker Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.

/debug
/dll
/implib:ThreadDumpUtility.lib
/out:ThreadDumpUtility.dll
c:\bea\jdk142_05\lib\jvm.lib
ThreadDumpUtility.obj
Creating library ThreadDumpUtility.lib and object ThreadDumpUtility.exp
ThreadDumpUtility.obj : error LNK2019: unresolved external symbol _JVM_DumpAllStacks
referenced in function _Java_ThreadDumpUtility_generateThreadDump@8
ThreadDumpUtility.dll : fatal error LNK1120: 1 unresolved externals


I assume this is because either (a) I haven't linked jvm.lib correctly or
(b) Weblogic 8.1 doesn't have JVM_DumpAllStacks in jvm.lib any more. I suspect (a)as I am not very experienced in building dll's using cl.

My build script is as follows:

set JDK_HOME=c:\bea\jdk142_05
set PATH=%JDK_HOME%\lib;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin;C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\ide;%PATH%

set CLASSPATH=C:\AAA\JamesTDU

set SRC_DIR=.

set INCLUDES=-I. -I%JDK_HOME%\include -I%JDK_HOME%\include\win32 -I %SRC_DIR%

set NAME=ThreadDumpUtility

rem cl /c /Zi %INCLUDES% ThreadDumpUtility.c

rem link /dll /out:ThreadDumpUtility.dll ThreadDumpUtility.obj %JDK_HOME%\lib\jvm.lib

cl %INCLUDES% /Zd /MD /LD ThreadDumpUtility.c -FeThreadDumpUtility.dll -link %JDK_HOME%\lib\jvm.lib


My .c file is as follows:

#include <stdio.h>
#include <jni.h>

#include "ThreadDumpUtility.h"

JNIEXPORT void JNICALL Java_ThreadDumpUtility_generateThreadDump(JNIEnv *env, jobject obj)
{
JVM_DumpAllStacks( env, NULL );

//printf("Generating Thread Dump....\n");
}


OS is Windows XP SP2

If anyone can help point out my mistakes I would be most grateful.

Thanks,
James.
15 years ago
Hi folks,
I am trying to create( as a dll) a piece of JNI code where the
native function invokes JVM_DumpAllStacks which exists
in jvm.lib distributed in Weblogic 8.1. The code works
fine with the call to JVM_DumpAllStacks commented out
and a simple printf() call, but when I try to compile
with JVM_DumpAllStacks uncommented I get a linkage
problem as follows:

C:\AAA\JamesTDU>cl -I. -Ic:\bea\jdk142_05\include -Ic:\bea\jdk142_05\include\win32
-I . /Zd /MD /LD ThreadDumpUtility.c -FeThreadDumpUtility.dll
-link c:\bea\jdk142_05\lib\jvm.lib
ThreadDumpUtility.c
Microsoft (R) Incremental Linker Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.

/debug
/dll
/implib:ThreadDumpUtility.lib
/out:ThreadDumpUtility.dll
c:\bea\jdk142_05\lib\jvm.lib
ThreadDumpUtility.obj
Creating library ThreadDumpUtility.lib and object ThreadDumpUtility.exp
ThreadDumpUtility.obj : error LNK2019: unresolved external symbol _JVM_DumpAllStacks
referenced in function _Java_ThreadDumpUtility_generateThreadDump@8
ThreadDumpUtility.dll : fatal error LNK1120: 1 unresolved externals


I assume this is because either (a) I haven't linked jvm.lib correctly or
(b) Weblogic 8.1 doesn't have JVM_DumpAllStacks in jvm.lib any more. I suspect (a) as I am not very experienced in building dll's using cl.

My build script is as follows:

set JDK_HOME=c:\bea\jdk142_05
set PATH=%JDK_HOME%\lib;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin;C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\ide;%PATH%

set CLASSPATH=C:\AAA\JamesTDU

set SRC_DIR=.

set INCLUDES=-I. -I%JDK_HOME%\include -I%JDK_HOME%\include\win32 -I %SRC_DIR%

set NAME=ThreadDumpUtility

rem cl /c /Zi %INCLUDES% ThreadDumpUtility.c

rem link /dll /out:ThreadDumpUtility.dll ThreadDumpUtility.obj %JDK_HOME%\lib\jvm.lib

cl %INCLUDES% /Zd /MD /LD ThreadDumpUtility.c -FeThreadDumpUtility.dll
-link %JDK_HOME%\lib\jvm.lib


My .c file is as follows:

#include <stdio.h>
#include <jni.h>

#include "ThreadDumpUtility.h"

JNIEXPORT void JNICALL Java_ThreadDumpUtility_generateThreadDump(JNIEnv *env, jobject obj)
{
JVM_DumpAllStacks( env, NULL );

//printf("Generating Thread Dump....\n");
}


OS is Windows XP SP2

If anyone can help point out my mistakes I would be most grateful.

Thanks,
James.
15 years ago
Hi folks,
I am trying to create( as a dll) a piece of JNI code where the
native function invokes JVM_DumpAllStacks which exists
in jvm.lib distributed in Weblogic 8.1. The code works
fine with the call to JVM_DumpAllStacks commented out
and a simple printf() call, but when I try to compile
with JVM_DumpAllStacks uncommented I get a linkage
problem as follows:

C:\AAA\JamesTDU>cl -I. -Ic:\bea\jdk142_05\include -Ic:\bea\jdk142_05\include\win32
-I . /Zd /MD /LD ThreadDumpUtility.c -FeThreadDumpUtility.dll
-link c:\bea\jdk142_05\lib\jvm.lib
ThreadDumpUtility.c
Microsoft (R) Incremental Linker Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.

/debug
/dll
/implib:ThreadDumpUtility.lib
/out:ThreadDumpUtility.dll
c:\bea\jdk142_05\lib\jvm.lib
ThreadDumpUtility.obj
Creating library ThreadDumpUtility.lib and object ThreadDumpUtility.exp
ThreadDumpUtility.obj : error LNK2019: unresolved external symbol _JVM_DumpAllStacks
referenced in function _Java_ThreadDumpUtility_generateThreadDump@8
ThreadDumpUtility.dll : fatal error LNK1120: 1 unresolved externals


I assume this is because either (a) I haven't linked jvm.lib correctly or
(b) Weblogic 8.1 doesn't have JVM_DumpAllStacks in jvm.lib any more. I suspect (a) as I am not very experienced in building dll's using cl.

My build script is as follows:

set JDK_HOME=c:\bea\jdk142_05
set PATH=%JDK_HOME%\lib;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin;C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\ide;%PATH%

set CLASSPATH=C:\AAA\JamesTDU

set SRC_DIR=.

set INCLUDES=-I. -I%JDK_HOME%\include -I%JDK_HOME%\include\win32 -I %SRC_DIR%

set NAME=ThreadDumpUtility

rem cl /c /Zi %INCLUDES% ThreadDumpUtility.c

rem link /dll /out:ThreadDumpUtility.dll ThreadDumpUtility.obj %JDK_HOME%\lib\jvm.lib

cl %INCLUDES% /Zd /MD /LD ThreadDumpUtility.c -FeThreadDumpUtility.dll
-link %JDK_HOME%\lib\jvm.lib


My .c file is as follows:

#include <stdio.h>
#include <jni.h>

#include "ThreadDumpUtility.h"

JNIEXPORT void JNICALL Java_ThreadDumpUtility_generateThreadDump(JNIEnv *env, jobject obj)
{
JVM_DumpAllStacks( env, NULL );

//printf("Generating Thread Dump....\n");
}


OS is Windows XP SP2

If anyone can help point out my mistakes I would be most grateful.

Thanks,
James.
15 years ago
Thanks Bear.
15 years ago
JSP
sorry,
<c:out value="${someDay}"/><br>
should read
<c:out value="${doesntExistVar}"/><br>
15 years ago
JSP
Thanks Bear, that's what I was getting at, albeit in a rather circuitous way.
Is it right therefore to say that unlike the "var" form of <c:set>, the "target" version will not attempt to create a bean if the one specified does not exist already.
i.e. with reference to the original post
<c:set value="Friday" target="${jmlbean}" property="dayName"/>
works fine but
<c:set value="Friday" target="${jmlbean2}" property="dayName"/>
throws an exception
and
<c:set value="someval" var="doesntExistVar" scope="page"/>
<c:out value="${someDay}"/><br>
works fine.

James.
15 years ago
JSP
Hi folks,
I'm currently studying for the web component developer exam. using "Head
First Servlets and JSP" and I'm a bit confused by the "target" form of
<c:set>( page 446 ). The cause of the confusion is that rather than give
"target" an identifier like "id" in <jsp:useBean> you appear to have to
give it an object type like you would in Class.forName(). If I've got
that much right then I don't understand how I then get a reference to the
instance of the bean in order to access the property values. What do I do
if I want more than one of these beans in the same scope?

The following code might make this clearer:

In the uncommented section I create an instance of foo.JamesBean using
<jsp:useBean> and give it a reference name "jmlbean" which I can
subsequently use to access the values of the properties. I could, if I
wanted to use another <jsp:useBean> to create a second bean in the same
scope with a different name and refer to them separately.

In the commented out section I'd like to do exactly the same
thing using <c:set> but I don't have the equivalent of the <jsp:useBean>
"id" attribute.


<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>
<body>

Use jsp:UseBean to create a bean in page scope and print its contents...
<br>
<br>
<jsp:useBean id="jmlbean" class="foo.JamesBean" scope="page">
<jsp:setProperty name="jmlbean" property="dayName" value="Monday"/>
<jsp:setProperty name="jmlbean" property="monthName" value="May"/>
<jsp:setProperty name="jmlbean" property="bankHoliday" value="true"/>
</jsp:useBean>

<br>
<br>
Print using EL...
<br>
Day is : ${jmlbean.dayName}<br>
Month is : ${jmlbean.monthName}<br>
Bank Holiday is : ${jmlbean.bankHoliday}<br>
<br>
Print using jsp:getProperty...
<br>

Day is : <jsp:getProperty name="jmlbean" property="dayName"/><br>
Month is : <jsp:getProperty name="jmlbean" property="monthName"/><br>
BH is : <jsp:getProperty name="jmlbean" property="bankHoliday"/><br>

<%--

Even if I create a bean "jmlbean2" with <jsp:useBean> how
would I tell <c:set> to use that bean since I can't
give it an "id"?

<c:set value="Friday" target="${???}" property="dayName"/>
<c:set value="December" target="${???}" property="monthName"/>
<c:set value="false" target="${???}" property="bankHoliday"/>

Print the bean properties:<br>

Day Name : <c:out value="${???.dayName}"/>
Month Name : <c:out value="${???.monthName}"/>
BH : <c:out value="${???.bankHoliday}"/>

--%>

</body>
</html>

Perhaps I've just missed the point of this tag. I have no problems
getting the "var" version of <c:set> to work and judging by the fact
that most of the online tutorials and documentation focus on the
"var" version maybe the "target" version is not widely used. I
appreciate that JSP should be presenting data rather than creating
it; however since it's on the exam I'd like to understand it.

Any advice would be greatly appreciated.

Thanks,
James.
15 years ago
JSP
That's great. Thanks Clifton. I've added the "def" and it all works as expected.
15 years ago
Hi folks,
having come to Javaranch to look up some Jython information I encountered Groovy for the first time and thought I'd have a play with it. I have to say, as a java programmer it is much more intuitive than Jython and I like it a lot. The only problem I have encountered so far is that it doesn't appear to allow me to program to an interface.
I'm using Eclipse 3.1 and wrote something along the lines of

myInterface x;

x = new ParentClass();
x.printMessage();
x = new ChildClass();
x.printMessage();

Which resulted in the following error message "The name x does not refer to a declared variable or class."

ParentClass implements myInterface and ChildClass extends ParentClass and overrides printMessage().

When I cut and paste the code into a java project it compiled fine.

Changing the declaration to
ParentClass x=new ParentClass();
ChildClass y = new ChildClass();
made Groovy happy.


Am I doing something stupid or is this not supported by Groovy yet.

Thanks.
15 years ago