java

jaxb, get the original xml after unmarshalling

I've a simple little servlet, basically: void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { JAXBContext jaxb = myContext.getXMLContext().getSearchparamContext(); SearchParams params = null; try { Unmarshaller um = jaxb.createUnmarshaller(); um.setSch...

Tips for implementation of the spring-oauth RandomValueProviderTokenServices class.

I need to implement the oauth spring persistence for RandomValueProviderTokenServices class. The class that needs to be stored according to the abstract protected methods of the RandomValueProviderTokenServices is OAuthProviderTokenImpl. however, this class contains a reference to Authentication interface which has various implementation...

What is the .NET equivalent of Java's java.util.concurrent package?

I come from a Java background. I am wanting to learn more about concurrency in .Net and C#. Is there something similar to Java's concurrent utils package? ...

Spring best practice for locking domain objects?

Using EJB entity beans you can configure the bean so that when a thread has access to an EJB entity bean, no other threads can access the EJB bean. The container will block other threads until the thread with the lock is finished with the bean. Is there a "Spring way" to do this? Or do you have to just use the standard Java concurrenc...

Using request.getSession() as a locking object?

I have some java code that gets and sets a session attribute: Object obj = session.getAttribute(TEST_ATTR); if (obj==null) { obj = new MyObject(); session.setAttribute(obj); } In order to make this code thread-safe, I'd like to wrap it in a synchronized block. But what do I use as the locking object? Does it make sense to use th...

Hudson plugin problem

Hi. I've created almost the same plugin as JobTypeColumn. There is only one difference - it shows job description instead of job type. But after i can't add this column to my list view. I have an NullPointerException after i edited my config.xml manually. java.lang.NullPointerException at hudson.model.Descriptor.newInstancesFromHet...

How to get a reference to the Window object using GWTQuery?

The title pretty much says it all. I'm trying to use jQuery's ability (hoping GWTQuery has implemented it) to pass a callback function to the window.resize something like this(example from jquery site): $(window).resize(function(){ alert("Stop it!"); }); but when I tryi to type $(window) in Eclipse I get an error that window can not...

How to turn off the Eclipse code formatter for certain sections of Java code?

I've got some Java code with SQL statements written as Java strings (please no OR/M flamewars, the embedded SQL is what it is - not my decision). I've broken the SQL statements semantically into several concatenated strings over several lines of code for ease of maintenance. So instead of something like: String query = "SELECT FOO, BAR...

ArrayIndexOutOfBoundsException after Assert(i>=0)

Hey SO for (int i = TrueProbDie; i < 100; i++) { assert(i>=0); probs[i] = 1; } Im getting an ArrayIndexOutOfBoundsException on this code, due to i becoming negative, this I can solve by editing my other code, what getting me is that its ever making it to the probs[i] = 1; line as should throw an error on assert(i>=0); , if ...

Error 403: Forbidden. The HTTP request was forbidden with client authentication scheme 'Anonymous'.

I'm getting this error when calling a java web service. I'm using the same source as the rest of my team and they're all able to call it no problem? This is the stack trace: 30 Nov 2009 16:38:50,970 [4] ERROR - Error calling web service: System.ServiceModel.Security.MessageSecurityException: The HTTP request was forbidden with client au...

GWT + Object Persistence + Maintaining Data In Memory

Hi, I am currently carrying out research for the design and implementation of a web-based RSS aggregation system, with the aim being the use and evaluation of recommendation algorithms. This system will require a relatively interactive web-based UI (hence my interest in using GWT) and some form of data persistence to store RSS feed det...

Map Database timestamp column to UTC Calendar (JPA) and pass it as UTC date via WebService (jax-ws)

This sounds like a simple task. Get UTC timestamp value from DB and pass it as UTC date via Web Service. We have timestamp column DATE_COLUMN and store there time in UTC time zone. With JPA we get this time with @Column(name = "DATE_COLUMN") private java.sql.Timestamp dateValue; And as we have to pass this time via Web Service in U...

Help me understand JSF managed bean lifecycle

I have a form bean defined in session scope and a controller bean defined in request scope. I am using JSF to inject the session scoped bean in to the request scoped bean. <managed-bean> <managed-bean-name>Controller</managed-bean-name> <managed-bean-class> com.mycomp.Controller </managed-bean-class> <managed-bean-scope>request</mana...

Java AJAX webapp security

I'm experimenting with creating a simple AJAX Java webapp. I'd like to use the container managed security provided by the Servlet container, but having investigated it have a feeling that it isn't going to work how I'd like it to. Basically I'd like to be able to have a login prompt on the main page, without the user having to navigate...

Hamcrest's lessThan doesn't compile

Trying to compile this code import static org.hamcrest.Matchers.is; import static org.hamcrest.number.OrderingComparison.lessThan; ... Assert.assertThat(0, is(lessThan(1))); issues this compilation error: assertThat(Object, org.hamcrest.Matcher<java.lang.Object>) cannot be applied to (int, org.hamcrest.Matcher<capture<? su...

Tomcat not recognizing the DLL files

i've an application which am trying to deploy in Window's Tomcat 5.5 - as an Axis Webservice. The application uses few DLL files, which I've placed the in the dir - $TOMCAT_HOME\common\endorsed\ and specified the same in the java.library.path. But the DLL files are not recognized by the Tomcat. Following Exception is thrown: java.lang...

Attachments+Html generated with commons-email doesn't show in some email clients

Hi, I've been using the org.apache.commons.mail.HtmlEmail class, from apache commons-mail, for some time. Eventually, some users complain that the email shows with no attachemnts on their e-mail client (problem reported in Outlook 2007 and Lotus Notes). One user have even analysed the problem and sent me the following link: http://sup...

A static file upload (text or HTML) cause full deployment in Google App Engine?

I have to change some contents in a html or text file. Or I have to upload an image. I have to re-deploy my application on GAE. Is there any way that I can upload such static files to the desire location from my hard disk? Please thanks for your help. ...

Java, Google Collections Library; problem with AbstractIterator?

I am using the Google Collections library AbstractIterator to implement a generator. I ran across a problem while doing so; I've reduced it to a more basic type and reproduced the problem. This reduction is obviously overkill for what it does, counting from 1 to numelements via an Iterable. Essentially in the following code, the uncom...

How is exif info encoded?

Greetings, I'm going to get exif info from some images using android. I know there are some standard java lib's out there that I could use with the device. I'm sure I will end up using one. But in the meantime can someone explain to me how this information is encoded inside a JPG? Where / how would you usually get the info from the ...