When I run the script locally
HKDFBytesGenerator hkdfBytesGenerator = new HKDFBytesGenerator(new SHA256Digest());
works great and creates the generator, when I upload WAR file (exported from eclipse IDE) and deploy to my dev server the application simply crashes when I get to that line.
Tried surrounding with try/catch - but its like no error is thrown and the output is the path of the package (the app does not get to the next line)
"org.bouncycastle.crypto.generators.HKDFBytesGenerator"
Any ideas how to resolve/whats the issue?
The jars are same in my local and remote env.
Related
Hi all I am new to jboss/wildfly world I am working on a java application which supports both tomcat and wildfly where I have a piece of code which changes the file content dynamically(from java code)...when I execute the following code in tomcat,it updates the file and restarts automatically...but when I tried the same code with wildfly I don't see any updates in file content.
NOTE : I am deploying the .WAR file from admin console (the file is in .WAR).
I tried restarting the wildfly server no changes same old file content.
Here is my piece of java code,
Path nioPath = Paths.get(XYZScript.getPath());
List<String> aLines = new ArrayList<>();
aLines.add("Content 1");
aLines.add("Content 2");
try {
Files.write(nioPath, aLines, ENCODING, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE);
} catch (IOException e) {
I found some links which says we need to redeploy the .WAR or use Overlay
But it should be programmatic the user will change files dynamically
During deployment JBoss / Wildfly unpacks the deployment under $JBOSS_HOME/standalone/tmp/vfs/deployment. It is used as a virtual file system (vfs). But it also gets deleted on undeployment.
In your case you will have to modify the war under $JBOSS_HOME/standalone/deployments and trigger a redeployment by using marker files like <war-name>.war.dodeploy. See here for more information on marker files.
I am trying to write and deploy a simple web-app at Google Cloud Platform. I installed gcloud and the corresponding libraries/plugins on Eclipse in my Mac. I use the following code to try to open a file specified in a HttpServeletRequest:
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("text/html");
resp.getWriter().println("<p>DEBUG: In Create2.</p>");
// get the file info
// to get the value of each input, always use the name and then
// req.getParameter(name);
String fileName = req.getParameter("file");
// create the file
File file = new File(fileName);
resp.getWriter().println("<p>"+file.getAbsolutePath()+"</p>");
if (file.exists()) {
...
}
else {
...
}
I put a test.txt file under project/src/main/webapp directory, run this project as an app engine and submit "test.txt" to servelet. But
In my local machine (localhost:8080), file.exists() always fails and the absolute path printed is
Applications/Eclipse/Contents/MacOS/test.txt
On the contrary, after I deploy the project to Google App Engine, everything works just fine and the absolute path printed is
/base/data/home/apps/XXXX/20170425t133741.400812218449586767/test.txt
I read a couple discussion threads all saying the file access in GAE/Google Cloud Platform is relative path. But why would my eclipse interpret it as an absolutely path when trying to open the file? Is there a fix on this issue so that I can always use relativ path both locally and on google cloud?
Thank you very much.
If you could set the working directory of the local App Engine dev server correctly, you wouldn't have problems using relative paths locally. Unfortunately, as of now, the Cloud Tools for Eclipse plugin doesn't support changing the working directory. Here is what you can do as a workaround:
Run the local dev server and check the server log in the Console view to see the actual web application root the server should use as a working directory. You'll see a log message like this:
WARNING: Your working directory, (<...your current, out-of-sync local server working directory...>) is not equal to your
web application root (<...your workspace...>.metadata/.plugins/org.eclipse.wst.server.core/tmp0/<...your Eclipse project name...>)
Open the Servers view. Stop the server.
Double-click on the server. Click Open launch configuration on the Overview page that pops up.
Select the Arguments tab.
Enter -Duser.dir=<...the directory of the web application root from the server log...> in the VM arguments: box. Click OK. (The Working directory section below doesn't work unfortunately.)
From now on, you won't see the WARNING message, and the server will use the directory you provided as a working directory.
UPDATE: This has been fixed in recent CT4E versions, which automatically set the working directory properly (unless you run multiple projects in a single local server). Update to the latest CT4E if you encounter this issue.
I made an app using javafx and packaged it as exe file. It works fine being started from eclipse but being installed it says
Failed due to exception in main class
no matter what pc it was started at. I've found a few same questions but everyone found solution by themselves but don't tell how. One question has an answer:
the issue were VM parameters I added in the build.xml in the
fx:platform / fx:jvmarg section. These params were put into the
package.cfg file which is called from the .exe file to initialize the
VM.
In my build.xml there is only one string related to the named fx:platform But in my case there is only <fx:platform basedir="${java.home}"/> and nothing else. What am I doing wrong?
I have developed an executor (jar file) for my automation framework, this executor connects to a remote machine and executes my script written in eclipse and gets the results back to my local machine. Right now I have to mention the name of file and it's path before I trigger the executor in eclipse using Ctrl+F11
Modification:
I want it to run the script which is open in eclipse when I run my executor using Ctrl+F11, e.g. I open myscript.txt in eclipse and hit run and it should execute myscript.txt.
For this I would need the name of file which is currently open in eclipse.
NOTE:
I have not developed a plugin it is just a simple core Java code.
I have tried the below code:
if(PlatformUI.isWorkbenchRunning()) {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
String name = activePage.getActiveEditor().getEditorInput().getName();
System.out.println(name);
}
else
System.out.println("Work Bench Does not exist");
But it always returns me that Work Bench does not exist.
I am new to it, please let me know if something does not make sense here.
-Thanks in advance
When you run an application via a run configuration Eclipse starts an own javaw process for that. Therefore you cannot access the environment of Eclipse from inside that process in the way you tried.
There might be a simpler solution to your problem:
Make your application expect the opened file to be passed as commandline argument to its main method.
Enter ${resource_loc} in the "program arguments" section of the run configuration. ${resource_loc} translates into the absolute file system path of the selected resource.
I have a project where I am using a start.HTML page to invoke javascript call which inturn calls a java servlet Enquiry.java and this calls a php file myPhp.php. This php file scrapes data from a famous music site and sends data back to Enquiry.java as an XML(file or string, my choice).
So, I have to have this xml data on php page making myPhp.php act like a xml file, which my servlet uses to extract data from.
Now, I have to compile and run my java servlet on putty and run html on browser and do the rest.
I am able to compile my file perfectly.
I have set CLASSPATH to ~/tomcat/jakarta/common/lib where all jars are placed.
I do >javac -classpath $CLASSPATH/servlet.jar:$CLASSPATH/json-rpc-1.0.jar Enquiry.java
Compiled fine.
Now, I must be having a Enquiry.class somewhere (I think in my classpath)
I stop tomcat. Transfer this class file to where my .java file is. Start tomcat.
Now, I need to run it.
I do java -classpath $CLASSPATH/servlet.jar:$CLASSPATH/json-rpc-1.0.jar Enquiry
I get: Error in "main" thread, NoClassDefFound : Enquiry
I have both in current folder only. I still get a exception
I want to know what is wrong?
If I add a . before Enquiry, I get: Error in "main" thread, NoClassDefFound : javax.servlet.http.httpresponse exception
If I add a java -cp .:$CLASSPATH... then i get: Error in "main" thread, NoClassDefFound : Main exception
Please help me to resolve my classpath and run my java servlet cleanly.
When creating a servlet, you usually (if not always) create it as a part of a web application packaged as a WAR file. To run your servlet, you take the packaged WAR file and put it in the deployment folder of the servlet container you're using. Since you aparently are using Tomcat, this would probably be in the tomcat/webapps folder. This tutorial is a good place to start to learn about developing and deploying web applications. The only Java process you should have to start is your servlet container.