I want to use a python backend while developing a SmartGWT front end. In order to get the debugging working correctly, I think I need the dev server running in eclipse which means the webserver will be running in eclipse.
My python (Django) backend needs to serve the requests for the data and I'd like it to not be a cross-domain issue, however cross-domain also seems to require the ports match too.
What is the simplest way to work around this? Been thinking about setting up my hosts file with a bogus domain and then have two entries, one for data, one for js. But, this requires setting up a second IP on the machine because the ports have to match too.
If I want anyone else to be able to see the pages I can't use localhost and my external IP since they won't be able to get to my localhost.
Is there some simpler setup?
Is there some simple proxy piece I could drop into the eclipse dev server that would proxy the data requests to a different server?
Other ideas?
I am using a proxy servlet in my gwt setup for this purpose.
I am using a tomcat proxy servlet from jetty util artifact:
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>6.1.22</version>
<scope>runtime</scope>
</dependency>
My web.xml looks like this:
<servlet>
<servlet-name>JettyProxy</servlet-name>
<servlet-class>org.mortbay.servlet.ProxyServlet$Transparent</servlet-class>
<init-param>
<param-name>ProxyTo</param-name>
<param-value>http://yourserver</param-value>
</init-param>
<init-param>
<param-name>Prefix</param-name>
<!-- will be removed from request -->
<param-value>/prefix/</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JettyProxy</servlet-name>
<url-pattern>/prefix/*</url-pattern>
</servlet-mapping>
If you get some weired error about some _context variable, make sure that the jetty-util.jar is in your classpath before the GWT SDK.
Use -noserver for the DevMode. See http://code.google.com/webtoolkit/doc/latest/DevGuideCompilingAndDebugging.html#How_do_I_use_my_own_server_in_development_mode_instead_of_GWT's
The easiest way to do it is if you have both backend and frontend on your development machine.
For my projects I am using GWT on the frontend and cherrypy (python) on the backend.
I set up both projects in eclipse and when developing I start a debugger for the cherrypy backend and one for the GWT frontend. So I can basically debug backend and frontend at the same time. Works really good.
Communication between python backend and gwt frontend is done via RequestBuilder (JSON) and the good thing about this setup is that I can test the backend's data communication directly without GWT.
So the development url is usually something like: http://localhost:8080/?gwt.codesvr=127.0.0.1:9997
Port 8080 is used by my cherrypy backend.
Related
I want to make my website pages password protected.I make the website using restful webservices in java using jersey.So can any one tell me how to protect my web pages using apache shiro.Any one have implemented example to securing a website using apache shiro if yes than plz share the example.I shall be thankful :)
For protecting your webservices using shiro you can use following template files and can customize with your own requirements. Include the jars or add to pom as required.
Add these to web.xml
<filter>
<filter-name>Shiro</filter-name>
<filter-class>
org.apache.shiro.web.servlet.IniShiroFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>Shiro</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Now for shiro.ini to be place in WEB-INF (I am using basic Authentication with username and roles in shiro.ini which you can use from database etc as per your need, Assuming that /rest is the url for jersey rest services)
[main]
[urls]
/rest/** = noSessionCreation,authcBasic
/**= anon
[users]
admin=admin
I have debugged Java codes as JAVA APPLICATION.(its simple)
Now I am working with Maven project, and I am Keen to know comprehensive flow of this MAVEN+SPRING-JERSEY Project.
I guess debugging could help me with that, I have crawled many sites but cant really get how to debug a Maven Project.
Can anyone help me with this babyish doubt.
Or even you can explain me flow from this example.JERSEY+SPRING+MAVEN
Sorry ! I know This might be silly question,Let me know if I should delete it.
Please let me know if I am Correct:
WHAT I HAVE UNDERSTOOD:
1.Request comes from client,Web.xml Handles this request.
It finds the REST class(with URIs) in given Package.
(Also in meantime,Spring registers all Beans with help of Bean Registry)
2.Then from Service It gets URI , Now request is sent to particular URI.
3.At that URI we have beans,(i.e business logic) which gets executed
4.Then this beans send back result to REST and REST send this response message to client.
This is My understanding from #Michael Hoffman answer.
Please Let me know if this is correct.
Maven is simply providing you with build management. For most cases, it has no impact on how you will debug an application.
Based on your question, the best approach for debugging your application would be to use an IDE like Eclipse. You will need to have Tomcat, or a similar web container, in order to debug at runtime. Otherwise, the flow of code at design time is likely as follows:
At runtime, Spring loads any beans that are to be managed into the Spring container (application context). This may include the controller or service that is executed by the REST-ful call.
Web page or other integration makes a call to the rest service. The address depends on the configuration of the service across the web.xml and Spring application context.
A request flows through the configured servlet. Here is an example of servlet configuration in the web.xml of an app:
<web-app>
<servlet>
<servlet-name>MyApplication</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
...
</init-param>
</servlet>
...
<servlet-mapping>
<servlet-name>MyApplication</servlet-name>
<url-pattern>/myApp/*</url-pattern>
</servlet-mapping>
...
</web-app>
Based on the path requested, the request will flow to an implementing class, often times a controller or service class. The class or methods on the class will have annotation like: #Path("/helloWorld")
I have few questions about https in Scala Lift:
How can I set for my web application use only https protocol?
Must I rewrite some code for existing application for using https?
Is request response cycle changes or there is no any differents?
Where to find good scala lift open source project using https or just to see advanced use of framework?
Thanks.
HTTPS needs to be enabled in your servlet container, such as Jetty or Tomcat. It doesn't have much to do with your web application. Then you need to tell the servlet container to use HTTPS for some or all pages in the deployment descriptor. This is what your web.xml file will look like:
<web-app>
. . .
<security-constraint>
. . .
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
I wrote a small GWT app that includes a websocket servlet. I installed jetty-hightide 7.1.6 on my ubuntu 10.04 server and I cannot access the websocket servlet. However I can access it no problem when running on my local machine for testing. I didn't do any configuration to jetty I simply dropped the war file for the GWT app into the webapps folder and jetty deployed it.
I can access the app itself by going to the expected URL, but I just can't access the servlet via a URL.
the url I use locally is:
ws://127.0.0.1:8888/canvasbattleserver/battleCom
and on the production server:
ws://thelettercliff.com:8080/canvasbattleserver/battleCom
here is the configuration of the servlet in web.xml
<servlet>
<servlet-name>battleServlet</servlet-name>
<servlet-class>com.thelettercliff.project.server.BattleServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>battleServlet</servlet-name>
<url-pattern>/canvasbattleserver/battleCom</url-pattern>
</servlet-mapping>
Any ideas?
See if this works:
Edit this file: /etc/default/jetty
Look for a line that says
JETTY_HOST and change its value to 0.0.0.0
so it should read as:
JETTY_HOST=0.0.0.0
That will make jetty listen to connections on all interfaces.
When I deploy a JSF application on a Glassfish V2.1 Patch02 Cluster, the following exception is thrown while loading the first page.
java.security.ProviderException: update() failed
at sun.security.pkcs11.P11Cipher.implUpdate(P11Cipher.java:557)
at sun.security.pkcs11.P11Cipher.engineUpdate(P11Cipher.java:457)
at sun.security.pkcs11.P11Cipher.engineDoFinal(P11Cipher.java:485)
at sun.security.pkcs11.P11Cipher.engineDoFinal(P11Cipher.java:471)
at javax.crypto.Cipher.doFinal(DashoA13*..)
...
Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
at sun.security.pkcs11.wrapper.PKCS11.C_EncryptUpdate(Native Method)
at sun.security.pkcs11.P11Cipher.implUpdate(P11Cipher.java:510)
I am NOT using any kind of encryption/decryption inside my application.
When I googled up for this exception, I found this which is the case when Ciphers are loaded in the application.
I would like to know if Glassfish/JSF load default Ciphers which are causing this exception?
If not, what could be the possible cause and the solution for it?
The issue has been resolved. The problem is this 'minor' bug - https://issues.apache.org/jira/browse/MYFACES-1786
The solution is to put the following entries in the web.xml to disable encryption for state management and to switch the state saving to server
<context-param>
<param-name>org.apache.myfaces.USE_ENCRYPTION</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
From my experience the application when deployed with encryption enabled by 'default' (i.e. having no entry for org.apache.myfaces.USE_ENCRYPTION in web.xml) in Websphere(standalone or cluster) works perfectly okay.
But the application does NOT get deployed in Glassfish cluster or in Tomcat 6 (the problem is defined in the thread - nabble.com/BadPadding-Exception-and-more-td21984713.html)
The only place I can think where the base JSF implementation might use encryption is in state management. The component tree is stateful, so it is preserved between requests, either in the session or in a hidden form field (set by the javax.faces.STATE_SAVING_METHOD init parameter). If a hidden form field is used, the implementation would be wise to encrypt it to prevent hackers rewriting server state. (Note that state management in JSF is pluggable, so 3rd party libraries could replace the default behaviour. If you're using a rich component library, it's worth checking the doc.)
You could try deploying your app in non-clustered glassfish, or in tomcat and see if you get the same situation. Then you would know if the problem is your app or the configuration of the app server or cluster.