java

Is it safe to get values from a java.util.HashMap from multiple threads (no modification)?

There is a case where a map will be constructed, and once it is initialized, it will never be modified again. It will however, be accessed (via get(key) only) from multiple threads. Is it safe to use a java.util.HashMap in this way? (Currently, I'm happily using a java.util.concurrent.ConcurrentHashMap, and have no measured need to im...

JPA 1 is not good enough

Working in a medium size project during last 4 months - we are using JPA and Spring - I'm quite sure that JPA is not powerfull for projects that requires more than CRUD screen... Query interface is poor, Hibernate doesn't respect JPA spec all the time and lot of times I need to use hibernate classes, annotations and config. What do ...

looking for best practice guidlines (or any guidelines) on using the jax-ws maven plugin

My particular use case is using the wsimport goal (which basically maps to the jaxws wsimport.sh tool) to generate java code from wsdl. Looking for ideas on how others have integrated this goal into their development cycle. ie. do you generate all the interfaces only once and check it in. Where do you store the actual wsdl and any xsd...

java.io.Console support in Eclipse IDE

I use the Eclipse IDE to develop, compile, and run my Java projects. Today, I'm trying to use the java.io.Console class to manage output and, more importantly, user input. The problem is that System.Console() returns null when an application is run "through" Eclipse. Eclipse run the program on a background process, rather than a top-lev...

Mac OS X Java Swing Buttons are Disabled for no aparent reason

I wrote an application in Java and when it runs on one customer's computer running OS X The Save and Export buttons are disabled. (Everything else works in the application.) Both of these buttons open up a standard save file dialog. Any ideas? ...

Memory footprint issues with JAVA, JNI, and C application

I have a piece of an application that is written in C, it spawns a JVM and uses JNI to interact with a Java application. My memory footprint via Process Explorer gets upto 1GB and runs out of memory. Now as far as I know it should be able to get upto 2GB. One thing I believe is that the memory the JVM is using isn't visible in the Pro...

How to configure ResourceBundleViewResolver in Spring Framework 2.0

Everywhere I look always the same explanation pop ups. Configure the view resolver. <bean id="viewMappings" class="org.springframework.web.servlet.view.ResourceBundleViewResolver"> <property name="basename" value="views" /> </bean> And then put a file in the classpath named view.properties with some key-value pairs (don't mind the...

Sort on a string that may contain a number

I need to write a Java Comparator class that compares Strings, however with one twist. If the two strings it is comparing are the same at the beginning and end of the string are the same, and the middle part that differs is an integer, then compare based on the numeric values of those integers. For example, I want the following strings...

Why aren't Java Collections remove methods generic?

Why isn't Collection.remove(Object o) generic? Seems like Collection<E> could have boolean remove(E o); Then, when you accidentally try to remove (for example) Set<String> instead of each individual String from a Collection<String>, it would be a compile time error instead of a debugging problem later. ...

How do you create automated tests of a Maven plugin using JUnit?

I've got a (mostly) working plugin developed, but since its function is directly related to the project it processes, how do you develop unit and integration tests for the plugin. The best idea I've had is to create an integration test project for the plugin that uses the plugin during its lifecycle and has tests that report on the plug...

"SetPropertiesRule" warning message when starting Tomcat from Eclipse

When I start Tomcat (6.0.18) from Eclipse (3.4), I receive this message (first in the log): WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server: (project name)' did not find a matching property. Seems this message does not have any severe impact, however,...

Is there an easy way to get Apache Tomcat to reboot automatically after a deployment?

Our project uses Cruise Control to both build and hot deploy a web application to a remote server (via FTP) running Tomcat in the form of a .war file. Unfortunately, "hot" deploys don't appear to work properly, causing us to reboot Tomcat in response to each deployment. We would really like to do this auto-magically, much like the buil...

Thinking of learning Maven

I have a side project I do = in Java. It's a pretty straight-forward webapp. It runs in Tomcat on a Linux Server and uses a MySQL database. The majority of the code was written with the Spring Framework. It has a lot of Unit Tests in place. When I'm coding it's in Eclipse. When I deploy the application I run a few shell scripts to move...

Gsoap Error in C++

I am using gsoap to create a soap server in C++. Messages are routed through a bus written in java. Both the server and the bus are multithreaded. Everything works well sending one message at a time through the system. If i start 3 clients each sending messages as fast as possible everything is fine for about 3500 messages. Then i begin ...

Is there a Java-based ray tracing model that can be adapted for use in underwater acoustics?

I am looking for an open-source Java-based raytracing system suitable for use in modeling underwater ray-based acoustics. Such a package might be similar to the Comprehensive Acoustic System Simulation (CASS) with the Gaussian Ray Bundle (GRAB) but I would prefer an open-source, free-to-use or free-to-modify model that I can use in pres...

Most important problem solved by EJB 3?

The scenario You have developed a webapp using EJBs version 3. The system is deployed, delivered and is used by the customer. If you would have to rewrite the system from scratch, would you use EJBs again? No: Don't answer this question, answer this one instead. Yes: Provide one important, real problem that EJBs solved, based on yo...

Is there any way to enable the mousewheel (for scrolling) in Java apps?

Ideally I'd like a way to enable the mousewheel for scrolling in old compiled java runtime apps, but java code to explicitly utilize it for an individual app would suffice. ...

Best practices for configuring Apache / Tomcat

We are currently using Apache 2.2.3 and Tomcat 5 (Embedded in JBoss 4.2.2) using mod_proxy_jk as the connector. Can someone shed some light on the the correct way to calculate / configure the values below (as well as anything else that may be relevant). Both Apache and Tomcat are running on separate machines and have copious amounts of...

Does the JVM prevent tail call optimizations?

I saw this on a question: Scala in particular doesn't support tail-call elimination except in self-recursive functions, which limits the kinds of composition you can do (this is a fundamental limitation of the JVM). Is this true? If so, what is it about the JVM that creates this fundamental limitation? ...

How do I get the value of the jdbc.batch_size property at runtime for a Web application using Spring MVC and Hibernate?

According to what I have found so far, I can use the following code: LocalSessionFactoryBean sessionFactory = (LocalSessionFactoryBean)super.getApplicationContext().getBean(" System.out.println(sessionFactory.getConfiguration().buildSettings().getJdbcBatchSize()); but then I get a Hibernate Exception: org.hibernate.HibernateE...