microtan / nhin-d

Automatically exported from code.google.com/p/nhin-d
0 stars 0 forks source link

agent doesn't work with mysql #157

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When config-service uses mysql as storage instead of Derby, James is not 
started with exception below. It seems that Axis doesn't support date/time 
without milliseconds. config-service with Derby returns date/time with 
yyyy-MM-dd'T'HH:mm:ss.SSS'Z' format, but the format is yyyy-MM-dd'T'HH:mm:ss'Z' 
with mysql.

config-ui is using config-service-jar as the SOAP client, so that if gateway 
uses config-service-jar instead of config-service-client, it will be resolved.

java.lang.ClassCastException: org.nhind.config.Address cannot be cast to 
[Lorg.nhind.config.Domain;
        at org.nhindirect.config.service.impl.ConfigurationServiceImplServiceSoapBindingStub.listDomains(ConfigurationServiceImplServiceSoapBindingStub.java:1741)
        at org.nhind.config.ConfigurationServiceProxy.listDomains(ConfigurationServiceProxy.java:140)
        at org.nhindirect.gateway.smtp.config.WSSmtpAgentConfig.buildDomains(WSSmtpAgentConfig.java:200)
        at org.nhindirect.gateway.smtp.config.WSSmtpAgentConfig.buildAgentInjector(WSSmtpAgentConfig.java:150)
        at org.nhindirect.gateway.smtp.config.WSSmtpAgentConfig.getAgentInjector(WSSmtpAgentConfig.java:144)
        at org.nhindirect.gateway.smtp.SmtpAgentFactory.buildAgentInjector(SmtpAgentFactory.java:135)
        at org.nhindirect.gateway.smtp.SmtpAgentFactory.createAgent(SmtpAgentFactory.java:96)

Original issue reported on code.google.com by teru.mor...@gmail.com on 22 Jul 2011 at 2:32

GoogleCodeExporter commented 9 years ago
Could you please provide your entityManagerFactory and dataSource XML 
configuration in the beans.xml file?

thx

Original comment by gm2...@cerner.com on 1 Aug 2011 at 12:13

GoogleCodeExporter commented 9 years ago
I have replicated the error with mysql.

Original comment by gm2...@cerner.com on 1 Aug 2011 at 1:31

GoogleCodeExporter commented 9 years ago
teru, have you found a solution for this problem?

-doru 

Original comment by doru.mih...@gmail.com on 18 Oct 2012 at 4:12

GoogleCodeExporter commented 9 years ago
Issue:

The id on the domain and address xml tags are 'clashing' since the both id 
values are simply the value of the records numeric primary key. To fix the 
problem the ids need to be unique.

Note: this is not a MySQL issue but an issue with the formatting of the SOAP 
message.

Workaround:

Change the values of the domain or address primary keys that are clashing 
(making sure you also change any foreign key fields) e.g. change address.id and 
domain.postmasterAddressId

Fix:

For the config-store project

Annotate
 - org.nhindirect.config.store.Address.getId with @XmlAttribute

When addressing this issue I chose to also add @XmlAttribute to the following 
methods
 - org.nhindirect.config.store.Domain.getId
 - org.nhindirect.config.store.Domain.getStatus

Happy new year!

Original comment by phillip....@nitorgroup.com on 31 Dec 2012 at 8:09

GoogleCodeExporter commented 9 years ago
Just an update on what the exception looks like in version 2.0

At the head of the logged exception you'll now see the following in Direct 2.0 
as opposed to the class cast exception under 1.x. The same underlying issue is 
cause.

ERROR HH:mm:ss,SSS | james.mailprocessor | Unable to init mailet 
org.nhindirect.gateway.smtp.james.mailet.NHINDSecurityAndTrustMailet: 
javax.mail.MessagingException: Failed to create the SMTP agent: WebService 
error getting domains list: ; nested exception is: 
        java.lang.ArrayStoreException: org.nhind.config.Address (org.nhindirect.gateway.smtp.SmtpAgentException: WebService error getting domains list: ; nested exception is: 
        java.lang.ArrayStoreException: org.nhind.config.Address)
javax.mail.MessagingException: Failed to create the SMTP agent: WebService 
error getting domains list: ; nested exception is: 
        java.lang.ArrayStoreException: org.nhind.config.Address (org.nhindirect.gateway.smtp.SmtpAgentException: WebService error getting domains list: ; nested exception is: 
        java.lang.ArrayStoreException: org.nhind.config.Address)
        at org.nhindirect.gateway.smtp.james.mailet.NHINDSecurityAndTrustMailet.init(NHINDSecurityAndTrustMailet.java:137)

Original comment by phillip....@nitorgroup.com on 11 Feb 2013 at 3:44

GoogleCodeExporter commented 9 years ago
Hi All,

I have the same issue, Unable to proceed further.
Can you please help me to use MySQL and/or MS SQL Server database for config-ui 
instead of Derby.

Thanks,
Sai

Original comment by saibabu....@gmail.com on 16 Feb 2013 at 4:20

GoogleCodeExporter commented 9 years ago
I am facing problem with MySQL tool.

If I have one domain listed i get the following:

Exception in thread "main" java.lang.ClassCastException: 
org.nhind.config.Address cannot be cast to [Lorg.nhind.config.Domain;
    at org.nhindirect.config.service.impl.ConfigurationServiceImplServiceSoapBindingStub.listDomains(ConfigurationServiceImplServiceSoapBindingStub.java:1741)
    at org.nhind.config.ConfigurationServiceProxy.listDomains(ConfigurationServiceProxy.java:140)
    at sendmail.TestConfigClient.main(TestConfigClient.java:23)

If I have more than one domain listed :

Exception in thread "main" AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode: 
 faultString: java.lang.ArrayStoreException: org.nhind.config.Address
 faultActor: 
 faultNode: 
 faultDetail: 
    {http://xml.apache.org/axis/}stackTrace:java.lang.ArrayStoreException: org.nhind.config.Address
    at org.apache.axis.utils.JavaUtils.convert(JavaUtils.java:493)
    at org.apache.axis.client.Call.invoke(Call.java:2537)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at org.nhindirect.config.service.impl.ConfigurationServiceImplServiceSoapBindingStub.listDomains(ConfigurationServiceImplServiceSoapBindingStub.java:1731)
    at org.nhind.config.ConfigurationServiceProxy.listDomains(ConfigurationServiceProxy.java:140)
    at sendmail.TestConfigClient.main(TestConfigClient.java:23)

    {http://xml.apache.org/axis/}hostname:ltSaswataGhose

java.lang.ArrayStoreException: org.nhind.config.Address
    at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
    at org.apache.axis.client.Call.invoke(Call.java:1828)
    at org.nhindirect.config.service.impl.ConfigurationServiceImplServiceSoapBindingStub.listDomains(ConfigurationServiceImplServiceSoapBindingStub.java:1731)
    at org.nhind.config.ConfigurationServiceProxy.listDomains(ConfigurationServiceProxy.java:140)
    at sendmail.TestConfigClient.main(TestConfigClient.java:23)
Caused by: java.lang.ArrayStoreException: org.nhind.config.Address
    at org.apache.axis.utils.JavaUtils.convert(JavaUtils.java:493)
    at org.apache.axis.client.Call.invoke(Call.java:2537)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    ... 3 more

Original comment by saswatag...@gmail.com on 25 Feb 2013 at 9:34

GoogleCodeExporter commented 9 years ago
Hi saswatag and Sai

In saswatag's case since the entire exception is reported but should also be 
applicable to Sau, going by the (org.nhind.config.Address cannot be cast to 
[Lorg.nhind.config.Domain) from my experience the detail I posted on Dec 31, 
2012 up above is will help you.

One really easy way to workaround this issue is to simply login to the 
config-ui and delete the address on the domain and then re-add it. Then try 
starting apache james, if it still errors out just keep deleting the address 
and re-adding it until james starts. What's happening each time you delete the 
address and re-add it is that the primary key of the address is incrementing by 
1 and eventually it will not match any of the primary keys of the domains you 
have in the system.

If you're more interested in actually fixing the problem before the direct 
project gets the fix into a release, just follow my fix details on Dec 31, 2012.

Thanks
Phillip

Original comment by phillip....@nitorgroup.com on 8 Mar 2013 at 9:15

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Phillip's suggested changes seem to have made it into the source code, but for 
me the problem persists (James 2.3.2).  

james.log:

SEVERE: Failed to create the SMTP agent: WebService error getting domains list: 
org.nhind.config.Address cannot be cast to [Lorg.nhind.config.Domain;
ERROR=InvalidConfigurationFormat^M

        at org.nhindirect.gateway.smtp.config.WSSmtpAgentConfig.buildDomains(WSSmtpAgentConfig.java:346)
        at org.nhindirect.gateway.smtp.config.WSSmtpAgentConfig.buildAgentInjector(WSSmtpAgentConfig.java:193)
        at org.nhindirect.gateway.smtp.config.WSSmtpAgentConfig.getAgentInjector(WSSmtpAgentConfig.java:187)
        at org.nhindirect.gateway.smtp.SmtpAgentFactory.buildAgentInjector(SmtpAgentFactory.java:134)
        at org.nhindirect.gateway.smtp.SmtpAgentFactory.createAgent(SmtpAgentFactory.java:95)
        at org.nhindirect.gateway.smtp.james.mailet.NHINDSecurityAndTrustMailet.init(NHINDSecurityAndTrustMailet.java:150)
        at org.apache.mailet.base.GenericMailet.init(GenericMailet.java:181)
<snip>

logs/phoenix.log:

ERROR   2013-10-26 17:34:57.613 [Phoenix.] (): Component named "spoolmanager" 
failed to pass through the Starting stage. (Reason: 
javax.mail.MessagingException: Failed to create the SMTP agent: WebService 
error getting domains list: org.nhind.config.Address cannot be cast to 
[Lorg.nhind.config.Domain;;
  nested exception is:
        ERROR=InvalidConfigurationFormat^M
).
ERROR   2013-10-26 17:34:57.613 [Phoenix.] (): There was an error running phase 
"startup" for Block named "spoolmanager". (Reason: Component named 
"spoolmanager" failed to pass through the Starting stage. (Reason: 
javax.mail.MessagingException: Failed to create the SMTP agent: WebService 
error getting domains list: org.nhind.config.Address cannot be cast to 
[Lorg.nhind.config.Domain;;
  nested exception is:
        ERROR=InvalidConfigurationFormat^M
).).
org.apache.avalon.phoenix.containerkit.lifecycle.LifecycleException: Component 
named "spoolmanager" failed to pass through the Starting stage. (Reason: 
javax.mail.MessagingException: Failed to create the SMTP agent: WebService 
error getting domains list: org.nhind.config.Address cannot be cast to 
[Lorg.nhind.config.Domain;;
  nested exception is:
        ERROR=InvalidConfigurationFormat^M
).
        at org.apache.avalon.phoenix.containerkit.lifecycle.LifecycleHelper.fail(LifecycleHelper.java:354)
        at org.apache.avalon.phoenix.containerkit.lifecycle.LifecycleHelper.startup(LifecycleHelper.java:226)
        at org.apache.avalon.phoenix.components.application.DefaultApplication.startup(DefaultApplication.java:530)
        at org.apache.avalon.phoenix.components.application.DefaultApplication.doRunPhase(DefaultApplication.java:478)
rethrown from
javax.mail.MessagingException: Failed to create the SMTP agent: WebService 
error getting domains list: org.nhind.config.Address cannot be cast to 
[Lorg.nhind.config.Domain;;
  nested exception is:
        ERROR=InvalidConfigurationFormat^M
        at org.nhindirect.gateway.smtp.james.mailet.NHINDSecurityAndTrustMailet.init(NHINDSecurityAndTrustMailet.java:156)
        at org.apache.mailet.base.GenericMailet.init(GenericMailet.java:181)
        at org.apache.james.transport.JamesMailetLoader.getMailet(JamesMailetLoader.java:54)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
rethrown from
ERROR=InvalidConfigurationFormat^M
        at org.nhindirect.gateway.smtp.config.WSSmtpAgentConfig.buildDomains(WSSmtpAgentConfig.java:346)
        at org.nhindirect.gateway.smtp.config.WSSmtpAgentConfig.buildAgentInjector(WSSmtpAgentConfig.java:193)
        at org.nhindirect.gateway.smtp.config.WSSmtpAgentConfig.getAgentInjector(WSSmtpAgentConfig.java:187)
        at org.nhindirect.gateway.smtp.SmtpAgentFactory.buildAgentInjector(SmtpAgentFactory.java:134)
        at org.nhindirect.gateway.smtp.SmtpAgentFactory.createAgent(SmtpAgentFactory.java:95)
        at org.nhindirect.gateway.smtp.james.mailet.NHINDSecurityAndTrustMailet.init(NHINDSecurityAndTrustMailet.java:150)
        at org.apache.mailet.base.GenericMailet.init(GenericMailet.java:181)
<snip>

And the spoolmanager log in james-2.3.2/apps/james/logs:

23/10/13 19:24:48 ERROR spoolmanager: Unable to init mailet 
NHINDSecurityAndTrustMailet: javax.mail.MessagingException: Failed to create 
the SMTP agent: WebService error getting domains list: org.nhind.config.Address 
cannot be cast to [Lorg.nhind.config.Domain;;
nested exception is:
ERROR=InvalidConfigurationFormat

javax.mail.MessagingException: Failed to create the SMTP agent: WebService 
error getting domains list: org.nhind.config.Address cannot be cast to 
[Lorg.nhind.config.Domain;;
nested exception is:
ERROR=InvalidConfigurationFormat

at 
org.nhindirect.gateway.smtp.james.mailet.NHINDSecurityAndTrustMailet.init(NHINDS
ecurityAndTrustMailet.java:156)
at org.apache.mailet.base.GenericMailet.init(GenericMailet.java:181)
<snip>

Original comment by plm...@gmail.com on 27 Oct 2013 at 8:37

GoogleCodeExporter commented 9 years ago
Update - I have found that the cause of this problem is still the same as the 
one Phillip identified.  However, the annotation changes that Phillip suggests 
don't seem to do anything to fix it.

The manual work-around Phillip suggests DOES resolve the issue (temporarily, of 
course).

However, anyone using that method should be careful if the address they need to 
delete and re-add is the postmaster address - the config GUI doesn't seem to 
have a facility to update the foreign key in the domain table that points to 
the postmaster address in the address table. I think that scenario will be 
quite common given that when you're setting up a fresh system, the first thing 
you do in the config GUI is add a domain, which automatically populates both 
the domain and address tables with clashing ID keys for the postmaster address.

Therefore, I suggest that anyone wanting to use the manual work-around go to 
their database directly and run a couple simple queries:

UPDATE address SET id=2 WHERE id=1;
UPDATE domain SET postmasterAddressId=2 WHERE id=1;

You'll want to check that the IDs are as expected before you run these queries. 
Also, it may be possible in some database environments that updating the 
auto-increment columns manually like this could break the internal 
auto-increment system so use caution and check the IDs again after adding 
another address to be sure everything works as expected.

Original comment by plm...@gmail.com on 28 Oct 2013 at 12:16

GoogleCodeExporter commented 9 years ago
Reading back over the fix I mentioned on Dec 31, 2012 I think I must have 
referred to the wrong annotation. The whole issue is that the id is an 
attribute of domain and address (and already annotated as such). So the 
annotation should *not* be @XmlAttribute but instead @XmlElement so there is no 
clash of ids not being unique. Or alternatively make the id values unique (e.g. 
prefix with domain_ and address_) and hey presto the problem just disappears.

Original comment by phillip....@nitorgroup.com on 26 Feb 2014 at 4:57

GoogleCodeExporter commented 9 years ago
Hello Phillip,

I am also having the same issue i changed my config-service to use mysql as 
storage instead of Derby, At that time an error occurred like communication 
link failed due to over load on hibernate. then i added <property 
name="testOnBorrow" value="true"/> <property name="validationQuery" 
value="SELECT 1"/> after database connection property.  Now i am unable to 
start James 2.3.2 due the following error
Unable to init mailet NHINDSecurityAndTrustMailet: 
javax.mail.MessagingException: Failed to create the SMTP agent: WebService 
error getting domains list: org.nhind.config.Address cannot be cast to 
[Lorg.nhind.config.Domain;;
i tried 
UPDATE address SET id=2 WHERE id=1;
UPDATE domain SET postmasterAddressId=2 WHERE id=1;
Even though james server is not srarting.
can you please help me with this and i didn't get the latest comment
"The whole issue is that the id is an attribute of domain and address (and 
already annotated as such). So the annotation should *not* be @XmlAttribute but 
instead @XmlElement so there is no clash of ids not being unique. Or 
alternatively make the id values unique (e.g. prefix with domain_ and address_) 
and hey presto the problem just disappears." Thank you so much in advance for 
your helpful response. 

Thank you,
Harry.

Original comment by itsharsh...@gmail.com on 27 Oct 2014 at 6:57

GoogleCodeExporter commented 9 years ago
Hi Harry

Just saw your comment. The bit you quoted is simply detailing a possible 
approach to resolve the issue via a code change.

The SQL statements you issued ought to have worked around the issue assuming 
that there is no domain with id 2.

Another approach to adjusting the DB is to use the config-ui (delete the 
address and add it again) instead of going behind the scenes and executing the 
SQL directly.

Phillip

Original comment by phillip....@nitorgroup.com on 7 Jan 2015 at 2:00

GoogleCodeExporter commented 9 years ago
Hi Phillip,

Thank you for the explanation now i am clear and my setup is working clear with 
MySql in configure-service but How can i move msg-monitoring service 
configuration to MySql i tried it but in "monitor.properties" file at this line 
19 for this propertiy 
"monitor.recovery.deadLetterURL=file:recovery/directMonitorDeadLetter" i was 
unable to get how to move this configuration(recovery) to Mysql. Can you please 
help me about this configuration. Once again thank you so much for the response.

Thanks,
Harry.

Original comment by itsharsh...@gmail.com on 13 Jan 2015 at 8:19

GoogleCodeExporter commented 9 years ago
FYI, RI 4.0 will address this issue by defaulting the agent to using a REST 
protocol to the configuration service instead of using the SOAP based service.

Original comment by gm2...@cerner.com on 13 Jan 2015 at 8:32