Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

J.D. Thompson

Greenhorn
+ Follow
since Mar 08, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by J.D. Thompson

Okay, issue resolved. Problem was in the class annotated with @XmlRootElement, @XmlElement, etc. all of the getter and setters were correct for the member variables, however I had named one method "getCopy" to create a deep copy of the POJO. Jackson, upon converting to JSON, evidently was trying to match this to a member variable "copy", couldn't find it and threw an exception.

So, for any helper methods in your RESTEasy POJO's, DO NOT begin with get or set unless they correspond to a member variable.

Hope this posting helps someone else!!!

Happy New Year!!
10 years ago
I have been through all of the files in the JBOSS_HOME/server/default/conf directory and do not see anyway to configure automounting. I am trying to prevent the JAXB Provider jars associated with jackson as they are causing me problems. Is there a way to configure this? Otherwise, for every JBoss installation as well as upgrade these jars will have to be removed.

Currently using JBoss 6.1.

Take care!

JD
10 years ago
I am creating a web service using resteasy and running in JBoss 6.1. I am attempting to use the JAXB Provider Jettison for the following class:



I am using the @XmlRootElement, @XmlAttribute, @XmlElement annotations.

In my POM file(using Maven to build), I list the dependency for for using resteasy-jaxrs, resteasy-jaxb-provider, and resteasy-jettison-provider.

The xml production works without a problem. However, when the return content type is specifed to be JSON, i get the following exception thrown:

Unexpected error during load of:org.codehaus.jackson.map.JsonMappingException$Reference: java.lang.StackOverflowError
with alot of addtional "at" statements in the print trace stack.

The annotated POJO class has a zero argument constructor and get/set for each element/attribute annotated.

Has anyone else run into this or can offer a suggestion?

Thank you very much.


JD

PS - I have to type everything as the actual development is on another computer behind and I cannot copy/move the code to this unsecure machine.
10 years ago
Okay, have solved the issue. The URL passed to add needs to be the containing structure, not the resource itself, i.e.

file:/C:/HelloWorld/config/

instead of

file:/C:/HelloWorld/config/application.properties


hope this helps anyone else attempting to dynamically add to the classpath!!!
12 years ago
Sorry about that, I thought the dashed line with code snippet would work, here is the portion that the tags would apply to:



Thank you!

JD
12 years ago
I have to write code so that no matter what the path is, the relative directories with configuration files and supporting jar libraries will be added at the application invocation. (This has to work from inside the eclipse framework AND in a production build).

Development Structure:

HelloWorld(Project)
/classes
HelloWord.class
/config
application.properties
/lib

Production Structure:
HelloWorld.jar
/config
application.properties
/lib
neededJar.jar

The URL for the properties is: file:/C:/HelloWorld/config/application.properties (dynamically created by using File to find config and then toUri().toURL()
Similar approach for the jar.

These are returned from createURLS() [method not shown here].

The following code snippet (minus the try/catch) is then used to attempt to add to the classloader's classpath:
--------------------------------------------------------------------------------------------------------------------------------
ArrayList<URL> list = createURLS();

Method [] methods = URLClassLoader.class.getDeclaredMethods();
Method getURLs = URLClassLoader.class.getDeclaredMethod("getURLs", null); //used to check for urls added
Method addURL = URLClassLoader.class.getDeclaredMethod("addURL", new Class [] {URL.class}); //used to add the urls

getURLs.setAccessible(true);
addURL.setAccessible(true);


Object a = getURLs.invoke(HelloWorld.class.getClassLoader(), null); //see what urls are present before adding

for(URL url: list)
{
addURL.invoke(HelloWorld.class.getClassLoader(), url);
}

a = getURLs.invoke(HelloWorld.class.getClassLoader(), null); //confirm that urls are added

URL url = HelloWorld.class.getResource("application.properties");

-------------------------------------------------------------------------------------------
end snippet

The url variable returns NULL!

I do not understand why this tried approach is not working! Any suggestions or clarifications?

Please accept my thanks for your time in responding in advance!!

JD

12 years ago
Ty very much!!

Have a great day!!

JD
12 years ago
Example code

private StringBuffer m_buffer=new StringBuffer();


public synchronized method1(String value)
{
m_buffer.append(value);
method2();
}

public method2()
{
System.out.println(m_buffer.toString());
m_buffer.setLength(0);
}

Is m_buffer protected during one threads call from all other threads in method2??

Thank you in advance for your prompt reply.
12 years ago
I am having problems having my "HelloWorld" server retrieve the "NameService" from the Name Service Server. As I go into the ORB.class code I noticed several deprecated methods which leads me to my first question: Does anyone know if JacORB 2.3.0 compliant with the Java 1.6 JRE?

I have other questions to post if the answer to this one is a definite yes.

Thank you in advance for your time in looking at this post!!!

Take care and Happy New Year!!!

JD
13 years ago
I am currently running a server application on a remote linux machine. We have JProbe to use as our profiler but I cannot find a way to connect to a running JVM started without JProbe. There seems to be ways of doing this as referenced by different threads and posting in various Googled forums but no specifics.

Does anyone out there in Java World know how to do this?

Currently running JProbe 8.0 on local machine with 1.6 on the remote.

Thanks in advance for any responses!!!

PS - trying a new/different profiler is not an option as the company "purchased" this for us and we "need to use JProbe".
13 years ago
I am looking into finding a way to improve the current speed of an application I am working on. The major hangup right now is the reading of bits from a TCP socket.

The current application basically reads into a byte array, decodes, flips, and then appends a StringBuilder buffer. This buffer is then regex'd to see if a new message has arrived.

Is there a better technique, perhaps at the bit level, that I could look into adapting and using?

Currently, we handle a maximum of 5 messages per sec where each message is approx 160 bytes. I would like to improve this through a better read to 8 or greater.

Thanks for your feedback and thoughts!!!

JD
13 years ago
Ok, I have the answer!!!

Mysql allows multiples sessions to the server instance. As a result, you can have different profiling for different sessions, thus it is critical that you set the profiling for the built-in MySQL Profiler from INSIDE the application you are wanting to profile, IF you are desiring to profile live queries versus profiling from the command line on a query by query basis.

Once you have obtained a connection to the database, you execute the following query:

set profiling=1;

and a temporary table within the information_schema db will be created. ALL queries run by the application will then be measured and recorded and values stored. However, you must capture that information BEFORE your session ends, i.e. the application instance vanishes.

There is alot more to share but the following link is a great help once you know how to start the profiling from inside the app:

http://dev.mysql.com/tech-resources/articles/using-new-query-profiler.html

Hope this helps the next guy!!!

Take care!
I am conducting performance testing on a Java Application which uses a MySQL db. I am attempting to use MySQL Query Profiler to measure db performance. Both are on the same Linux machine.

I initiate the profiler by logging into the MySQL client and "set profiling=1". However, this captures only the queries executed from the command line and not those from the application.

Any ideas on how I need to go about this?

Thanks in advance for your insight and help!

JD
OK, I have the answer and am posting in case someone else experiences the same issue.

The short answer is: this is the serial number format MS Excel uses behind the scenes to store date/time information. It is based on the number of days since 1/1/1900.
13 years ago