Can I invoking java web start in program? - java

I want to make use of the java web start advantage,but I dont want our customer face the java web start loading Screen,it seems ugly...and also customer maybe not install jre and the jre-install maybe fussy to them..so I want to package our application and jre into setup file using installanywhere. when user start our program,I want to invoking web start API to do the work like version compare,and offer outself loading screen ..
so,Can I invoking web start in my program?and how?
Best regards
L.J.W

I don't think web start is the way you want to go here. You can't change the loading screen, and if you want to access the user's computer in any way you'll have to bother the user with a confirmation, and risk them freaking out and canceling. Just roll your own auto-update; it's definitely not worth using web start just for that.

For the loading screen question:
<jnlp ...>
<information>
<icon kind="splash" href="splash.gif" />
...
</information>
...
</jnlp>

If you're installing your application locally on the user's machine, why would you need to call JWS?

Related

How to remove deployed webapp in embedded Tomcat?

I'm using apache-tomcat-8.5.4-embed to load web application at runtime.
I have a requirement to stop web application when user requested to stop.
Is it possible to do, if yes please let me know the procedure!
Uday , something worth a try are API's that are available (more specifically for ANT) in tomcat
https://tomcat.apache.org/tomcat-8.5-doc/api/org/apache/catalina/ant/StopTask.html
I have not tested the code below , but it is something you could try.
StopTask stopTask= new StopTask();
stopTask.setUsername("admin");
stopTask.setPassword("mypass");
stopTask.setUrl("http://server:port/manager";);
stopTask.setPath("/my-webapp-context");
stopTask.execute();

How to know if my application is running over a JBoss server?

I am developing a GWT application.
And I would like to know if I am running over a Jboss instance or over a Jetty instance.
This is because if I am running over Jetty it means that I am running the dev mode and I need to redirect to MyModule.html?codeserver... but if I am running over Jboss I need to redirect to MyModule.html
But I can't figure how can I know if I am running over Jetty or over Jboss.
You should not try to find out the webserver on which your application is running, in your application code. Instead you can have a discriminating parameter set in the context of your application with different values for different servers.
E.g.
For JBoss, the server.xml can contain a parameter in the context definition as follows:
<Context ...>
...
<Parameter name="applicationStage" value="prod" />
...
</Context>
and for Jetty, the same context parameter would go into its jetty.xml but the value as "devo".
If you just want to know wether you are running production or development mode, then try
GWT.isProdMode();
Only works client-side of course.
There's not really any simple way to determine what application server you're running on (to my knowledge). You could check some system properties to determine this.
JBoss:
jboss.server.name
Jetty:
jetty.home
Although I do not encourage having logic determined by your environment as Vikdor mentions in his answer. His suggestion would be a better approach.
In a JSP,
Server is <%= application.getServerInfo()%>
or use
Server is ${pageContext.servletContext.serverInfo}
in a Servlet,
String server = getServletContext().getServerInfo();

JNLP file: not to create desktop shortcut

In our webstart JNLP file, I have removed the shortcut and desktop tag, but when installing the webstart app, it still prompts me if I want to create a desktop shortcut.
So in the information tag it looks like this:
<information>
<title>Dynamic Tree Demo</title>
<vendor>Dynamic Team</vendor>
<icon href="sometree-icon.jpg"/>
</information>
Is there any way to do this?
Your best bet is to add query params to the href e.g. if the current value is the.jnlp, make it the.jnlp?a=b. The JWS client will presume it is generated dynamically and will generally not create a desktop shortcut.
I say 'generally' since it is really up to the JWS client & how it is configured.

Client.Error.MessageSend problem with Flex/BlazeDS on JBoss

I'm developing a Flex 3.4 app that interops with a Java EE backend running on a JBoss-4.2.2 server, through the most recent release of BlazeDS. When I ran the Flex app from Flash Builder 4 beta 2 on Tomcat, everything was fine, the Flex app was able to make the remote call needed. But my production environment is on JBoss, and when I moved the app to JBoss (with services-config.xml updated to fit JBoss), the Flex app keeps complaining Client.Error.MessageSend upon remote calls.
At first, when I manually deployed the app to JBoss, the faultDetail was "Channel.Security.Error error Error #2048 ... "; later I tried to run the app from Flash Builder, and then faultDetail became "Channel.Connect.Failed error NetConnection.Call.BadVersion".
In services-config.xml, under <security>, was:
<login-command class="flex.messaging.security.TomcatLoginCommand" server="Tomcat"/>
when moving to JBoss, I updated it to:
<login-command class="flex.messaging.security.TomcatLoginCommand" server="JBoss"/>
I have a crossdomain.xml placed in JBoss' deploy folder, as follows:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy
SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>
But looks like it doesn't work. I've also tried to put crossdomain.xml in deploy/xxxxx.war folder, and the problem remains.
I'm using http://, not https://, so I guess it's not about security channel.
Tried to search for a solution, but most solutions were PHP related, which wasn't really helpful. Any one got any clues?
You have
<login-command class="**flex.messaging.security.TomcatLoginCommand**" server="Tomcat"/>
Where the class indicates that security is of tomcat you should change it to a class that implements the interface flex.messaging.security.LoginCommand or any security interface blaze.
If you browse to http://your.application.root/crossdomain.xml, does the file load? The simplest configuration is to put the file at the root of the domain.

Start / stop a web application from itself?

I've made a web application using Java, Struts and running over Apache Server and Tomcat. It would be very useful to be able to restart the application from the web. I don't want to restart Tomcat, only this webapp, the same way as Tomcat Manager does it.
Do you know how can I do it? If not, any way to simulate that behaviour (reload config.properties, make Hibernate init process, etc)?
Thank you a lot.
I took a quick look at the source code for the Tomcat Manager. It looks like there's a class that's part of the Tomcat source called "Container Servlet". From the javadocs:
A ContainerServlet is a servlet
that has access to Catalina internal
functionality, and is loaded from the
Catalina class loader instead of the
web application class loader.
A ContainerServlet automatically gets passed a wrapper that can be used to get the Context and Deployer -- and the Deployer has helpful methods such as start(String contextPath) and stop(String contextPath) that will do what you want.
So, what I think you would need to do is write your own servlet that inherits from ContainerServlet, and configure Tomcat to load your servlet using the Catalina class loader (look at how the Manager is configured to see how). Note that this is probably not going to be an option for you in a hosted environment.
Then your servlet could have, say, a button you press to reload the application. I recommend putting password-protection of some kind in front of that. :)
Just hit the URLs
http://<username>:<password>#<hostname>:<port>/manager/stop?path=/<context path>
to stop and
http://<username>:<password>#<hostname>:<port>/manager/start?path=/<context path>
to start. That simulates you using the manager application.
Tomcat Manager offers an http interface to start/stop an application and other tasks. There are Ant tasks that you can use to easily access these operations.

Categories