NullPointerException from generated code? (WLS81SP2)
We are receiving an NPE, and looks like it is coming from
the generated code. Most oddly, it is intermittent; repeating the operation that causes the error often succeeds. Any thoughts? Here is the stack trace:
2005-09-12 17:21:31.273 | payprocess.ProcessBatch:process | EJB Exception: ; nested exception is:
javax.ejb.TransactionRolledbackLocalException: EJB Exception: ; nested exception is: javax.ejb.TransactionRolledbackLocalException: EJB Exception: ; nested exception is: java.lang.NullPointerException
java.rmi.RemoteException: EJB Exception: ; nested exception is:
javax.ejb.TransactionRolledbackLocalException: EJB Exception: ; nested exception is: javax.ejb.TransactionRolledbackLocalException: EJB Exception: ; nested exception is: java.lang.NullPointerException
at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:284)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:244)
at org.ecmc.nib.batch.session.PaymentProcessFacade_blomzu_EOImpl_812_WLStub.processPayments(Unknown Source)
at org.ecmc.nib.batch.payprocess.ProcessPaymentsHelper.queryFredTransPosted(ProcessPaymentsHelper.java:72)
at org.ecmc.nib.batch.payprocess.ProcessBatch.checkForPayments(ProcessBatch.java:206)
at org.ecmc.nib.batch.payprocess.ProcessBatch.process(ProcessBatch.java:133)
at org.ecmc.common.batch.AbstractBatchJob.startBatch(AbstractBatchJob.java:40)
at org.ecmc.nib.batch.payprocess.ProcessPayments.main(ProcessPayments.java:71)
Caused by: javax.ejb.TransactionRolledbackLocalException: EJB Exception: ; nested exception is: javax.ejb.TransactionRolledbackLocalException: EJB Exception: ; nested exception is: java.lang.NullPointerException
at weblogic.ejb20.internal.EJBRuntimeUtils.throwTransactionRolledbackLocal(EJBRuntimeUtils.java:248)
at weblogic.ejb20.internal.BaseEJBLocalHome.handleSystemException(BaseEJBLocalHome.java:247)
at weblogic.ejb20.internal.BaseEJBLocalObject.postInvoke(BaseEJBLocalObject.java:327)
at org.ecmc.nib.batch.session.RouterFacade_s27p4a_ELOImpl.route(RouterFacade_s27p4a_ELOImpl.java:57)
at org.ecmc.nib.batch.session.PaymentProcessFacadeBean.processPayments(PaymentProcessFacadeBean.java:38)
at org.ecmc.nib.batch.session.PaymentProcessFacade_blomzu_EOImpl.processPayments(PaymentProcessFacade_blomzu_EOImpl.java:46)
at org.ecmc.nib.batch.session.PaymentProcessFacade_blomzu_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Oops, sorry about that, grabbed the stack trace from the wrong spot; the correct trace is below:
####<Sep 12, 2005 5:21:31 PM CDT> <Info> <EJB> <wlsprd2.ecmc.lan> <ms1> <ExecuteThread: '20' for queue: 'weblogic.kernel.Default'> <PMT_PROCESS> <BEA1-593B17F9A1A85E2AA270> <BEA-010051> <EJB Exception occurred during invocation from home: org.ecmc.nib.model.LoanCancelFacade_fy2xso_HomeImpl@184a0b7 threw exception: java.lang.NullPointerException
java.lang.NullPointerException
>
####<Sep 12, 2005 5:21:31 PM CDT> <Info> <EJB> <wlsprd2.ecmc.lan> <ms1> <ExecuteThread: '20' for queue: 'weblogic.kernel.Default'> <PMT_PROCESS> <BEA1-593B17F9A1A85E2AA270> <BEA-010051> <EJB Exception occurred during invocation from home: [email protected]89 threw exception: javax.ejb.TransactionRolledbackLocalException: EJB Exception: ; nested exception is: java.lang.NullPointerException
javax.ejb.TransactionRolledbackLocalException: EJB Exception: ; nested exception is: java.lang.NullPointerException
java.lang.NullPointerException
javax.ejb.TransactionRolledbackLocalException: EJB Exception: ; nested exception is: java.lang.NullPointerException
at weblogic.ejb20.internal.EJBRuntimeUtils.throwTransactionRolledbackLocal(EJBRuntimeUtils.java:248)
at weblogic.ejb20.internal.BaseEJBLocalHome.handleSystemException(BaseEJBLocalHome.java:247)
at weblogic.ejb20.internal.BaseEJBLocalObject.postInvoke(BaseEJBLocalObject.java:327)
at org.ecmc.nib.model.LoanCancelFacade_fy2xso_ELOImpl.localGetLoanPlacementStatusTypCd(LoanCancelFacade_fy2xso_ELOImpl.java:228)
at org.ecmc.nib.batch.session.payprocess.CheckLoanBalance.update(CheckLoanBalance.java:40)
at org.ecmc.nib.batch.session.payprocess.RouteToMethods$RouteMeQueryHandler.processStep(RouteToMethods.java:240)
at org.ecmc.nib.batch.session.payprocess.RouteToMethods$RouteMeQueryHandler.processRow(RouteToMethods.java:111)
at org.springframework.jdbc.core.JdbcTemplate$RowCallbackHandlerResultSetExtractor.extractData(JdbcTemplate.java:939)
at org.springframework.jdbc.core.JdbcTemplate$1QueryStatementCallback.doInStatement(JdbcTemplate.java:256)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:204)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:266)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:270)
at org.ecmc.nib.batch.session.payprocess.RouteToMethods.routeMe(RouteToMethods.java:62)
at org.ecmc.nib.batch.session.RouterFacadeBean.route(RouterFacadeBean.java:35)
at org.ecmc.nib.batch.session.RouterFacade_s27p4a_ELOImpl.route(RouterFacade_s27p4a_ELOImpl.java:46)
at org.ecmc.nib.batch.session.PaymentProcessFacadeBean.processPayments(PaymentProcessFacadeBean.java:38)
at org.ecmc.nib.batch.session.PaymentProcessFacade_blomzu_EOImpl.processPayments(PaymentProcessFacade_blomzu_EOImpl.java:46)
at org.ecmc.nib.batch.session.PaymentProcessFacade_blomzu_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Similar Messages
-
Remove Schema from Generated Code
Hi,
I have the common situation where I want to extract data from tables in multiple schemas on a database seperate to both my runtime/staging schema and my target schema.
This is handled quite simply through the use of db_links, created through locations, this is fine. However occasionally the source schema that I am trying to extract from can be changed due to a quirk in the source application. Now this is fine from a location point of view I just unregister the location and point it to the new schema. However for some reason the code owb is generating has both the schema and db_link meaning any schema name changes will require a complete regeneration of the code (e.g. "NON_PERS"."ET_OCLIENT_COSTS"@"CEPPRD@PLAN_NON_PERS_LOCATION"), so if the table (ET_OCLIENT_COSTS) moves from the NON_PERS schema to CY_NON_PERS the code is now invalid.
Is there anyway around this it seems unnecessary to have both the schema and the db_link as the link only has access to the one schema anyway! Therefore can the schema be removed systematically through OWB?
fyi, I'm running OWB 10g Release 2.
Thanks...JonathanHere is some info which might be useful too....
If you use an unbound table/view as the source in OWB, the code will generate with no schema or dblink. With this approach when the map is deployed as long as the name is resolved you can magic up what the object actually is at execution time. For example it could be a view/synonym where you replace its definition before execution.
To add an unbound table operator....say you have a table T in module S, add S.T into the map (it will be operator T), add a new table operator T1 into map, map from T.INOUTGRP1 to T1.INOUTGRP1, delete operator T from map, rename T1 to T. You now have an unbound table operator which when the code is generated will just reference the name T.
Cheers
David -
In wadl2java-generated code, NullPointerException from HttpTransportPipe
I wrote a WADL document and used JAXB schemagen to create an XSD for my Jersey RESTful web-service, and referenced that XSD in that WADL document.
Then, I used wadl2java to generate client-code for my service.
However, then, I had numerous jar-dependency problems while trying to run that generated code. Perhaps I got myself into some trouble by choosing the wrong jar-file in one case or another. I thought it was odd that one of the missing class-files was SOAPException. Another one is part of FastInfoSet. And one of the problems seemed to require adding a JSR-related jar provided by BEA.
I managed to find some possibly relevant source-code. However, it seems to simply indicate no need for an outputStream for a GET-request, which makes lots of sense:
From HttpClientTransport:
118: public OutputStream getOutput() {
119: try {
120: createHttpConnection();
121: sendCookieAsNeeded();
122: // for "GET" request no need to get outputStream
123: if (requiresOutputStream()) {At this point, I'm not able to use wadl2java, thanks to this failure to get this generated client-code running. I'd like to avoid writing custom client-code instead. I'd sooner revert to SOAP and wsdl2java.
Any help with this would be much appreciated.
Exception in thread "main" javax.xml.ws.WebServiceException: java.lang.NullPointerException
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:157)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:74)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:559)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:518)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:503)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:400)
at com.sun.xml.ws.client.Stub.process(Stub.java:228)
at com.sun.xml.ws.client.dispatch.DispatchImpl.doInvoke(DispatchImpl.java:167)
at com.sun.xml.ws.client.dispatch.DispatchImpl.invoke(DispatchImpl.java:193)
at com.sun.research.ws.wadl.util.JAXBDispatcher.doGET(JAXBDispatcher.java:92)
at com.foo.bar.restapi.client.Endpoint$Product.getAsProduct(Endpoint.java:66)
at com.foo.bar.restapi.client.Test.main(Test.java:9)
Caused by: java.lang.NullPointerException
at java.io.Writer.<init>(Unknown Source)
at java.io.OutputStreamWriter.<init>(Unknown Source)
at com.bea.xml.stream.XMLOutputFactoryBase.createXMLStreamWriter(XMLOutputFactoryBase.java:45)
at com.sun.xml.ws.api.streaming.XMLStreamWriterFactory$Default.doCreate(XMLStreamWriterFactory.java:204)
at com.sun.xml.ws.api.streaming.XMLStreamWriterFactory$Default.doCreate(XMLStreamWriterFactory.java:199)
at com.sun.xml.ws.api.streaming.XMLStreamWriterFactory.create(XMLStreamWriterFactory.java:152)
at com.sun.xml.ws.encoding.xml.XMLCodec.encode(XMLCodec.java:35)
at com.sun.xml.ws.encoding.MimeCodec.encode(MimeCodec.java:64)
at com.sun.xml.ws.encoding.XMLHTTPBindingCodec.encode(XMLHTTPBindingCodec.java:173)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:128)
... 11 moreThanks, that solved that problem.
Then, however, I had a couple of other problems, having to do with namespace declarations. I've apparently fixed them.
The one remaining problem is that the generated code seems to treat a certain template parameter as if it were a header-parameter. The WADL-file definitely uses style="template" for that parameter.
I temporarily manually patched the generated EndPoint class to get it working.
The effect of this problem was that the result was in the form of the HTML-message returned by Apache when a resource cannot be found. That was because that template parameter was missing and was being passed instead in a header.
Perhaps I'll investigate this further at some point. However, "time's a wastin'", and reverting to SOAP is now quite likely.
Thanks. -
Error while deploying generated code from sup to iPhone
Hi
I generated the code using Sap unwired platform for Objective-c. I followed the steps specified in the below link
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc01213.0153/doc/html/mqu1264543829068.html
for deploying the generated code into iPhone simulator, i am getting the following error
Undefined symbols:
"_OBJC_CLASS_$_SUPEntityAlias", referenced from:
objc-class-ref-to-SUPEntityAlias in SUP101_Customer.o
objc-class-ref-to-SUPEntityAlias in SUP101_LogRecordImpl.o
Can any one help me in this
Edited by: KiranSanka on Dec 2, 2010 1:18 PM
Edited by: KiranSanka on Dec 3, 2010 7:26 AMHi
While compiling did you get a warning? something along the line "missing required architecture i386 in fileu201D? if so refer this link http://stackoverflow.com/questions/1456185/build-error-missing-required-architecture-i386-in-file
Regards
Jinesh -
How to use generated code from "Import Web Services" with Cairngorm Framework
I recently downloaded Flex Builder 3 beta 2 and tried out the
wizard that lets you import web services. The code that is
auto-generated makes if fairly straight forward to consume web
services using the object types defined in the WSDL. No longer does
the developer need to decode the XML payload! The only problem I am
having is how does you integrate the auto- generated code with the
Cairngorm framework? This seems like a huge question for anyone who
might want to leverage Cairngorm and the auto-generated proxy code
in the same project (like me).
Here are the problems that I see so far.
1) How do you configure the generated service class to work
with the Cairngorm service locator? The service constructor only
accepts a “LCDS destination string” which implies that
you must use Lifecycle data services. Unfortunately, the project I
am trying to retrofit currently uses a WebService and does not use
data services. All I really need to do is change the endpoint URL
(ie from local to a development server). This issue is noted in the
bug https://bugs.adobe.com/jira/browse/FB-8456. What I think is
needed is a way to set the endpointURI in the Services.mxml file.
2) Even if I come up with a hack around #1, I do not receive
a callback to my IResponder even though I register it immediately
after the method call. I can register and listener function within
my business delegate and receive the callback, but my Command
object, which implements IResponder, does not receive the call back
even though it is registered. From what I read in the ASDocs it
should but it doesn’t for me!
These are the issues I have observed in 3 hours of messing
with this. I hope this makes sense. I would love to integrate
auto-generated web service proxies into Cairngorm but I don’t
see a straight forward way without re-architecting Cairngorm. Has
any one else run across this issue? If so, do you have any insights
on how to proceed? Any help is appreciated.Since I posted this question, I have abandoned the notion of
auto-generated web services and embraced the good old FDS concept
where the RemoteObject meta-tag does all the conversion work for
me. We are now using the Granite DS package and it is working well
for us. I would love to consume web services, but it just isn't
worth the hassle when all you have to do with Granite (and FDS) is
cast your return objects to the proper object type.
BTW, since this posting, I have investigated competing Flex
app frameworks. After my research, I checked out the PureMVC
framework. Wow!! Cairngorm always left me with an uneasy feeling
and I guess I am not alone. Apparently, Cliff Hall felt the same
way. That is why he started the project. I like his approach alot
more than Cairngorm especially since it includes notifications
which allow me to broadcast my own app level events independent
from the AS Event framework. Check out PureMVC. For what it is
worth, it has my humble endorsement. Cliff was even gracious enough
to acknowledge the other Adobe Consulting guys for their work. Good
for you Cliff, I respect that. Check out a better way at
http://www.puremvc.org/ -
Can't generate code from class diagram
I have installed Studio Enterprise 8. I tried to create a class, but when I right-clicked on a class, there was no "Generate Code" on the contextual menu.
I've tried the Help guide as pasted below. Would appreciate anybody's help. Thanks.
To generate code:
In the Projects window or in a diagram, right-click the element or elements for which you want to generate code.
In the Projects window, this code generation function is supported for entire UML projects and for individual diagram elements.
On the contextual menu, choose Generate Code. The IDE generates source code for all of the target items and displays the code in the Source Editor.Thanks, but I still have problem.
File / New Project
UML / Java Platform Model
Name: UMLTest Location: D:\UML Unchecked Generate Code
The UMLTest Project appears in the Project Window
--- So far so good
File / New Project
General / Java Application
--- There is no General category
Under Category: Samples, Standard, UML, Web
Under Samples, there is general, but project = Anagram Game.
I still can't create a Java application from scratch.
Using Web and Standard, I must provide ANT -
Accessing connection from java and generated code
In JDeveloper 10.1.2.x I set up a connection and selected a stored procedure and generated java to call the stored proc. All good.
Now, in a web service application I want to call the method in that class that was generated.
So, the generated class has setConnectionContext(), getConnectionContext(), etc methods. I don't know how to use them. What is a ConnectionContext?
How do I provide the database connection information and call the method in the generated code that I need?
My Oracle AS server has a datasource configured that is the one I would like to use, but I don't know how to 'access' it via java in the context of this generated class.
I am deploying to Oracle AS 10.1.2,
thanksHi, well CSV is not currently an Excel file, it is a Comma Separated Values
file which can be read through Excel.
Now, if you wish to remove the header, I would purpose that you develop an
application that reads the CSV file, as it is mere text, and that it also reads
another file (lets call it confirguration.txt) in which you determine the pattern
you want to remove, then you just read your report and if a string line
matches the pattern you defined in the configuration.txt file, then you simply
erase it.
And if you keep interested in reading real Excel files (xls), I would
recommend you use POI-HSSF API from Apache.org
http://jakarta.apache.org/poi/hssf/index.html
Hope this helps, cya around. -
How i can generat VHDL or Verilog code from labview code
how i can generat VHDL or Verilog code from labview code ( i have a labview code and i want to convert it to VHDL or Verilog code how i can do that )
Mouath,
There is no feature in LabVIEW to export your VIs as VHDL files. You are able to include your own HDL in your LabVIEW VI (using the HDL node). I encourage you to provide your feedback related to this issue at ni.com/contact. The product suggestion submitted are taken seriously and reviewed by National Instruments.
Cheers,
Jonah
Applications Engineer
National Instruments
Jonah Paul
Marketing Manager, Embedded Software
Evaluate the LabVIEW RIO Platform! - ni.com/rioeval -
Generate IDL from Java Code, Classes, UML, etc?
Hi,
is is possible to generate IDL code from Java Code, Classes, UML, ... using JDeveloper?
I know this is somewhat reverse engeneering, but it would speed up the migration of our existing Java project...
Thanks,
JohanHi,
is is possible to generate IDL code from Java Code, Classes, UML, ... using JDeveloper?
I know this is somewhat reverse engeneering, but it would speed up the migration of our existing Java project...Unfortunately it does not. The IDL to Java conversion is handled under the covers by the idl2java.exe included with the database. You might want to search on google for a IDL generator from java source.
java2iiop (another tool) just generates IIOP stubs from classes and interfaces, but I don't think it creates IDL.
Rob -
Generated Code different from OWB Client and Deployment Manager....
Hi,
I developed the mappings using OWB9.2 and generated the code.
But when same mapping is used to generated code from deployment manager it is having extra code like WB_RT% procedures/functions.
Why this is happening, does any body have idea on this.
Please let me know.
With Regards,
Kranthi..When you generate code from within your mapping, you'll get clean sql. But when you deploy your mapping and create package the code will contain more than just sql used for loading your tables, like control procedures etc. based on your mapping configuration, table loading options etc.
If you create mapping that will load table using TRUNCATE/INSERT option and generate code you will see only INERT INTO code, but when you deploy your mapping the code will include TRUNCATE TABLE code. -
I'm using NetBeans IDE 6.1 UML editor to generate java code. When I choose the "Generate Code" option and select the options I want. The console shows the message:
Generating source from template "Java/CompilationUnit.java" ...ERROR: java.lang.NullPointerException
How do I find where the Null Pointer Exception is being thrown?Rick.Lohmeyer wrote:
I'm using NetBeans IDE 6.1 UML editor to generate java code. When I choose the "Generate Code" option and select the options I want. The console shows the message:
Generating source from template "Java/CompilationUnit.java" ...ERROR: java.lang.NullPointerException
How do I find where the Null Pointer Exception is being thrown?You go over to the NetBeans forum and ask them the same questions, since this is not a Java question, but a IDE specific question. Also if you are not a fairly seasoned programmer, then may I happily wish you cheers with all the frustration and grief that inevitably awaits you in your autocoding endeavors. -
OWB Error while generating Code for a mapping
I have a simple mapping loading from a source to a flat file. When I try to generate code it gives me the following Error
VLD-2357: Target Data File name not specified for file <target Flat file name>.
I am new to OWB so any help on the same will be greatly appreciated. How can I specify target Data File name in the mapping configuration under Flat file operators
Thanks
AnishIf you configure the mapping in the UI from the main design tree and select the name of your file operator under the tree node 'Flat File Operators' on the right hand side panel the properties should be displayed - one of these properties is 'Target Data File Name', enter the name of your target data file name.
Cheers
David -
Error while generating code for deployment
I am getting the following error:
Error generating findTest1ByMarks(java.lang.Integer) query for Bean Test1(Abstract scheme name=Test1) Error=query cannot be pushed down
Query="select ..."
Could someone help me?
I am trying to generate code of Container Managed Entity Bean in WSAD 5.0.
ThanksIf you configure the mapping in the UI from the main design tree and select the name of your file operator under the tree node 'Flat File Operators' on the right hand side panel the properties should be displayed - one of these properties is 'Target Data File Name', enter the name of your target data file name.
Cheers
David -
Running a jar file from java code
Hi!
Im trying to run a jar file from my code.
I've tried Classloader, but that doesnt work because it doesnt find the images (also embedded in the 2nd jar file).
WHat I would like to do is actually RUN the 2nd jar file from the first jar file. There must be a way to do this right?
any ideas?ok, I found some wonderful code (see below) that will try to start the jar. But it doesn't. What it does is produce the following error when my application runs...
So it's not finding the images in the jar file that I am trying to run? Strange. I checked the URL that sending, but it seems ok....
I think I will check the url again to make sure......
any ideas?
Uncaught error fetching image:
java.lang.NullPointerException
at sun.awt.image.URLImageSource.getConnection(Unknown Source)
at sun.awt.image.URLImageSource.getDecoder(Unknown Source)
at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source)
at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
at sun.awt.image.ImageFetcher.run(Unknown Source)
the code....
/* From http://java.sun.com/docs/books/tutorial/index.html */
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.JarURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.jar.Attributes;
* Runs a jar application from any url. Usage is 'java JarRunner url [args..]'
* where url is the url of the jar file and args is optional arguments to be
* passed to the application's main method.
public class JarRunner {
public static void main(String[] args) {
URL url = null;
try {
url = new URL(args[0]);//"VideoTagger.jar");
} catch (MalformedURLException e) {
System.out.println("Invalid URL: ");
// Create the class loader for the application jar file
JarClassLoader cl = new JarClassLoader(url);
// Get the application's main class name
String name = null;
try {
name = cl.getMainClassName();
} catch (IOException e) {
System.err.println("I/O error while loading JAR file:");
e.printStackTrace();
System.exit(1);
if (name == null) {
fatal("Specified jar file does not contain a 'Main-Class'"
+ " manifest attribute");
// Get arguments for the application
String[] newArgs = new String[args.length - 1];
System.arraycopy(args, 1, newArgs, 0, newArgs.length);
// Invoke application's main class
try {
cl.invokeClass(name, newArgs);
} catch (ClassNotFoundException e) {
fatal("Class not found: " + name);
} catch (NoSuchMethodException e) {
fatal("Class does not define a 'main' method: " + name);
} catch (InvocationTargetException e) {
e.getTargetException().printStackTrace();
System.exit(1);
private static void fatal(String s) {
System.err.println(s);
System.exit(1);
* A class loader for loading jar files, both local and remote.
class JarClassLoader extends URLClassLoader {
private URL url;
* Creates a new JarClassLoader for the specified url.
* @param url
* the url of the jar file
public JarClassLoader(URL url) {
super(new URL[] { url });
this.url = url;
* Returns the name of the jar file main class, or null if no "Main-Class"
* manifest attributes was defined.
public String getMainClassName() throws IOException {
URL u = new URL("jar", "", url + "!/");
JarURLConnection uc = (JarURLConnection) u.openConnection();
Attributes attr = uc.getMainAttributes();
return attr != null ? attr.getValue(Attributes.Name.MAIN_CLASS) : null;
* Invokes the application in this jar file given the name of the main class
* and an array of arguments. The class must define a static method "main"
* which takes an array of String arguemtns and is of return type "void".
* @param name
* the name of the main class
* @param args
* the arguments for the application
* @exception ClassNotFoundException
* if the specified class could not be found
* @exception NoSuchMethodException
* if the specified class does not contain a "main" method
* @exception InvocationTargetException
* if the application raised an exception
public void invokeClass(String name, String[] args)
throws ClassNotFoundException, NoSuchMethodException,
InvocationTargetException {
Class c = loadClass(name);
Method m = c.getMethod("main", new Class[] { args.getClass() });
m.setAccessible(true);
int mods = m.getModifiers();
if (m.getReturnType() != void.class || !Modifier.isStatic(mods)
|| !Modifier.isPublic(mods)) {
throw new NoSuchMethodException("main");
try {
m.invoke(null, new Object[] { args });
} catch (IllegalAccessException e) {
// This should not happen, as we have disabled access checks
} -
Auto generated code in makefile
For our product we have a TCL script that reads a series of text files and generates C++ classes for easy access to database records. Our code has been in use for make years and works very well. We have always used a solaris command prompt dmake to compile, which first generates the C++ files then complies them. It uses a series of enviroment variables which a user must set before compilation.
I recently tried to create a Sun Studio Express based on NetBeans 6.5.rc1 project from a make file. This has worked for every other makefile except for this one. The others do not have any auto generated code.
To run sun studio I in a command prompt source in the environments then run netbeans. Then I choose to build the product but I get an error. I then try to copy the command it is running into telnet window and it works fine. Does anyone have an idea on why in the sun studio I get and error while the telnet window works fine.I think the problem is that the SunStudio IDE runs the build command in a wrong directory.
Can you verify that the working directory is correct?
(it is in project properties: Build > Make)
Also you can find this directory in the message in the output, when you try to build the project.
That's the message, that you copied to the terminal window.
Thanks,
Nik
Maybe you are looking for
-
Photoshop CC 2014 for PC will not copy or paste
Running: Photoshop CC 2014 for PC Windows 8.1 Pro, R2 64 bit, AMD FX3 8350 with 16GB RAM. 75% of RAM free Photoshop CC 2014 for PC will not copy or paste. When I create a line of text and want to copy and paste the text in the same document, the copy
-
Hope someone can help.
-
The "Aux. Account Assignment 1" field in COEP table appears as KSIN00011987
We are facing an issue with field "Aux. Account Assignment 1" in COEP table. When we display this field in our Z report it appears as "KSIN0001198763" (for example) where 1198763 is a cost center. Whereas; the same field for the same document when
-
I need to build idocs from external systems to SAP, how can I do that? Do I have to use structures EDIDC and EDIDD? What fields should I fill and how? Does some one has somekind of manual that describe basic idocs and how to use them? Thanks in adva
-
How to Auto Select some RadioButton on page load using ADF/JSF
Hi, I am learning ADF and need some help. I have multiple radio buttons and couple of text boxes on my page. How can I make some radio button be selected based on some value from a database table and also populate the text boxes with the corrospondin