How to Allocate a Private IP address and Port with Ghostdriver - ip

I wrote a Ghostdriver Maven Java project where I call many instances of the jar file using a shell script in Ubuntu 14.04 64bit.
Each line in my shell script calls a new instance of my jar file.
The format of each line:
screen -dmS name java -jar /path/name.jar arg1 arg2 arg3
Currently I have 1 network interface (eth0) split up into multiple network aliases (eth0:1, eth0:2, etc), each alias points to a private IP which in turns points to a public IP.
I am trying to find the best way to allocate a private IP and possibly port number to each instance of my java program. Currently I call Ghostdriver inside my program.
The way I call ghost driver within my program:
public class className {
PhantomJSDriver driver;
public static final File PHANTOMJS_EXE = new File("//home/username/phantomjs/bin/phantomjs");
public className() {
callGhostdriver();
driver.quit();
}
private void callGhostdriver() {
{
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability("phantomjs.binary.path",
PHANTOMJS_EXE.getAbsolutePath());
driver = new PhantomJSDriver(caps);
driver.manage().window().maximize();
actions = new Actions(driver);
}
}
}
Any help would be greatly appreciated.
***Update****
I tried changing the callGhostdriver method but had no success.
private void callGhostdriver() {
DesiredCapabilities dcaps = new DesiredCapabilities();
dcaps.setCapability(
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
PHANTOMJS_EXE.getAbsolutePath());
String[] phantomJsArgs = {"--webdriver=172.16.190.131:6781"};
dcaps.setCapability(
PhantomJSDriverService.PHANTOMJS_CLI_ARGS,
phantomJsArgs);
driver = new PhantomJSDriver(dcaps);
driver.manage().window().maximize();
actions = new Actions(driver);
}
Argument --webdriver=IP:PORT seems to be overridden by a default
--webdriver call.
Output from running jar:
*Apr 12, 2015 5:26:25 PM org.openqa.selenium.phantomjs.PhantomJSDriverService INFO: port: 8651
Apr 12, 2015 5:26:25 PM
org.openqa.selenium.phantomjs.PhantomJSDriverService INFO: arguments:
[--webdriver=172.16.190.131:6781, --webdriver=8651,
--webdriver-logfile=/home/RemovedPath/phantomjsdriver.log] Apr 12, 2015 5:26:25 PM org.openqa.selenium.phantomjs.PhantomJSDriverService
INFO: environment: {} [INFO - 2015-04-12T21:26:26.584Z] GhostDriver -
Main - running on port 8651
Port 6781 with the different private IP should be what it is using but it uses 8651 instead.

I was able to find a hackish way to set the port but still haven't figured out how to set the private ip, I may have to use iptables to route the traffic.
private void loadLightWeightDriverCustom() {
ArrayList<String> cliArgsCap = new ArrayList();
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, PHANTOMJS_EXE.getAbsolutePath());
cliArgsCap.add("--web-security=false");
cliArgsCap.add("--ssl-protocol=any");
cliArgsCap.add("--ignore-ssl-errors=true");
capabilities.setCapability(
PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgsCap);
driver = new PhantomJSDriver(Configure(cliArgsCap), capabilities);
}
private PhantomJSDriverService Configure(ArrayList<String> cap) {
return new PhantomJSDriverService.Builder().usingPhantomJSExecutable(PHANTOMJS_EXE)
.usingPort(5555)
.usingCommandLineArguments(
(cap.toArray(new String[cap.size()])))
.build();
}

Try this -->
List<String> cliArgsCap = Arrays.asList(
"--webdriver=172.16.190.131:6781");
dcaps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgsCap);

I was able to find a fix to the --webdriver command, https://github.com/detro/ghostdriver/pull/438, I compiled that jar and loaded it in. Now I am getting
Apr 24, 2015 10:35:04 AM org.openqa.selenium.phantomjs.PhantomJSDriverService
INFO: executable: C:*Removed Path\phantomjs-2.0.0-windows\bin\phantomjs.exe
Apr 24, 2015 10:35:04 AM org.openqa.selenium.phantomjs.PhantomJSDriverService
INFO: port: 41533
Apr 24, 2015 10:35:04 AM org.openqa.selenium.phantomjs.PhantomJSDriverService
INFO: arguments: [--webdriver=127.0.0.1:6666, --webdriver-logfile=C:\Removed Path*\phantomjsdriver.log]
Apr 24, 2015 10:35:04 AM org.openqa.selenium.phantomjs.PhantomJSDriverService
INFO: environment: {}
[INFO - 2015-04-24T14:35:06.222Z] GhostDriver - Main - running on port 6666
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.45.0', revision: '5017cb8e7ca8e37638dc3091b2440b90a1d8686f', time: '2015-02-27 09:10:26'
System info: host: 'MBC5708', ip: '167.74.185.13', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_45'
Driver info: driver.version: PhantomJSDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:593)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:139)
My method invoking phantomjs is:
ArrayList<String> cliArgsCap = new ArrayList<String>();
DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
cliArgsCap.add("--webdriver=6666");
capabilities.setCapability(
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,PHANTOMJS_EXE.getAbsolutePath());
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgsCap);
driver = new PhantomJSDriver(capabilities);

Related

Java EE 7 and Wildfly 10.1.0 - IllegalStateException: EJBCLIENT000025

I created following EJB-Module:
1) My Remote interface
package calculator.beans;
import javax.ejb.Remote;
#Remote
public interface CalculatorRemote {
public int addNum(int num1, int num2);
}
2) A bean which implements the interface
package calculator.beans;
import javax.ejb.Stateless;
#Stateless
public class CalculatorBean implements CalculatorRemote {
#Override
public int addNum(int num1, int num2) {
return num1 + num2;
}
}
3) Next I created a property-file 'jboss-ejb-client.properties'
endpoint.name=client-endpoint
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=127.0.0.1
remote.connection.default.port = 8080
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.default.username=appuser
remote.connection.default.password=apppassword
After the deployment to wildfly everything was fine. I get following Information:
INFO [org.jboss.as.ejb3.deployment] (MSC service thread 1-4) WFLYEJB0473: JNDI bindings for session bean named 'CalculatorBean' in deployment unit 'deployment "CalculatorEJB.jar"' are as follows:
java:global/CalculatorEJB/CalculatorBean!calculator.beans.CalculatorRemote
java:app/CalculatorEJB/CalculatorBean!calculator.beans.CalculatorRemote
java:module/CalculatorBean!calculator.beans.CalculatorRemote
java:jboss/exported/CalculatorEJB/CalculatorBean!calculator.beans.CalculatorRemote
java:global/CalculatorEJB/CalculatorBean
java:app/CalculatorEJB/CalculatorBean
java:module/CalculatorBean
4) Then I created my Java Client
package calculator.client;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import calculator.beans.CalculatorRemote;
public class RemoteRechnerClient {
public static void main(String[] args) {
try {
final Hashtable<String, String> jndiProperties = new Hashtable<>();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
final Context ctx = new InitialContext(jndiProperties);
String crName = CalculatorRemote.class.getName();
CalculatorRemote cr = (CalculatorRemote) ctx.lookup("ejb:CalculatorEJB/beans/CalculatorBean!" + crName);
System.out.println("Result: " + cr.addNum(5, 4));
} catch (NamingException ex) {
ex.printStackTrace();
}
}
}
The code is simple enough. But if I run the Client I get following Error-Message:
Apr 06, 2017 3:30:26 PM org.jboss.ejb.client.EJBClient <clinit>
INFO: JBoss EJB Client version 2.0.1.Final
Apr 06, 2017 3:30:26 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.0.Final
Apr 06, 2017 3:30:26 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.0.Final
Apr 06, 2017 3:30:26 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 4.0.6.Final
Apr 06, 2017 3:30:27 PM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: EJBCLIENT000017: Received server version 2 and marshalling strategies [river]
Apr 06, 2017 3:30:27 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext#3c0f93f1, receiver=Remoting connection EJB receiver [connection=org.jboss.ejb.client.remoting.ConnectionPool$PooledConnection#31dc339b,channel=jboss.ejb,nodename=john-waynes-macbook-pro]} on channel Channel ID b98547a5 (outbound) of Remoting connection 0c84e8ba to /127.0.0.1:8080
Exception in thread "main" java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:CalculatorEJB, moduleName:beans, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext#2758fe70
at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:749)
at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:116)
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:186)
at org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:253)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:198)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:181)
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:144)
at com.sun.proxy.$Proxy0.addNum(Unknown Source)
at calculator.client.RemoteRechnerClient.main(RemoteRechnerClient.java:27)
/Users/manhthangd/Library/Caches/NetBeans/8.2/executor-snippets/run.xml:53: Java returned: 1
BUILD FAILED (total time: 3 seconds)
I am using Netbeans 8.2, Java EE 7 and Wildfly 10.1.0-Final.
What can I do to solve the problem?
Your JNDI lookup name is incorrect.
You need to use the highlighted portion of:
java:jboss/exported/CalculatorEJB/CalculatorBean!calculator.beans.CalculatorRemote
ie.
CalculatorRemote cr = (CalculatorRemote) ctx.lookup("ejb:CalculatorEJB/CalculatorBean!" + crName);
Where did you get "ejb:CalculatorEJB/beans/CalculatorBean!" from?

WebSocketServlet in a WAR-file: Bad character 13 for SelectChannelEndPoint

On Mac with Oracle java "1.8.0_45" I have create a Jetty base dir with:
# java -jar /Users/afarber/jetty-distribution-9.3.10.v20160621/start.jar jetty.home=/Users/afarber/jetty-distribution-9.3.10.v20160621 jetty.base=/Users/afarber/jetty-base --add-to-startd=http,servlet,webapp,resources,ext,fcgi,websocket,proxy-protocol,deploy
INFO: ext initialised in ${jetty.base}/start.d/ext.ini
INFO: resources initialised in ${jetty.base}/start.d/resources.ini
INFO: server initialised (transitively) in ${jetty.base}/start.d/server.ini
INFO: http initialised in ${jetty.base}/start.d/http.ini
INFO: servlet initialised in ${jetty.base}/start.d/servlet.ini
INFO: fcgi initialised in ${jetty.base}/start.d/fcgi.ini
INFO: proxy-protocol initialised in ${jetty.base}/start.d/proxy-protocol.ini
INFO: webapp initialised in ${jetty.base}/start.d/webapp.ini
INFO: websocket initialised in ${jetty.base}/start.d/websocket.ini
MKDIR: ${jetty.base}/lib
MKDIR: ${jetty.base}/lib/ext
MKDIR: ${jetty.base}/resources
MKDIR: ${jetty.base}/webapps
INFO: Base directory was modified
Then I have put $JETTY_BASE/webapps/ws-servlet-0.1-SNAPSHOT.war produced by the very simple Maven project out of -
WsServlet.java
public class WsServlet extends WebSocketServlet
{
#Override
public void configure(WebSocketServletFactory factory) {
factory.register(EchoListener.class);
}
}
EchoListener.java
public class EchoListener implements WebSocketListener {
private static final Logger LOG = Log.getLogger(EchoListener.class);
private Session mSession;
#Override
public void onWebSocketConnect(Session session) {
LOG.info("onWebSocketConnect {}", session);
mSession = session;
}
#Override
public void onWebSocketText(String message) {
LOG.info("onWebSocketText {}", message);
if (mSession != null && mSession.isOpen()) {
mSession.getRemote().sendString("ECHO: " + message, null);
}
}
}
Finally I have created the $JETTY_BASE/webapps/ws.xml file pointing to the WAR-file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
"http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/ws</Set>
<Set name="war"><SystemProperty name="jetty.base"/>/webapps/ws-servlet-0.1-SNAPSHOT.war</Set>
</Configure>
When I start Jetty and then connect to it using simple JavaScript code in browser var ws = new WebSocket("//127.0.0.1:8080/ws"); or the Simple Web Socket Client extension for Chrome the error comes:
# java -Dorg.eclipse.jetty.LEVEL=DEBUG -jar /Users/afarber/jetty-distribution-9.3.10.v20160621/start.jar jetty.base=/Users/afarber/jetty-base
....
WARN:oejs.ProxyConnectionFactory:qtp1993134103-12: Bad character 13 for SelectChannelEndPoint#26ba5622{/127.0.0.1:49883<->8080,Open,in,out,-,-,0/30000,ProxyConnection#49376d8e}{io=1/0,kio=1,kro=1}
Here is the full Jetty log, what have I missed here please?
UPDATE:
I have also tried connecting to ws://127.0.0.1:8080/ws-servlet-0.1-SNAPSHOT and tried adding annotations like #WebServlet(name = "WsServlet", urlPatterns = { "/ws" })- but that does not help. Also I have tried the older version 9.3.9.v20160517.
UPDATE 2:
Is the root cause the PROXY Protocol, which I have to use at my production server, because I offload SSL and normal connections to HAProxy? From the doc I read that 13 is sent as the first byte.
UPDATE 3:
The problem has been solved by adding a trailing slash: ws://127.0.0.1:8080/ws/

Run Rscript from Spring MVC with Wildfly 9

I am trying to run Rscript from JAVA code. I am able to do so. Now I am trying to run same JAVA code from a Spring MVC project and using Wildfly 9 to run the project. For the first time when I am trying to execute JAVA code (to run Rscript) is working fine and giving correct result, but on running 2nd time it is giving error and Wildfly stops running. Below is the error that I am getting:
A fatal error has been detected by the Java Runtime Environment:
Internal Error (0xc0000029), pid=6768, tid=8456
JRE version: Java(TM) SE Runtime Environment (7.0_75-b13) (build 1.7.0_75-b13)
Java VM: Java HotSpot(TM) Client VM (24.75-b04 mixed mode, sharing windows-x86 )
Problematic frame:
C [ntdll.dll+0xa096a]
Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
The JAVA code is below:
package com.test.util;
import org.rosuda.JRI.Rengine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class RunRScript {
private static final Logger logger = LoggerFactory
.getLogger(RunRScript.class);
public void runScript() {
// Create an R vector in the form of a string.
String javaVector = "c(1,2,3,4,5)";
// Start Rengine.
Rengine engine = new Rengine(new String[] { "--no-save" }, false, null);
// The vector that was created in JAVA context is stored in 'rVector' which is a variable in R context.
engine.eval("rVector=" + javaVector);
//Calculate MEAN of vector using R syntax.
engine.eval("meanVal=mean(rVector)");
//Retrieve MEAN value
double mean = engine.eval("meanVal").asDouble();
//Print output values
logger.info("Mean of given vector is=" + mean);
}
}
I am using Windows 8 64-bit and R-2.15.0. Please let me know if my question is not clear or you need any other information. Thanks in advance.
You can't call JRI engine with that code. According to the documentation, JRI doesn't allow more that one engine instance per JVM, so you shouldn't create more than one engine.
This line:
// Start Rengine.
Rengine engine = new Rengine(new String[] { "--no-save" }, false, null);
Must be called only once. You have to ensure that only one engine is started in your JVM.
On the other hand, JRI uses by default the same environment to handle all the calls (eval, assign, etc...) so the rest of your code must be synchronized, otherwise you can suffer race conditions every time two different threads are executing eval methods.
If you have trouble getting it working, you can replace JRI by Rserve, that doesn't need JRI library loaded into the JVM and allow concurrency (each thread must use its own RConnection).
But with Rserve you should setup your engine only once, as well as using JRI.
You can use a #PostConstruct method:
/**
* This method initializes REngine properly and make all the operations needed
* to set up the environment.
*
* This RServe implementation must run R in a separate process and check the connection.
*
*/
#PostConstruct
public void setUpR() {//NOSONAR
REngine engine = null;
try {
if(LOGGER.isInfoEnabled()) {
LOGGER.info("Starting RServe process...");
}
ProcessBuilder builder = new ProcessBuilder("/bin/sh", "-c", String.format("echo 'library(Rserve);Rserve(FALSE,args=\"--no-save --slave --RS-conf %s\")'|%s --no-save --slave", rserveConf, rexe));
builder.inheritIO();
Process rProcess = builder.start();
if(LOGGER.isInfoEnabled()) {
LOGGER.info("Waiting for Rserve to start...");
}
int execCodeResult = rProcess.waitFor();
if(execCodeResult != SUCCESS_CODE) {
LOGGER.error(String.format("Unexpected error code starting RServe: %d", execCodeResult));
} else {
LOGGER.error("RServe started successfully");
}
if(LOGGER.isInfoEnabled()) {
LOGGER.info("Opening connection to RServe daemon....");
}
engine = new RConnection();
if(LOGGER.isInfoEnabled()) {
LOGGER.info(String.format("Obtaining R server version: %d", ((RConnection)engine).getServerVersion()));
}
} catch(Exception e) {
LOGGER.error("Unexpected error setting up RServe environment", e);
} finally {
closeRServeConnection(engine);
}
}
You can do the same with JRI:
/**
* This method initializes REngine properly and make all the operations needed
* to set up the environment.
*
* This JRI implementation must load JRI library and starts JRIEngine
*
*/
#PostConstruct
public void setUpR() {//NOSONAR
try {
//make sure JRI lib can be loaded (it must be present in java.library.path parameter)
//This line is necessary because Rengine.versionCheck() will execute a System.exit if
//it can't load JRI library.
System.loadLibrary("jri");
// just making sure we have the right version of everything
if (!Rengine.versionCheck()) {
LOGGER.error("** Version mismatch - Java files don't match library version.");
LOGGER.error(String.format("Invalid versions. Rengine must have the same version of native library. Rengine version: %d. RNI library version: %d", Rengine.getVersion(), Rengine.rniGetVersion()));
}
// Enables debug traces
Rengine.DEBUG = 1;
if(LOGGER.isInfoEnabled()) {
LOGGER.info("Creating Rengine (with arguments)");
}
// 1) we pass the arguments from the command line
// 2) we won't use the main loop at first, we'll start it later
// (that's the "false" as second argument)
// 3) no callback class will be used
this.engine = REngine.engineForClass("org.rosuda.REngine.JRI.JRIEngine", new String[] { "--no-save" }, new REngineStdOutCallback(LOGGER), false);
if(LOGGER.isInfoEnabled()) {
LOGGER.info("Rengine created...");
LOGGER.info("Loading blockFunction from " + getBlockFunction());
}
REXP result = engine.parseAndEval(getBlockFunction());
if(result == null) {
LOGGER.error("blockFunction is not loaded!");
} else if(LOGGER.isInfoEnabled()) {
LOGGER.info("blockFunction loaded successfully");
}
} catch(Exception|UnsatisfiedLinkError e) {
LOGGER.error("Unexpected error setting up R", e);
}
}
And then reuse the same Rengine instance in each call (make sure you synchronize the access to this instance).
You have more examples in this repo

Spring MVC Java Configuration

Hi I am trying to use Spring MVC Java config and Content View resolver.
Files:-
public class WebInitializer implements WebApplicationInitializer {
/*
* (non-Javadoc)
*
* #see
* org.springframework.web.WebApplicationInitializer#onStartup(javax.servlet
* .ServletContext)
*/
#Override
public void onStartup(ServletContext servletContext)
throws ServletException {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.register(SpringMvcConfig.class);
ctx.setServletContext(servletContext);
ctx.refresh();
Dynamic servlet = servletContext.addServlet("dispatcher",
new DispatcherServlet(ctx));
servlet.addMapping("/");
servlet.setLoadOnStartup(1);
servlet.setAsyncSupported(false);
}
}
#Configuration
#EnableWebMvc
#ComponentScan(basePackages = { "com.sambhav.mvc.controller" })
public class SpringMvcConfig extends WebMvcConfigurerAdapter {
/*
* #Bean public UrlBasedViewResolver setupViewResolver() {
* UrlBasedViewResolver resolver = new UrlBasedViewResolver();
* resolver.setPrefix("/WEB-INF/jsp/"); resolver.setSuffix(".jsp");
* resolver.setViewClass(TilesView.class); return resolver; }
*/
#Bean
public TilesViewResolver getTilesViewResolver() {
TilesViewResolver tilesViewResolver = new TilesViewResolver();
/*
* tilesViewResolver.setPrefix("/WEB-INF/jsp/");
* tilesViewResolver.setSuffix(".jsp");
*/
tilesViewResolver.setViewClass(TilesView.class);
return tilesViewResolver;
}
#Bean
public TilesConfigurer getTilesConfigurer() {
TilesConfigurer tilesConfigurer = new TilesConfigurer();
tilesConfigurer.setCheckRefresh(true);
tilesConfigurer.setDefinitions(new String[] { "/WEB-INF/tiles.xml" });
return tilesConfigurer;
}
#Override
public void configureContentNegotiation(
ContentNegotiationConfigurer configurer) {
configurer.defaultContentType(MediaType.TEXT_HTML)
.mediaType("json", MediaType.APPLICATION_JSON)
.mediaType("xml", MediaType.APPLICATION_XML)
.favorPathExtension(true); // default is true. just for clarity
}
#Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/css/*").addResourceLocations(
"/WEB-INF/css/*");
registry.addResourceHandler("/js/*").addResourceLocations(
"/WEB-INF/js/*");
registry.addResourceHandler("/img/*").addResourceLocations(
"/WEB-INF/img/*");
}
}
When trying to run the app, I don't the dispatcher servlet getting registered - no related info logs appear. Running in debug mode with break point in WebInitializer also indicates that its not getting called.
Jul 12, 2013 5:06:57 PM com.springsource.tcserver.serviceability.rmi.JmxSocketListener init
INFO: Started up JMX registry on 127.0.0.1:6969 in 68 ms
Jul 12, 2013 5:06:57 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 573 ms
Jul 12, 2013 5:06:57 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 12, 2013 5:06:57 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: VMware vFabric tc Runtime 2.8.2.RELEASE/7.0.35.B.RELEASE
Jul 12, 2013 5:06:57 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor D:\Installations\sts3.2\vfabric-tc-server-developer-2.8.2.RELEASE\base-instance\conf\Catalina\localhost\spring-mvc-config.xml
Jul 12, 2013 5:06:57 PM org.apache.catalina.startup.SetContextPropertiesRule begin
WARNING: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:spring-mvc-config' did not find a matching property.
Jul 12, 2013 5:06:57 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Installations\sts3.2\vfabric-tc-server-developer-2.8.2.RELEASE\base-instance\webapps\manager
Jul 12, 2013 5:06:57 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Installations\sts3.2\vfabric-tc-server-developer-2.8.2.RELEASE\base-instance\webapps\ROOT
Jul 12, 2013 5:06:57 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jul 12, 2013 5:06:57 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 311 ms
This results in 404 at / or any other path.
I am wondering what went wrong here.
Thanks for your help.
I know its old question. With newer Spring Boot, it is now far easier to configure any Spring application. Refer Spring Boot starter project here :-
Spring Boot Blog
Possible reasons:
web.xml. I advice you to delete it at all and use servlet-api with version higher than 3.0.
Incorrect #RequestMapping in controllers. Show them, please.
And finally, here you can find good step-by-step guide for base Spring MVC app with java configuration:
http://www.javacodegeeks.com/2013/03/spring-mvc-creation-of-a-simple-controller-with-java-based-config.html

WebDAV library that supports Kerberos?

I want to programmatically read the files of a Kerberos-protected WebDAV server.
I tried adding Kerberos support to Sardine (Java), but it does not seem to work well.
Is there a WebDAV library that supports Kerberos? (any language, preferably open source)
The solution I found to work is using the Sardine method classes that extend HttpRequestBase with Apache HttpClient. You will need to use both the httpclient and httpclient-win
try {
CloseableHttpClient client = WinHttpClients.createDefault();
HttpMove move = new HttpMove(fullSource, fullDestination, false);
CloseableHttpResponse response = client.execute(move);
if (response.getStatusLine().getStatusCode() == 201){
System.out.println("Yay");
}
} catch (Exception e) {
e.printStackTrace();
}
throw new Exception("Unable to move node");
Here are the dependencies used (gradle form)
compile group: 'com.github.lookfirst', name: 'sardine', version:
'5.+'
compile group: 'org.apache.httpcomponents', name: 'httpclient',
version: '4.5.+'
compile group: 'org.apache.httpcomponents', name: 'httpclient-win',
version: '4.5.+'
The transport library need Kerberos support not your WebDAV lib. Try to fix that transport lib. Oracle's URLConnection does that.

Resources