Loading .jar and .class in MX7
I have a cfx tag that includes a .class and .jar file. I
could do this on the old MX server but in MX7 the option is not in
the cfide/administrator.
I copied the .jar and .class files into the
c:\cfusionmx7\runtime\lib\ directory and then added them to the
bottom of the jvm.config file with the following entry. (note: The
.jar file is called MYNEWFILE.jar)
java.class.path={application.home}/servers/lib,{application.home}/../lib/macromedia_driver s.jar,{application.home}/lib/cfmx_mbean.jar,{application.home}/lib,{application.home}/lib/ MYNEWFILE.jar,{application.home}/../wwwroot/WEB-INF/lib/
I then rebooted the server. I also have a ".class" file that
goes with this. I have no idea where to put that thing. The cfx
(which I mapped in the administrator).
I get the standard 500 error saying:
HTTP 500 - Internal server error
Internet Explorer
even though I have debugging going to my laptop.
Here is the output of the exception.log
"Error","jrpp-0","07/05/07","16:04:14",,"com/allaire/cfx/CustomTag
The specific sequence of files included or processed is:
C:\Inetpub\wwwroot\Pauly\example.cfm "
java.lang.NoClassDefFoundError: com/allaire/cfx/CustomTag
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown
Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at
jrunx.util.JRunURLClassLoader.loadClass(JRunURLClassLoader.java:77)
at java.lang.ClassLoader.loadClass(Unknown Source)
at
jrunx.util.JRunURLClassLoader.loadClass(JRunURLClassLoader.java:77)
at java.lang.ClassLoader.loadClass(Unknown Source)
at
jrunx.util.JRunURLClassLoader.loadClass(JRunURLClassLoader.java:77)
at
jrunx.util.JRunURLClassLoader.loadClass(JRunURLClassLoader.java:69)
at
coldfusion.bootstrap.BootstrapClassLoader.loadClass(BootstrapClassLoader.java:207)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at coldfusion.tagext.CfxTag.doStartTag(CfxTag.java:88)
at
coldfusion.runtime.CfJspPage._emptyTag(CfJspPage.java:1908)
at
cfexample2ecfm2026642798.runPage(C:\Inetpub\wwwroot\Pauly\example.cfm:3)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
at
coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:343)
at
coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
at
coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:210)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:86)
at
coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:50)
at
coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:52)
at
coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:2 8)
at
coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
at
coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
at
coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.CfmServlet.service(CfmServlet.java:105)
at
coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:78)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
at
jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at
jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:257)
at
jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
at
jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
at
jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:349)
at
jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:457)
at
jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:295)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
"Information","Thread-10","07/05/07","16:14:10",,"Address
already in use: JVM_Bind"
java.net.BindException: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(Unknown Source)
at java.net.ServerSocket.bind(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at
coldfusion.server.jrun4.metrics.CfstatServer.run(CfstatServer.java:64)
Any help would be greatly appreciated, as I've been working
on this for a while. I couldn't find a solution in the forums so I
thought I would post. Thanks!
Pauly
>> java.lang.NoClassDefFoundError:
com/allaire/cfx/CustomTag
Is the CFX.jar in the classpath?
> The option is not in the cfide/administrator.
What option? The administrator has several options for custom
jars, tags, et.
- Extensions -> Custom Tag Paths
- Extensions -> CFX Tags
CF will also look in these directories automatically
- {cf_webroot}/WEB-INF/classes (for classes)
- {cf_webroot}/WEB-INF/lib (for jars)
Similar Messages
-
I am very new to Java world. Anyone know the difference between *.jar and *.class file. Another one is java servlet and java applet, are they the same? Please give simple answer. Thanks.
Hi,
When you compile any Java file, it will create its class file.
And jar file is a collection of such different class files.
Servlet is a server side application/program which runs on the webserver & gives the output in html format.
Applet is a client side application/program which runs on the client machine. But there are many restrictions for applet such as it can not access the local machine file system etc.
You can get more details about Applet & Servlet on this site.
Bye.
Ajay. -
Load Jar and access a class in jar at run time
I need help from you.
How to load a Jar and access a class in the jar at run time?
When i try the following code it works fine while running in Java (Jdk1.5).If iam running the same code in servlet,ClassCastException occurs.
Error Message : ClassCastExcption : jartest1 cannot be cast to Thing
test.jar contains jartest.class and Thing.class
jartest1.java
try{
File file =new File("test.jar");
String lcStr ="jartest";
URL jfile = new URL("jar", "", "file:" + file.getAbsolutePath() +"!/");
URLClassLoader cl = URLClassLoader.newInstance(new URL[] { jfile });
Class loadedClass = cl.loadClass(lcStr);
Thing t=(Thing)loadedClass.newInstance();
t.execute();
catch(Exception e)
System.err.println(e);
Thing.java
public interface Thing
void execute();
jartest.java
public class jartest implements Thing
public void exceute()
System.out.println("Welcome");
Thanks and Regards
V.Senthil Kumar
Edited by: senthilv_sun on Dec 16, 2008 8:30 PMsenthilv_sun wrote:
I need help from you.
How to load a Jar and access a class in the jar at run time?
When i try the following code it works fine while running in Java (Jdk1.5).If iam running the same code in servlet,ClassCastException occurs.
Error Message : ClassCastExcption : jartest1 cannot be cast to ThingPresumably we can only hope that that is a transciption error. It always helps to use copy and past actual errors and code rather than manually typing them.
test.jar contains jartest.class and Thing.classWrong.
The interface class and plugable class must not be in the same jar.
A plugable interface requires two components
- Interface (generic sense)
- Functional components.
The Interface must be independant (own jar) so that it is available to the framework (user of plugin) and to the functional components. And the plugable component must not be on the java class path.
This also means that we know for certain that the plugable component is also on the system class path. That is a bad idea as well.
Given that it is pretty pointless to even speculate as to why this error is showing up. Create the correct jar layout. Test using the command line. Then test using servlets. Insure that the plugable jar is NOT on the java classpath for both tests. -
Java - referencing external jar and class files
When compiling (loadjava) a Java class, how can an externally referenced '.jar file' be resolved please? Using '-resolve' doesn't do the job in this case.
Many thanks.I think I've seen an option for this with manifest files (or was it something that had to do with the java plug-in). There was something about the version and only download a new version if it was newer than the one on your local computer. This version thing is something you define in the manifest file at least. Take a look at jar and manifest files, there might be something there.
-
Problem with Form and webutil loading jar and connection
Can anyone shed light on this. Here is my java console output. I then get FRM-90250 and FRM-92101....
Orion-web.xml
<virtual-directory virtual-path="/webutil"
real-path="C:\webutil/lib" />
Forms90.conf
#Virtual path for WebUtil
AliasMatch ^/forms90/webutil/(..*) "c:\webutil/lib/$1"
formsweb.cfg
webUtilArchive=/forms90/webutil/webutil.jar,/forms90/webutil/jacob.jar
[WEBFTU]
pageTitle=Creative Automation Services
form=c:\export\data\ca\prod\webftu.fmx
archive_jini=f90all_jinit.jar,rolloverbutton.jar,hyperlink.jar
archive_ie=f90all.cab
archive=f90all.jar
webUtilArchive=/forms90/webutil/webutil.jar,/forms90/webutil/jacob.jar
WebUtilLogging=off
#WebUtilLogging=Console
# WebUtilLoggingDetail=normal
WebUtilLoggingDetail=Detailed
WebUtilErrorMode=Alert
baseHTMLjinitiator=C:\webutil\server\webutiljini.htm
width=900
height=600
splashScreen=/forms90/images/splash.gif
background=/forms90/images/black.gif
logo=/forms90/images/blackborder.gif
lookAndFeel=Oracle
colorScheme=Titanium
otherparams=useSDI=yes
workingDirectory=c:\export\data\ca\prod
envFile=C:\webutil\server\webutil.env
Oracle JInitiator: Version 1.3.1.9
Using JRE version 1.3.1.9 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\msantry
User has overriden browser's proxy settings.
Proxy Configuration: no proxy
JAR cache enabled
Location: C:\javaburps\CACHE
Maximum size: 50 MB
Compression level: 0
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
q: hide console
s: dump system properties
t: dump thread list
x: clear classloader cache
0-5: set trace level to <n>
Loading http://clientapps.cauto.com/forms90/webutil/webutil.jar from JAR cache
Downloading http://clientapps.cauto.com/forms90/webutil/jacob.jar to JAR cache
Loading http://clientapps.cauto.com/forms90/java/f90all_jinit.jar from JAR cache
RegisterWebUtil - Loading Webutil Version 1.0.2 Beta
Loading http://clientapps.cauto.com/forms90/java/rolloverbutton.jar from JAR cache
Loading http://clientapps.cauto.com/forms90/java/hyperlink.jar from JAR cache
connectMode=HTTP, native.
oracle.forms.net.ConnectionException: Forms session <3> failed during startup: no response from runtime process
at oracle.forms.net.ConnectionException.createConnectionException(Unknown Source)
at oracle.forms.net.HTTPNStream.getResponse(Unknown Source)
at oracle.forms.net.HTTPNStream.doFlush(Unknown Source)
at oracle.forms.net.HTTPNStream.flush(Unknown Source)
at java.io.DataOutputStream.flush(Unknown Source)
at oracle.forms.net.HTTPConnection.connect(Unknown Source)
at oracle.forms.engine.FormsDispatcher.initConnection(Unknown Source)
at oracle.forms.engine.FormsDispatcher.init(Unknown Source)
at oracle.forms.engine.Runform.initConnection(Unknown Source)
at oracle.forms.engine.Runform.startRunform(Unknown Source)
at oracle.forms.engine.Main.createRunform(Unknown Source)
at oracle.forms.engine.Main.start(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Thanks,
Mary SantryThe error does not look like a webutil client side problem - it looks more like a server side issue - perhaps the runtime not being able to find the webutil.pll.
Check your FORMS90_PATH in the webutil.env file and make sure it's not too long (>255 chars) if it is split it and use ORACLE_PATH as well. -
Jars and .class files - security of the source code
Hi,
I have an app that is in a jar file with the .class files (so no source code).
I'm wondering how difficult it is to attain the source code from these .class files in my jar? Looking through the contents of the .class files it seems there is a large amount of readable text. For example I see method names, variables, etc.
This leads me to believe these jars are not secure. What is a better way?
Thanks!
Edit:
Looking around, I've noticed many java decompilers and Sun even supports a dissembler - javap. I think this is not cool, haha.
What way can I protect my code? To me, the value of java just went way down due to the ease at attaining source code (based on what I read in the past hour or so. I have yet to try it myself). I wonder if this impacts companies reasons not to use java?
Edit 2:
I heard that there may be a way to make the jar closed, so you can't say, use winrar, to extract the class files. Does anyone know anything about this?
Message was edited by:
dayrinni
Message was edited by:
dayrinniHi,
I have an app that is in a jar file with the .class
files (so no source code).
I'm wondering how difficult it is to attain the
source code from these .class files in my jar?
Looking through the contents of the .class files it
seems there is a large amount of readable text. For
example I see method names, variables, etc.
This leads me to believe these jars are not secure.
What is a better way?
Thanks!
Edit:
Looking around, I've noticed many java decompilers
and Sun even supports a dissembler - javap. I think
this is not cool, haha.
What way can I protect my code? To me, the value of
java just went way down due to the ease at attaining
source code (based on what I read in the past hour or
so. I have yet to try it myself). I wonder if this
impacts companies reasons not to use java?All intellectual property stored in electronic form is vulnerable. Not just Java bytecode. You can use tools called obfuscators to make decompiling more difficult, which is usually good enough. The truth is, no matter how great you think your code is, it's of a lot less interest to others than you actually think. Unless you've got a particularly sexy argorithm or something, it's not really worth worrying too much about
All you can do is make it more difficult for people to crack things, never prevent it. True of all languages, all electronic media -
I just started learning Java (I used books like "Teach yourself java 2 in 24 hours", "Teach yourself java in 21 days", "Teach yourself object oriented programming in 21 days", etc.), but there are still some things that prevent me from succeeding. I have programmed in PHP, Javascript and StarBasic before.
I'm testing some Swing component. I wanted to use a JFormattedTextField with a MaskFormatter over it. But it seems that I don't have the class installed.
My Code
import javax.swing.JFormattedTextField.*;
import javax.swing.text.MaskFormatter;
MaskFormatter formatter = new MaskFormatter("(###) ###-####");
JFormattedTextField textField = new JFormattedTextField(formatter);Error message: Type MaskFormatter not found
How can I check if the class is installed? I use a Linux deriviant Kubuntu. I looked at /usr/share/java/ , where I find a lot of jars, but none applicable. How do I even know what my classpath is?I use Sun Java 6. This compiles without error for me:
import javax.swing.text.MaskFormatter;
public class XXX
public static void main(String[] args) throws java.text.ParseException
MaskFormatter formatter = new MaskFormatter("(###) ###-####");
} -
How to load all the classes in a JAR file at runtime?
Any clues o:
"How can I force JVM to load all the classes in a specified JAR at once?"
Thanx!
-RajeevWell I was thinking may be there exists an option with "java", when I
am starting an application from a jar file, I could force it to load all
the classes in the JAR. I don't want to do it programically. Is there such
an option available?? Or in other words can I ask JVM to not do the dynamic
loading for the JAR??
Thanx.
List all JarEntries and convert the paths to fully
qualified class files
e.g file in jar
[1] /com/mycompany/proj/X.class
should become
[2] com.mycompany.proj.X
then for each entry issue
Class.forName( [2] ); -
Loading jar files and calling java stored procedure
I am trying to load jai_core.jar, jai_codec.jar, mlibwrapper.jar and another class I created into my project schema. I am having problems with resolving all of the class using the "loadjava -resolve" command as well as using the "alter java class" command. The single class I authored is not in a valid state as well as the PL/SQL wrapper for the function I am calling.
My questions are:
1) Does the single class need to be in a valid state before the PL/SQL wrapper will compile and be in a valid state itself?
2) Are there any special tricks to this becuase the code I am using below doesn't seem to be working correctly?
3. Should I worry about "resolving/validating" all of the class from the jar file? I have read conflicting views on this topic.
SQL> CREATE OR REPLACE FUNCTION get_image (p_fileName in varchar2, p_offset in number )
2 RETURN blob AS LANGUAGE Java
3 NAME 'gov.irs.rtr.image.ImageUtilityFunction.getImage (java.lang.String, int) RETURN oracle.sql.BLOB';
4 /
Warning: Function created with compilation errors.
SQL> show err
Errors for FUNCTION GET_IMAGE:
LINE/COL ERROR
0/0 PL/SQL: Compilation unit analysis terminated
3/1 PLS-00311: the declaration of
"gov.irs.rtr.image.ImageUtilityFunction.getImage
(java.lang.String, int) RETURN oracle.sql.BLOB" is incomplete or
malformed
Any help would be greatly appreciated.
Regards,
JoeyWe are using Oracle 9.2.0.8 and I have written the single class in 1.3.1.
The first loadjava commands I tried were:
loadjava -user username/password -resolve -resolver '((* RTRPROD)(* PUBLIC))' jai_core.jar jai_codec.jar mlibwrapper_jai.jar
loadjava loadjava -user username/password -resolve -resolver '((* RTRPROD)(* PUBLIC) (* -))' ImageUtility.class
Then I tried:
loadjava -user username/password -resolve -resolver '((* RTRPROD)(* PUBLIC) (* -))' jai_core.jar jai_codec.jar mlibwrapper_jai.jar
errors : class javax/media/jai/operator/EncodeDescriptor
ORA-29534: referenced object RTRPROD.com/sun/media/jai/codec/ImageCodec could not be resolved
errors : class javax/media/jai/operator/FileStoreDescriptor
ORA-29534: referenced object RTRPROD.com/sun/media/jai/codec/ImageCodec could not be resolved
errors : class com/sun/media/jai/opimage/BMPRIF
ORA-29534: referenced object RTRPROD.com/sun/media/jai/opimage/CodecRIFUtil could not be resolved
errors : class com/sun/media/jai/opimage/CodecRIFUtil
ORA-29534: referenced object RTRPROD.com/sun/media/jai/codec/ImageCodec could not be resolved
errors : class com/sun/media/jai/opimage/EncodeRIF
ORA-29534: referenced object RTRPROD.com/sun/media/jai/codec/ImageCodec could not be resolved
errors : class com/sun/media/jai/opimage/FPXRIF
ORA-29534: referenced object RTRPROD.com/sun/media/jai/opimage/CodecRIFUtil could not be resolved
errors : class com/sun/media/jai/opimage/GIFRIF
ORA-29534: referenced object RTRPROD.com/sun/media/jai/opimage/CodecRIFUtil could not be resolved
errors : class com/sun/media/jai/opimage/IIPCRIF
ORA-29534: referenced object RTRPROD.com/sun/media/jai/codec/ImageCodec could not be resolved
This error messages goes on and on for 44 files.
I have found out that JAI is part of the Oracle 9 Release 2 but is part of the InterMedia package that is not installed. I would imagine that the JAI libraries mentioned above would be included in InterMedai. However, there are several dependencies on packages distributed in the Sun JDK but not the Oracle Runtime.
Regards,
Joey -
Trying to use the classes in casStubs.jar and get crawl metrics
I was going through the class files available in casStubs.jar and was trying to come up with a script in AppConfig.xml to connect to the CAS server and obtain the crawl status and metrics. I was trying this option because the class com.endeca.eac.toolkit.component.cas.ContentAcquisitionServerComponent does not provide me these features.
+<script id="CheckCrawlStatus">+
+<bean-shell-script><![CDATA[+
import javax.xml.namespace.QName;
import com.endeca.cas.wsdl.*;
final String wsdlUrl = "http://" "${cas.host}" + ":" + "${cas.port}" + "/cas?wsdl";+
final QName name = new QName("http://endeca.com/itl/cas/2010-07", "CasCrawlerService");
CasCrawlerServiceLocator service = new CasCrawlerServiceLocator(wsdlUrl, name);
CasCrawler crawler = service.getCasCrawlerPort();
String crawlName = "myFirstCrawl";
CrawlId crawlId = new CrawlId(crawlName);
Metric[] metricArray = crawler.getMetrics(crawlId);
+ // rest of the code to retrieve crawl metrics +
+]]></bean-shell-script>+
+</script>+
Unfortunately, I am always getting connection refused exception - "java.net.ConnectException: Connection refused". My cas wsdl is loading fine in my browser.
Any ideas about the shortcomings in the code or missing configuration in CAS or DT or platformservices?
Thanks
DevHey Brett,
Awesome, it works now. I went through the source code by de-compiling the class files and figured out why you referred to this extra line of code; great that it didn't miss your "laser eyes". It was really helpful.
Another question for you; a stupid one maybe -
I was also trying to call the web-services through the browser -
http://{cas-host}:{cas-port}/cas/listCrawls - this one works great; gives me the list of all the crawls
http://{cas-host}:{cas-port}/cas/getAllMetrics - this one work great too
But when I try to pass a parameter my service call fails with an exception
http://{cas-host}:{cas-port}/cas/getMetrics?crawlId={crawl-id}
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>java.lang.ClassCastException@1b3bf979 while invoking public java.util.List com.endeca.itl.service.CasCrawlerImpl.getMetrics(com.endeca.itl.cas.api.CrawlId) throws com.endeca.itl.cas.api.CrawlNotFoundException with params {crawl-id}.</faultstring>
</soap:Fault>
</soap:Body>
Note : {cas-host}, {cas-port} and {crawl-id} are placeholders for actual values.
Any idea where I am going wrong?
Thanks
Dev
Edited by: 950423 on Sep 4, 2012 3:13 PM -
Classloader isolation and jar manifest Class-Path headers
I have a system where I am loading a set of jars, each with its own URL classloader. So, Jar a is loaded by Loader A, jar b is loaded by Loader B, and so on.
Each jar has a Manifest Class-Path entry declaring its dependence on other jars. So in the example above, a puts c.jar in its Class-path, and, let's say, b also puts c.jar in its Class-path, unbeknownst to a.
Let's say there's a class Foo in c.jar. I want--need--it to be the case that (loader of a.jar == Foo.class.getClassLoader()) from the perspective of classes found in a.jar, and (loader of b.jar == Foo.class.getClassLoader()) from the perspective of classes found in b.jar.
That is, I want a and b to have their own isolated "copies" of c.jar.
Instead, what I'm finding is that Foo.class is loaded once, and his loader "leaks" over to the other jar's loader, if that makes any sense.
Is there any way to accomplish what I am talking about here?
LairdAs I understand the question - no.Hi; I think you misunderstand the question.
The classes are being loaded by the system loader.
Thus there is no way to seperate them.
If you want them seperate then you must use an
explicit class loader to load them.I am using explicit loaders to load them. Let me try again, because I don't think I was clear.
I have an application that has, let's say, nothing at all in its classpath. That is, it was invoked via "java ApplicationMainClass". No classpath.
Now that application reads, let's say, a properties file containing a list of URLs that point to jars.
Now the application creates a new URLClassLoader for each such URL. So if the mythical properties file has ten lines, then I create ten classloaders, each of which points to one and only one URL.
My problem is, even classes loaded by these isolated, separate classloaders are "leaking" across to other loaders. Remember, the parent classloader of all of these classloaders can't see the jars. Its classpath was empty, remember?
The issue is that the findLoadedClass() method of java.lang.ClassLoader scans the whole VM to see if a given Class was loaded before, and if it was, then by default that Class is simply returned. But I don't want that behavior.
Now, I also don't want the behavior of having to load the silly things off disk each and every time. So how do I retain this true multiple classloader isolation?
Thanks,
Laird -
Loading Jar classes dynamically - 10 Duke points
How can I load a jar class dynamically if it relies on say other interface? Example is, if I have three classes read from the jar file, Test.class, Test1.class and Testable.class
and "class Test implements Testable..."
If I load the Test.class, how do I tell my own class loader that Testable class is along the way, instead of getting a java.lang.NoClassDefFoundError: Testable
Need example source that works for this type of problem.
Cheers
Abraham Khalilprotected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
name = name.replace('/', '.').replace('\\', '.');
try {
// check if system class
return findSystemClass(name);
catch (ClassNotFoundException e) {}
catch (NoClassDefFoundError e) {}
// check if class already loaded
Class cl = null;
JarClassEntry jarEntry = (JarClassEntry) classes.get(name);
if (jarEntry != null) { // new class not loaded
// load class bytes--details depend on class loader
byte[] classBytes = loadClassBytes(name);
if (classBytes == null) {
throw new ClassNotFoundException(name);
String className = name;
if (className.endsWith(".class")) {
className = className.substring(0, className.indexOf(".class")); -
Load the compiled class and deploy programmatically
so, i am making a compiler,
the compilation part is using java compiler api
i want to ask, is there any api to run the generated class
and is there any api to deploy it??
or is it a must to use Runtime.getRuntime().exec ?
thanksIn outline it's pretty easy. The URLClassLoader can load classes from either .jar files and class directories. For dynamic class generation it's not worth using the .jar format, compile into a directory.
Then you just need to create a URLClassLoader using a file: type URL poiting to the base class directory (packages are represented as nested directories inside.)
File classDir = ......
ClassLoader cl = new URLClassLoader(new URL[]{classDir.toURL()});
Class loadedClass = cl.loadClass(className);Some complications:
This will not load the dynamic class if there's a class with the same name and package on the class path.
Having loaded a class, you need to know how to use it. Typically you create an instance with newInstance() and cast it to some interface that these classes are supposed to implement (and which is on the class path). -
Invalid classes after loading jar
Hello everybody,
I have a problem that's killing me for a week. My partners have created small interface in Java that help our application to call some Web services on other machine etc.
When I start one example from DOS prompt using java, everything works fine. But after loading jars into database (Oracle 10.2.0.2) a large number of classec become invalid and my PL/SQL wrapper return message that class cannot be found (or sthg).
My question: how to load those jars into db and prevent them to be invalid. I serached this forum but did not find any satisfying answer.
Any idea welcome.Thx raven for reply...
Analyzing table user_errors I found out that most problems is caused by some classes from packages
com/ibm/etools/webservice/wscbnd/*
com/ibm/etools/webservice/wscdd/*
com/ibm/etools/webservice/wscext/*
com/ibm/etools/webservice/wscommon/*
com/ibm/etools/webservice/wscommonext/*
Does anybody have those packages (classes or jars) to send me so I can try load them and check out if there is improvement.
My mail is: mladenDOTdelicATgmailDOTcom
Thx in advance -
WAR, MANIFEST.MF and class-path to jars
Hello,
I have a WAR shared library shared.mylib consisting of a series of JARs in a WAR:
/WEB-META/
MANIFEST.MF
/WEB-INF/
lib/
lib1.jar
lib2,jar
in the MANIFEST.MF I don't need to specify any Class-Path, since lib/ is considered by default and classes are loaded.
However I need a way to load classes from other directories in the WAR (without specifiying each jar if possible).
I have tried all the possibilities with Class-Path in the MANIFEST, but nothing works. Suppose you have /mylibs/ with many jars other than the default /lib.
What should I have to do to make weblogic load all the claasses in the jars under /mylibs ?
Thanks.http://download.oracle.com/docs/cd/E12840_01/wls/docs103/programming/classloading.html
Maybe you are looking for
-
The operation can't be completed because the item "libsmime3.dylib" is in use. This is the error message I get when i try to install the 7.0.1 update. I found a cisco folder on my MAC and tried to Trash it. It won't leave. Maybe I need it... Some of
-
HT201269 How can I backup to store iphone on an external hard disk drive?
I tried to backup my iphone, my pc did not have the storage, and I don't know how to find the select for external HDD. I dont know if this is possible to backup to external drive. I lost some of my phone contacts and now the contact list is in some a
-
Asset selections only allowed in repeat run
Hi Experts, I am was posted Deprication 2009 with 12 periods from Planned posting run. When I am doing Deprication 2010 with 1 periods from Planned posting run for perticual period its work in test run u2018 T E S T R U N completed successfully , A d
-
Please can you help me in Tuning this query..?
Hi , Please can you help me in re-structuring this query? .Details are given below. I have 2 tables as shown below and data is like this. Position COD IND AAA N BBB N CCC N DDD Y Distance orig dest AAA BBB BBB CCC AAA CCC I need to create the records
-
Hi All.. I have a hierarchy query with description as below SQL> desc manager_entity; Name Null? Type MANAGER_ENTITY_ID NOT NULL NUMBER MANAGER_ENTITY_TYPE_ID NOT NULL NUMBER MANAGER_ENTITY_P