Win a copy of Spring in Action (5th edition) this week in the Spring forum!

gilbert engle

Greenhorn
+ Follow
since Jun 03, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
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 gilbert engle

toplink session readobject nullpointerexception

Are you looking for these keywords?

You will get a nullpointerexception from session.readObject if you don't include a setter method for your class.

DirectToFieldMapping somethingIntValueMapping = new DirectToFieldMapping();
somethingIntValueMapping.setAttributeName("intValue");
somethingIntValueMapping.setGetMethodName("getIntValue");
somethingIntValueMapping.setSetMethodName("setIntValue"); // gotta have this!
somethingIntValueMapping.setFieldName("EGOV_IAC.SOMETHING.INTVALUE");
somethingIntValueMapping.readOnly();
descriptor.addMapping(somethingIntValueMapping);

When you call readObject this is a request to read an object from the database. It is required that you provide setter methods for ALL object data attributes so that the readObject method can do its job

Session.readObject should be able to detect this problem and give you a meaningful Exception to work with, but it does not. I spent a long time on this one!
OK, who knows what the deal was but Chrome is now working properly for me. Apparently I was experiencing some sort of transient error.

Windows 7, 64 bit, 4GB, Dell Inspiron N411Z
6 years ago
PHP
This is the original author. I tried Chrome on a different machine and it worked properly. Both systems are using Windows 7. Who knows what's wrong with the original machine.
6 years ago
PHP
// here's a test URL
http://newjazz.net/php/index.php

If you use Firefox or IE you get a page with images and links. If you use Chrome you get the HTML source code displayed in the window without interpretation. I tried

<?php
header('Content-type: text/html');

but it didn't help. I just get plain HTML code displayed in the window. Anybody else having this same problem? I should have the latest version of Chrome.

thank you
6 years ago
PHP
I successfully got ActiveMQ working with SSL and JBOSS. Here's all the information


Follow directions here

http://activemq.apache.org/how-do-i-use-ssl.html

// I don't think it is necessary to update ALL of the following files but I haven't taken the time to figure which are important
activemq-command,xml

<transportConnector name="ssl" uri="ssl://localhost:61617?wantClientAuth=true&needClientAuth=true&transport.commandTracingEnabled=true" />

activemq-demo.xml // probably not needed

<transportConnector name="ssl" uri="ssl://localhost:61617"/>

activemq-dynamic-network-broker1.xml

<transportConnector name="ssl" uri="ssl://localhost:61617?wantClientAuth=true&needClientAuth=true&transport.commandTracingEnabled=true" />

activemq-dynamic-network-broker2.xml

<transportConnector name="ssl" uri="ssl://localhost:61617?wantClientAuth=true&needClientAuth=true&transport.commandTracingEnabled=true" />

activemq-jdbc.xml

<transportConnector name="ssl" uri="ssl://localhost:61617?wantClientAuth=true&needClientAuth=true&transport.commandTracingEnabled=true" />

activemq-security.xml

<transportConnector name="ssl" uri="ssl://localhost:61617?wantClientAuth=true&needClientAuth=true&transport.commandTracingEnabled=true" />

activemq-specjms.xml

<transportConnector name="ssl" uri="ssl://localhost:61617?wantClientAuth=true&needClientAuth=true&transport.commandTracingEnabled=true" />

activemq-static-network-broker1.xml

<transportConnector name="ssl" uri="ssl://localhost:61617?wantClientAuth=true&needClientAuth=true&transport.commandTracingEnabled=true" />

activemq-static-network-broker2.xml

<networkConnector uri="staticssl://localhost:61616)" duplex="true"/>

activemq-throughput.xml

<transportConnector name="ssl" uri="ssl://localhost:61617?needClientAuth=true" />

activemq.xml (inside <broker>

<transportConnector name="ssl" uri="ssl://localhost:61617?needClientAuth=true" />

activemq.xml

<transportConnector name="ssl" uri="ssl://localhost:61617?needClientAuth=true" />

// the following was placed inside AND outside of <broker>
<amq:broker useJmx="false" persistent="false">

<amq:sslContext>
<amq:sslContext
keyStore="c:/ActiveMQ/broker.ks" keyStorePassword="password"
trustStore="c:/ActiveMQ/client.ks" trustStorePassword="password"/>
</amq:sslContext>

<amq:transportConnectors>
<amq:transportConnector uri="ssl://localhost:61616" />
</amq:transportConnectors>

</amq:broker>


Download activemq-cpp-library-3.4.3 project
Download Bloodshed Dev C++
Download Open SSL
Drop all source files from activemq-cpp-library-3.4.3/src/main into a Dev C++ project
Set Dev C++ to build a DLL
Update main/activmq/util/Config.h, insert #define HAVE_OPENSSL 1
Build DLL from Dev C++
Update system PATH variable to point to directory containing the DLL
Update system PATH variable to point to \OpenSSL-Win64\lib

Change your code so that you have

ConnectionFactory connectionFactory =
new ActiveMQConnectionFactory("ssl://localhost:61617");

Update activemq.bat to set info about keystores and trust stores, when starting activemq precede by seting ACTIVEMQ_ENCRYPTION_PASSWORD=activemq

"%_JAVACMD%" %SUNJMX% %ACTIVEMQ_DEBUG_OPTS% %ACTIVEMQ_OPTS% %SSL_OPTS% -Dactivemq.classpath="%ACTIVEMQ_CLASSPATH%" -Dactivemq.home="%ACTIVEMQ_HOME%" -Dactivemq.base="%ACTIVEMQ_BASE%" -Dactivemq.conf="%ACTIVEMQ_CONF%" -Dactivemq.data="%ACTIVEMQ_DATA%" -Djava.io.tmpdir="%ACTIVEMQ_TMP%" -Djavax.net.ssl.keyStore=c:/ActiveMQ/broker.ks -Djavax.net.ssl.keyStorePassword=password -Djavax.net.ssl.trustStore=c:/activemq/broker.ts -Djavax.net.ssl.trustStorePassword=password -jar "%ACTIVEMQ_HOME%/bin/run.jar" %*

Add debug command to activemq

if "%ACTIVEMQ_OPTS%" == "" set ACTIVEMQ_OPTS=-Xms1G -Xmx1G -Djava.util.logging.config.file=logging.properties -Djavax.net.debug=ssl

When starting client add

java -Djavax.net.debug=ssl -Djavax.net.ssl.keyStore=c:/yourpath/client.ks -Djavax.net.ssl.keyStorePassword=password -Djavax.net.ssl.trustStore=c:/yourpath/client.ts -Djavax.net.ssl.trustStorePassword=password


OK, I tried to cover everything. All of this will definitely help you reach your goal of ActiveMQ invocation with server and client SSL validation



OK, I have made some progress since my original problem question post. Here's the new scenario

Server server = new Server(Protocol.HTTP, 8182, new TestServerApplication());
server.start()
// does NOT work
router.attach("/contacts/", ContactServerResource.class); Exception in thread "main" Not Found (404) - Not Found

// does NOT work
router.attach("/contacts/", ContactServerResource.class, Router.MODE_BEST_MATCH); Exception in thread "main" Not Found (404) - Not Found

// works!
router.attachDefault(ContactServerResource.class);

I thought maybe I could try something with Router.createRoute(String, Restlet) but the compiler tells me no such method

I'm stuck now. I'm not sure what else to try. Anybody have any ideas? thank you
6 years ago
I just tried spring-web-3.2.0.M2.jar from the latest release. Same results.
6 years ago
Trying to get this stuff to work on your own is crazy. The pieces and parts presented in the User's Guide are incomplete. I finally located some working source code

http://wiki.restlet.org/docs_2.0/304-restlet/version/default/part/AttachmentData/data/serializationFullSource.zip
6 years ago
OK, trying to get this stuff to work on your own is crazy. The pieces and parts that are presented in the user's guide are incomplete. I finally located some working source files.

http://wiki.restlet.org/docs_2.0/304-restlet/version/default/part/AttachmentData/data/serializationFullSource.zip

6 years ago
public class MyTestClientResource {

public static void main(String[] args) throws Exception {

ClientResource clientResource = new ClientResource(
"http://localhost:8182/rest/test");
MyTestResource testResource = clientResource.wrap(MyTestResource.class);

// Retrieve the JSON value
Customer result = testResource.retrieve();

System.out.println("CUSTOMER " + result);
if (result != null) {
System.out.println(result);
}
}
}


public interface MyTestResource {

@Get
public Customer retrieve();

@Put
public void store(Customer customer);

@Post
public void stop() throws Exception;

@Delete
public void remove() throws Exception;

}


public class TestServerResource extends ServerResource implements MyTestResource {

private static volatile Customer myCustomer = Customer.createSample();
private static Server server = null;

public static void main(String[] args) throws Exception {
server = new Server(Protocol.HTTP, 8182, TestServerResource.class);
server.start();
}

public Customer retrieve() {
System.out.println("GET request received");
System.out.println("CUSTOMER( " + myCustomer + ")");
return myCustomer;
}

public void store(Customer customer) {
System.out.println("PUT request received");
myCustomer = customer;
}

public void stop() throws Exception {
System.out.println("POST request received");
server.stop();
}

public void remove() throws Exception {
System.out.println("DELETE request received");
myCustomer = null;
}

}


runnning MyTestClientResource results in

CUSTOMER = null

I carefully copied all of the source code from the example but it just doesn't work. Any ideas? Thank you very much

source code example

http://wiki.restlet.org/docs_2.0/13-restlet/27-restlet/328-restlet/285-restlet.html

6 years ago
I am trying to put together a web service example with Spring beans. I am getting the following error

19:46:20,478 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-
host].[/iiii]] (MSC service thread 1-2) Exception sending context initialized ev
ent to listener instance of class org.springframework.web.context.ContextLoaderL
istener: org.springframework.beans.factory.BeanDefinitionStoreException: Line 5
in XML document from class path resource [applicationContext.xml] is invalid; ne
sted exception is org.xml.sax.SAXParseException; lineNumber: 5; columnNumber: 76
; Document root element "beans", must match DOCTYPE root "null"..

I have read that this can be caused by old spring jar files. It seems to be loading the wrong version of org.springframework.web.context.ContextLoaderListener.

I have spring-web-2.0-m2.jar in JBOSS_CLASSPATH, the system classpath, and I pass it into Jboss with -classpath.

I can't tell what jar file JBoss is actually using. There are no *spring* files in the JBoss directory structure.

I also put spring-web-2.0-m2.jar into my war file WEB-INF/lib directory.

Does anybody know if there is a newer jar than spring-web-2.0-m2.jar that contains org.springframework.web.context.ContextLoaderListener? I used findjar.com buy it shows like twenty jar files that contain the class. There is now way to tell which of the listed jar files is the most recent.

Thank you very much for any information.


6 years ago
Here's some more information

I am using WizTools.org RESTClient 3.0

I issue the following GET request

127.0.0.1:8182/users/1 through RESTClient 3.0

The java console shows

Oct 03, 2012 8:40:02 AM com.noelios.restlet.LogFilter afterHandle
INFO: 2012-10-03 08:40:02 127.0.0.1 - - 8182 GET /users/1 - 200 0 - 16 http://127.0.0.1:8182 Apache-HttpClient/4.2.1 (java 1.5)

The RESTClient output shows

Oct 03, 2012 8:40:03 AM org.wiztools.restclient.HTTPClientRequestExecuter execut
e
WARNING: Content-Type header not available in response. Using platform default e
ncoding: windows-1252

The RESTClient 3.0 GUI reports

Content-Length 0
Date: (a date value of the request)
Accept-Ranges bytes
Server Noelios-Restlet-Engine/1.1.10
Connection close
6 years ago
Restlet Code

public static void main(String[] args) {

Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
component.getClients().add(Protocol.FILE);


Context ctx = component.getContext();
final Context childCtx = ctx.createChildContext();
Application application = new Application(childCtx) {
@Override
public Restlet createRoot() {
// Create a root router
Router router = new Router(childCtx);

public void handle(Request request, Response response) {
// Print the user name of the requested orders
String message = "Orders of user \""
+ request.getAttributes().get("users") + "\"";
response.setEntity(message, MediaType.TEXT_PLAIN);
}
};

router.attach("/users/{user}", account);
router.attach("/object/", TestServerResource.class);

return router;
}
};

component.getDefaultHost().attach(application);

component.start();
}
}
}

When I use the GUI test tool and submit a GET request the console logs the fact that a request was received but no data is returned. A breakpoint in the handle() method is never hit. The TestServerResource class is never accessed either. I copied this example from the Restlet user guide. I feel like I have entered everything correctly but things just aren't working. Is there an important step that I have missed?

thank you
6 years ago
thanks for your input

// here's where I saw the note saying that there is now way to escape 0x14
http://stackoverflow.com/questions/1165966/xml-serialization-of-an-object-containing-invalid-chars


OK, I really messed up my earlier source code example. Let me try again.


String encryptedValue = new BASE64Encoder().encode(valueToEncrypt.getBytes());

Sending this string does not cause a problem and it does not contain any 0x14 characters.



String something = "medium length XML string, plain vanilla characters";
Key secretKey = generateKey(something.getBytes());
Cipher c = Cipher.getInstance(ALGORITHM);
c.init(Cipher.ENCRYPT_MODE, secretKey);
System.out.println("doFinal");
byte[] encValue = c.doFinal(valueToEncrypt.getBytes());
String encryptedValue = new BASE64Encoder().encode(encValue);

This encryptedValue String causes an XMLStreamException. Before I send the String I examine every character and I do not find any 0x14 characters. Somehow a 0x14 character is getting added to the stream. Here's the error message


[javax.xml.stream.XMLStreamException: ParseError at [row,col]:[7,57]
Message: An invalid XML character (Unicode: 0x14) was found in the element content of the document.]

The thing is I have no way of figuring out [row,col]:[7,57]. There are no newLine characters in the stream to account for 7 rows.

Do you have any idea how to use [row,col]:[7,57] to find the actual character? Thanks very much.
6 years ago

>>>> I suspect the reason it fails in your second example is because the character 0x14 is not encoded. This is not a character supported by XML so must be escaped or encoded.

I read that encoded or escaping the 0x14 character is not going to work. It's still not going to like it.

My problem has evolved to an even stranger level. When I Base64 encode a String and send it to the web service there are no problems. There is no 0x14 character within the String. When I use AES to encrypt a String it fails when it is sent to the web service due to a 0x14 character in the stream. The thing is I check every character in the problem String before it is sent and I don't find any 0x14 characters. I don't know how the problem character is getting into the stream.

javax.xml.ws.WebServiceException: javax.xml.bind.UnmarshalException
- with linked exception:
[javax.xml.stream.XMLStreamException: ParseError at [row,col]:[7,49]
Message: An invalid XML character (Unicode: 0x14) was found in the element conte
nt of the document.]
at com.sun.xml.internal.ws.server.sei.EndpointMethodHandler.invoke(Unkno
wn Source)
6 years ago